teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

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

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