richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
803fb7
From 2520d152da83096b42fe7d27cf0bf97a62b50fac Mon Sep 17 00:00:00 2001
803fb7
From: Michael Gebetsroither <michael@mgeb.org>
803fb7
Date: Thu, 17 Sep 2015 22:54:13 +0200
803fb7
Subject: [PATCH] load-fragment: resolve specifiers in RuntimeDirectory
803fb7
803fb7
Cherry-picked from: 9b5864d
803fb7
Resolves: #1428110
803fb7
---
803fb7
 src/core/load-fragment.c | 14 +++++++++++---
803fb7
 1 file changed, 11 insertions(+), 3 deletions(-)
803fb7
803fb7
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
803fb7
index c450fe2c7..6fc4d745d 100644
803fb7
--- a/src/core/load-fragment.c
803fb7
+++ b/src/core/load-fragment.c
803fb7
@@ -3384,6 +3384,7 @@ int config_parse_runtime_directory(
803fb7
                 void *userdata) {
803fb7
 
803fb7
         char***rt = data;
803fb7
+        Unit *u = userdata;
803fb7
         const char *word, *state;
803fb7
         size_t l;
803fb7
         int r;
803fb7
@@ -3401,12 +3402,19 @@ int config_parse_runtime_directory(
803fb7
         }
803fb7
 
803fb7
         FOREACH_WORD_QUOTED(word, l, rvalue, state) {
803fb7
-                _cleanup_free_ char *n;
803fb7
+                _cleanup_free_ char *t = NULL, *n = NULL;
803fb7
 
803fb7
-                n = strndup(word, l);
803fb7
-                if (!n)
803fb7
+                t = strndup(word, l);
803fb7
+                if (!t)
803fb7
                         return log_oom();
803fb7
 
803fb7
+                r = unit_name_printf(u, t, &n);
803fb7
+                if (r < 0) {
803fb7
+                        log_syntax(unit, LOG_ERR, filename, line, -r,
803fb7
+                                   "Failed to resolve specifiers, ignoring: %s", strerror(-r));
803fb7
+                        continue;
803fb7
+                }
803fb7
+
803fb7
                 if (!filename_is_valid(n)) {
803fb7
                         log_syntax(unit, LOG_ERR, filename, line, EINVAL,
803fb7
                                    "Runtime directory is not valid, ignoring assignment: %s", rvalue);