From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jun 2025 12:06:23 +0000 (+0200) Subject: shared/bus-unit-util: define helper for StandardInputText= X-Git-Tag: v258-rc1~183^2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bb442010046db0e4f18ee934d58496fdb0c51b0;p=thirdparty%2Fsystemd.git shared/bus-unit-util: define helper for StandardInputText= --- diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index fbf6e31a4ee..2a49d5717df 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -1237,6 +1237,23 @@ static int bus_append_standard_inputs(sd_bus_message *m, const char *field, cons return 1; } +static int bus_append_standard_input_text(sd_bus_message *m, const char *field, const char *eq) { + _cleanup_free_ char *unescaped = NULL; + ssize_t l; + + l = cunescape(eq, 0, &unescaped); + if (l < 0) + return log_error_errno(l, "Failed to unescape text '%s': %m", eq); + + if (!strextend(&unescaped, "\n")) + return log_oom(); + + /* Note that we don't expand specifiers here, but that should be OK, as this is a + * programmatic interface anyway */ + + return bus_append_byte_array(m, field, unescaped, l + 1); +} + static int bus_append_cgroup_property(sd_bus_message *m, const char *field, const char *eq) { if (STR_IN_SET(field, "DevicePolicy", "Slice", @@ -1527,22 +1544,8 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con "StandardError")) return bus_append_standard_inputs(m, field, eq); - if (streq(field, "StandardInputText")) { - _cleanup_free_ char *unescaped = NULL; - ssize_t l; - - l = cunescape(eq, 0, &unescaped); - if (l < 0) - return log_error_errno(l, "Failed to unescape text '%s': %m", eq); - - if (!strextend(&unescaped, "\n")) - return log_oom(); - - /* Note that we don't expand specifiers here, but that should be OK, as this is a - * programmatic interface anyway */ - - return bus_append_byte_array(m, field, unescaped, l + 1); - } + if (streq(field, "StandardInputText")) + return bus_append_standard_input_text(m, field, eq); if (streq(field, "StandardInputData")) { _cleanup_free_ void *decoded = NULL;