valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0458-load-fragment-resolve-specifiers-in-RuntimeDirectory.patch

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