chiark / gitweb /
service: don't hit an assert if a service unit changes type and we get a spurious...
[elogind.git] / src / core / load-fragment.c
index 9438aa312bd1931535bd61cc95b460db36ca9c96..1f3da70aca34337bdd20383b0bcbf77f7be2c1ce 100644 (file)
@@ -1469,6 +1469,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 +1484,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 +1515,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 +1530,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();
 
@@ -2031,7 +2041,7 @@ int config_parse_syscall_filter(
 
         ExecContext *c = data;
         Unit *u = userdata;
-        bool invert;
+        bool invert = false;
         char *w;
         size_t l;
         char *state;