From 4f25248b6e69855b4da6d01690821b9359928edc Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sat, 13 Dec 2025 17:56:51 +0100 Subject: [PATCH] core/service: set unit log context in helper processes that bypass cgroup Since these helper processes aren't spawned in the unit cgroup, let's explicitly attach unit log context so that all logging gets attributed to the unit, including the ones done in library calls. --- src/core/service.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index 31f481a7f08..7098e2744a9 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2888,8 +2888,9 @@ static void service_enter_refresh_extensions(Service *s) { goto fail; } if (r == 0) { - PidRef *unit_pid = &s->main_pid; - assert(pidref_is_set(unit_pid)); + LOG_CONTEXT_PUSH_UNIT(UNIT(s)); + + assert(pidref_is_set(&s->main_pid)); _cleanup_free_ char *propagate_dir = path_join("/run/systemd/propagate/", UNIT(s)->id); if (!propagate_dir) { @@ -2912,7 +2913,7 @@ static void service_enter_refresh_extensions(Service *s) { /* Only reload confext, and not sysext as they also typically contain the executable(s) used * by the service and a simply reload cannot meaningfully handle that. */ r = refresh_extensions_in_namespace( - unit_pid, + &s->main_pid, "SYSTEMD_CONFEXT_HIERARCHIES", &p); if (r < 0) @@ -5593,6 +5594,8 @@ static int service_live_mount( goto fail; } if (r == 0) { + LOG_CONTEXT_PUSH_UNIT(u); + if (flags & MOUNT_IN_NAMESPACE_IS_IMAGE) r = mount_image_in_namespace( &s->main_pid, -- 2.47.3