load-fragment: resolve specifiers in RuntimeDirectory
authorMichael Gebetsroither <michael@mgeb.org>
Thu, 17 Sep 2015 20:54:13 +0000 (22:54 +0200)
committerMichael Gebetsroither <michael@mgeb.org>
Fri, 18 Sep 2015 09:39:03 +0000 (11:39 +0200)
src/core/load-fragment.c

index 1217b46..fcf863c 100644 (file)
@@ -3049,6 +3049,7 @@ int config_parse_runtime_directory(
                 void *userdata) {
 
         char***rt = data;
+        Unit *u = userdata;
         const char *word, *state;
         size_t l;
         int r;
@@ -3065,12 +3066,19 @@ int config_parse_runtime_directory(
         }
 
         FOREACH_WORD_QUOTED(word, l, rvalue, state) {
-                _cleanup_free_ char *n;
+                _cleanup_free_ char *t = NULL, *n = NULL;
 
-                n = strndup(word, l);
-                if (!n)
+                t = strndup(word, l);
+                if (!t)
                         return log_oom();
 
+                r = unit_name_printf(u, t, &n);
+                if (r < 0) {
+                        log_syntax(unit, LOG_ERR, filename, line, -r,
+                                   "Failed to resolve specifiers, ignoring: %s", strerror(-r));
+                        continue;
+                }
+
                 if (!filename_is_valid(n)) {
                         log_syntax(unit, LOG_ERR, filename, line, EINVAL,
                                    "Runtime directory is not valid, ignoring assignment: %s", rvalue);