chiark / gitweb /
unit-printf: add specifiers for the host name, machine id, boot id
[elogind.git] / src / core / load-fragment.c
index c6422619f5d008db5dcd104c1347a88340d635f1..0d5d841429aeaaae1a4212f05a06a44ff365d8ea 100644 (file)
@@ -42,6 +42,7 @@
 #include "securebits.h"
 #include "missing.h"
 #include "unit-name.h"
+#include "unit-printf.h"
 #include "bus-errors.h"
 #include "utf8.h"
 #include "path-util.h"
@@ -1469,6 +1470,7 @@ int config_parse_unit_condition_path(
         Unit *u = data;
         bool trigger, negate;
         Condition *c;
+        _cleanup_free_ char *p = NULL;
 
         assert(filename);
         assert(lvalue);
@@ -1483,12 +1485,16 @@ int config_parse_unit_condition_path(
         if (negate)
                 rvalue++;
 
-        if (!path_is_absolute(rvalue)) {
-                log_error("[%s:%u] Path in condition not absolute, ignoring: %s", filename, line, rvalue);
+        p = unit_full_printf(u, rvalue);
+        if (!p)
+                return -ENOMEM;
+
+        if (!path_is_absolute(p)) {
+                log_error("[%s:%u] Path in condition not absolute, ignoring: %s", filename, line, p);
                 return 0;
         }
 
-        c = condition_new(cond, rvalue, trigger, negate);
+        c = condition_new(cond, p, trigger, negate);
         if (!c)
                 return -ENOMEM;
 
@@ -1510,6 +1516,7 @@ int config_parse_unit_condition_string(
         Unit *u = data;
         bool trigger, negate;
         Condition *c;
+        _cleanup_free_ char *s = NULL;
 
         assert(filename);
         assert(lvalue);
@@ -1524,7 +1531,11 @@ int config_parse_unit_condition_string(
         if (negate)
                 rvalue++;
 
-        c = condition_new(cond, rvalue, trigger, negate);
+        s = unit_full_printf(u, rvalue);
+        if (!s)
+                return -ENOMEM;
+
+        c = condition_new(cond, s, trigger, negate);
         if (!c)
                 return log_oom();