]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
generator: check $SYSTEMD_SCOPE rather than cgroup membership 37761/head
authorLennart Poettering <lennart@poettering.net>
Fri, 6 Jun 2025 06:59:31 +0000 (08:59 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 6 Jun 2025 07:04:45 +0000 (09:04 +0200)
This is more explicit and ensures that even in testing environments we
operate the same way.

As side effect it also avoids the mess around SELinux blocking access to
cgroupfs.

Fixes: #35723
src/shared/generator.c

index 3a9d10ad69dec332ab96b42998d29aab89762665..ea665a6c33719bd80a3e0fda4e669f4b6eba97eb 100644 (file)
@@ -1054,10 +1054,10 @@ int generator_write_veritysetup_service_section(
 void log_setup_generator(void) {
         if (invoked_by_systemd()) {
                 /* Disable talking to syslog/journal (i.e. the two IPC-based loggers) if we run in system context. */
-                if (cg_pid_get_owner_uid(0, NULL) == -ENXIO /* not running in a per-user slice */)
+                if (streq_ptr(getenv("SYSTEMD_SCOPE"), "system"))
                         log_set_prohibit_ipc(true);
 
-                /* This effectively means: journal for per-user generators, kmsg otherwise */
+                /* This effectively means: journal for per-user service manager generators, kmsg for per-system service manager generators */
                 log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
         } else
                 log_set_target(LOG_TARGET_AUTO);