]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/bus-unit-util: define helper for Delegate=
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 27 Jun 2025 11:44:09 +0000 (13:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Jul 2025 08:37:33 +0000 (10:37 +0200)
src/shared/bus-unit-util.c

index a9c9a0138c9b6edc13b99a9cc2051fff0b830666..de6413135c176d7f0bef2e43febeaf86af873f88 100644 (file)
@@ -300,6 +300,20 @@ static int bus_append_parse_cpu_set(sd_bus_message *m, const char *field, const
         return bus_append_byte_array(m, field, array, allocated);
 }
 
+static int bus_append_parse_delegate(sd_bus_message *m, const char *field, const char *eq) {
+        int r;
+
+        r = parse_boolean(eq);
+        if (r < 0)
+                return bus_append_strv(m, "DelegateControllers", eq, /* separator= */ NULL, EXTRACT_UNQUOTE);
+
+        r = sd_bus_message_append(m, "(sv)", "Delegate", "b", r);
+        if (r < 0)
+                return bus_log_create_error(r);
+
+        return 1;
+}
+
 static int bus_append_exec_command(sd_bus_message *m, const char *field, const char *eq) {
         bool explicit_path = false, done = false, ambient_hack = false;
         _cleanup_strv_free_ char **l = NULL, **ex_opts = NULL;
@@ -640,19 +654,10 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
                 return bus_append_parse_cpu_set(m, field, eq);
 
         if (streq(field, "DisableControllers"))
-                return bus_append_strv(m, "DisableControllers", eq, /* separator= */ NULL, EXTRACT_UNQUOTE);
-
-        if (streq(field, "Delegate")) {
-                r = parse_boolean(eq);
-                if (r < 0)
-                        return bus_append_strv(m, "DelegateControllers", eq, /* separator= */ NULL, EXTRACT_UNQUOTE);
-
-                r = sd_bus_message_append(m, "(sv)", "Delegate", "b", r);
-                if (r < 0)
-                        return bus_log_create_error(r);
+                return bus_append_strv(m, field, eq, /* separator= */ NULL, EXTRACT_UNQUOTE);
 
-                return 1;
-        }
+        if (streq(field, "Delegate"))
+                return bus_append_parse_delegate(m, field, eq);
 
         if (STR_IN_SET(field, "MemoryMin",
                               "DefaultMemoryLow",