]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/bus-unit-util: add helper for unit deps
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 27 Jun 2025 14:41:29 +0000 (16:41 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Jul 2025 17:53:40 +0000 (19:53 +0200)
src/shared/bus-unit-util.c

index 189500c09f3dd2446ec3d9bd3f3a11cf6ab190b0..a40c0e9e73f85d3c499eeb054e03427941a89caa 100644 (file)
@@ -2271,6 +2271,13 @@ static int bus_try_append_condition(sd_bus_message *m, const char *field, const
         return 0;
 }
 
+static int bus_try_append_unit_dependency(sd_bus_message *m, const char *field, const char *eq) {
+        if (unit_dependency_from_string(field) < 0)
+                return 0;
+
+        return bus_append_strv(m, field, eq);
+}
+
 static int bus_append_cgroup_property(sd_bus_message *m, const char *field, const char *eq) {
         if (STR_IN_SET(field, "DevicePolicy",
                               "Slice",
@@ -2923,6 +2930,8 @@ static int bus_append_timer_property(sd_bus_message *m, const char *field, const
 }
 
 static int bus_append_unit_property(sd_bus_message *m, const char *field, const char *eq) {
+        int r;
+
         if (STR_IN_SET(field, "Description",
                               "SourcePath",
                               "OnFailureJobMode",
@@ -2956,13 +2965,16 @@ static int bus_append_unit_property(sd_bus_message *m, const char *field, const
                               "FailureActionExitStatus"))
                 return bus_append_action_exit_status(m, field, eq);
 
-        if (unit_dependency_from_string(field) >= 0 ||
-            STR_IN_SET(field, "Documentation",
+        if (STR_IN_SET(field, "Documentation",
                               "RequiresMountsFor",
                               "WantsMountsFor",
                               "Markers"))
                 return bus_append_strv(m, field, eq);
 
+        r = bus_try_append_unit_dependency(m, field, eq);
+        if (r != 0)
+                return r;
+
         return bus_try_append_condition(m, field, eq);
 }