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

index 2a49d5717df6b67764e511eda9f42f7f9717d45f..59b5fe93530b4469e18c51d2ecad6002d9a27de2 100644 (file)
@@ -1254,6 +1254,18 @@ static int bus_append_standard_input_text(sd_bus_message *m, const char *field,
         return bus_append_byte_array(m, field, unescaped, l + 1);
 }
 
+static int bus_append_standard_input_data(sd_bus_message *m, const char *field, const char *eq) {
+        _cleanup_free_ void *decoded = NULL;
+        size_t sz;
+        int r;
+
+        r = unbase64mem(eq, &decoded, &sz);
+        if (r < 0)
+                return log_error_errno(r, "Failed to decode base64 data '%s': %m", eq);
+
+        return bus_append_byte_array(m, field, decoded, sz);
+}
+
 static int bus_append_cgroup_property(sd_bus_message *m, const char *field, const char *eq) {
         if (STR_IN_SET(field, "DevicePolicy",
                               "Slice",
@@ -1547,16 +1559,8 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
         if (streq(field, "StandardInputText"))
                 return bus_append_standard_input_text(m, field, eq);
 
-        if (streq(field, "StandardInputData")) {
-                _cleanup_free_ void *decoded = NULL;
-                size_t sz;
-
-                r = unbase64mem(eq, &decoded, &sz);
-                if (r < 0)
-                        return log_error_errno(r, "Failed to decode base64 data '%s': %m", eq);
-
-                return bus_append_byte_array(m, field, decoded, sz);
-        }
+        if (streq(field, "StandardInputData"))
+                return bus_append_standard_input_data(m, field, eq);
 
         if ((suffix = startswith(field, "Limit"))) {
                 int rl;