]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: add specifier expansion to RequiresMountsFor=
authorLennart Poettering <lennart@poettering.net>
Mon, 5 Dec 2016 18:40:13 +0000 (19:40 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Dec 2016 17:47:32 +0000 (18:47 +0100)
This might be useful for some people, for example to pull in mounts for paths
including the machine ID or hostname.

src/core/load-fragment.c

index 3ffb417f97b344293cc268fabbdff967dc7e2cac..85bac9ea5bcd37bedd768110bdbd6bbbc459fcfd 100644 (file)
@@ -2565,7 +2565,7 @@ int config_parse_unit_requires_mounts_for(
         assert(data);
 
         for (p = rvalue;; ) {
-                _cleanup_free_ char *word = NULL;
+                _cleanup_free_ char *word = NULL, *resolved = NULL;
 
                 r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
                 if (r == 0)
@@ -2583,9 +2583,15 @@ int config_parse_unit_requires_mounts_for(
                         continue;
                 }
 
-                r = unit_require_mounts_for(u, word);
+                r = unit_full_printf(u, word, &resolved);
+                if (r < 0) {
+                        log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit name \"%s\", ignoring: %m", word);
+                        continue;
+                }
+
+                r = unit_require_mounts_for(u, resolved);
                 if (r < 0) {
-                        log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add required mount \"%s\", ignoring: %m", word);
+                        log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add required mount \"%s\", ignoring: %m", resolved);
                         continue;
                 }
         }