From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jun 2025 12:18:31 +0000 (+0200) Subject: shared/bus-unit-util: define helper for TemporaryFileSystem= X-Git-Tag: v258-rc1~183^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f90f4b86fcf976d442516681e2dc81b681113fe;p=thirdparty%2Fsystemd.git shared/bus-unit-util: define helper for TemporaryFileSystem= --- diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 4e85d7edba3..71b141fe991 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -1542,6 +1542,64 @@ static int bus_append_bind_paths(sd_bus_message *m, const char *field, const cha return 1; } +static int bus_append_temporary_file_system(sd_bus_message *m, const char *field, const char *eq) { + const char *p = eq; + int r; + + r = sd_bus_message_open_container(m, SD_BUS_TYPE_STRUCT, "sv"); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, field); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_open_container(m, 'v', "a(ss)"); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_open_container(m, 'a', "(ss)"); + if (r < 0) + return bus_log_create_error(r); + + for (;;) { + _cleanup_free_ char *word = NULL, *path = NULL; + const char *w; + + r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); + if (r < 0) + return log_error_errno(r, "Failed to parse argument: %m"); + if (r == 0) + break; + + w = word; + r = extract_first_word(&w, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS); + if (r < 0) + return log_error_errno(r, "Failed to parse argument: %m"); + if (r == 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse argument: %s", p); + + r = sd_bus_message_append(m, "(ss)", path, w); + if (r < 0) + return bus_log_create_error(r); + } + + r = sd_bus_message_close_container(m); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_close_container(m); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_close_container(m); + if (r < 0) + return bus_log_create_error(r); + + return 1; +} + static int bus_append_cgroup_property(sd_bus_message *m, const char *field, const char *eq) { if (STR_IN_SET(field, "DevicePolicy", "Slice", @@ -1885,63 +1943,8 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con "BindReadOnlyPaths")) return bus_append_bind_paths(m, field, eq); - if (streq(field, "TemporaryFileSystem")) { - const char *p = eq; - - r = sd_bus_message_open_container(m, SD_BUS_TYPE_STRUCT, "sv"); - if (r < 0) - return bus_log_create_error(r); - - r = sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, field); - if (r < 0) - return bus_log_create_error(r); - - r = sd_bus_message_open_container(m, 'v', "a(ss)"); - if (r < 0) - return bus_log_create_error(r); - - r = sd_bus_message_open_container(m, 'a', "(ss)"); - if (r < 0) - return bus_log_create_error(r); - - for (;;) { - _cleanup_free_ char *word = NULL, *path = NULL; - const char *w; - - r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); - if (r < 0) - return log_error_errno(r, "Failed to parse argument: %m"); - if (r == 0) - break; - - w = word; - r = extract_first_word(&w, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS); - if (r < 0) - return log_error_errno(r, "Failed to parse argument: %m"); - if (r == 0) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Failed to parse argument: %s", - p); - - r = sd_bus_message_append(m, "(ss)", path, w); - if (r < 0) - return bus_log_create_error(r); - } - - r = sd_bus_message_close_container(m); - if (r < 0) - return bus_log_create_error(r); - - r = sd_bus_message_close_container(m); - if (r < 0) - return bus_log_create_error(r); - - r = sd_bus_message_close_container(m); - if (r < 0) - return bus_log_create_error(r); - - return 1; - } + if (streq(field, "TemporaryFileSystem")) + return bus_append_temporary_file_system(m, field, eq); if (streq(field, "RootHash")) { _cleanup_free_ void *roothash_decoded = NULL;