From 5e24ebace23ecd7d394e76180a28a76cf2ebe20c Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Tue, 22 Apr 2025 21:01:41 +0200 Subject: [PATCH 1/3] core/slice: remove redundant assertion --- src/core/slice.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/slice.c b/src/core/slice.c index 0bb73727bc..a4a82118dd 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -24,7 +24,6 @@ static const UnitActiveState state_translation_table[_SLICE_STATE_MAX] = { static void slice_init(Unit *u) { Slice *s = ASSERT_PTR(SLICE(u)); - assert(u); assert(u->load_state == UNIT_STUB); u->ignore_on_isolate = true; From f76b0293125bb89b05a01da921966840ae4a9f29 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 12 May 2025 17:07:47 +0200 Subject: [PATCH 2/3] core/dbus-execute: always normalize argv[0] to "sh" on EXEC_COMMAND_VIA_SHELL Addresses https://github.com/systemd/systemd/pull/37071#discussion_r2084851759 --- src/core/dbus-execute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index f7b2932e07..d0281cc236 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -1551,7 +1551,7 @@ int bus_set_transient_exec_command( path = _PATH_BSHELL; if (strv_isempty(argv)) - r = strv_extend(&argv, path); + r = strv_extend(&argv, "sh"); else r = free_and_strdup(&argv[0], argv[0][0] == '-' ? "-sh" : "sh"); if (r < 0) From 3ca4a717a6ecd45bbd8bb0933a9a8fcdef7d642e Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Thu, 17 Apr 2025 17:33:50 +0200 Subject: [PATCH 3/3] core/dbus-unit: remove unneeded else if --- src/core/dbus-unit.c | 53 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 9080ad93de..4f45b7c34e 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -2351,8 +2351,9 @@ static int bus_unit_set_transient_property( } return 1; + } - } else if (streq(name, "Slice")) { + if (streq(name, "Slice")) { Unit *slice; const char *s; @@ -2389,8 +2390,9 @@ static int bus_unit_set_transient_property( } return 1; + } - } else if (STR_IN_SET(name, "RequiresMountsFor", "WantsMountsFor")) { + if (STR_IN_SET(name, "RequiresMountsFor", "WantsMountsFor")) { _cleanup_strv_free_ char **l = NULL; r = sd_bus_message_read_strv(message, &l); @@ -2421,13 +2423,35 @@ static int bus_unit_set_transient_property( return 1; } + if (streq(name, "AddRef")) { + int b; + + /* Why is this called "AddRef" rather than just "Ref", or "Reference"? There's already a "Ref()" method + * on the Unit interface, and it's probably not a good idea to expose a property and a method on the + * same interface (well, strictly speaking AddRef isn't exposed as full property, we just read it for + * transient units, but still). And "References" and "ReferencedBy" is already used as unit reference + * dependency type, hence let's not confuse things with that. + * + * Note that we don't actually add the reference to the bus track. We do that only after the setup of + * the transient unit is complete, so that setting this property multiple times in the same transient + * unit creation call doesn't count as individual references. */ + + r = sd_bus_message_read(message, "b", &b); + if (r < 0) + return r; + + if (!UNIT_WRITE_FLAGS_NOOP(flags)) + u->bus_track_add = b; + + return 1; + } + if (streq(name, "RequiresOverridable")) d = UNIT_REQUIRES; /* redirect for obsolete unit dependency type */ else if (streq(name, "RequisiteOverridable")) d = UNIT_REQUISITE; /* same here */ else d = unit_dependency_from_string(name); - if (d >= 0) { const char *other; @@ -2481,29 +2505,6 @@ static int bus_unit_set_transient_property( return r; return 1; - - } else if (streq(name, "AddRef")) { - - int b; - - /* Why is this called "AddRef" rather than just "Ref", or "Reference"? There's already a "Ref()" method - * on the Unit interface, and it's probably not a good idea to expose a property and a method on the - * same interface (well, strictly speaking AddRef isn't exposed as full property, we just read it for - * transient units, but still). And "References" and "ReferencedBy" is already used as unit reference - * dependency type, hence let's not confuse things with that. - * - * Note that we don't actually add the reference to the bus track. We do that only after the setup of - * the transient unit is complete, so that setting this property multiple times in the same transient - * unit creation call doesn't count as individual references. */ - - r = sd_bus_message_read(message, "b", &b); - if (r < 0) - return r; - - if (!UNIT_WRITE_FLAGS_NOOP(flags)) - u->bus_track_add = b; - - return 1; } return 0;