From: Lennart Poettering Date: Wed, 30 Sep 2020 14:19:12 +0000 (+0200) Subject: generator: use kmsg in system-level generators, journal otherwise X-Git-Tag: v247-rc1~137^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F17214%2Fhead;p=thirdparty%2Fsystemd.git generator: use kmsg in system-level generators, journal otherwise Fixes: #17129. --- diff --git a/src/shared/generator.c b/src/shared/generator.c index 04d2f86a4a3..d61b367d337 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -4,6 +4,7 @@ #include #include "alloc-util.h" +#include "cgroup-util.h" #include "dropin.h" #include "escape.h" #include "fd-util.h" @@ -620,6 +621,11 @@ int generator_write_cryptsetup_service_section( } void log_setup_generator(void) { - log_set_prohibit_ipc(true); - log_setup_service(); + /* 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 */) + log_set_prohibit_ipc(true); + + log_set_target(LOG_TARGET_JOURNAL_OR_KMSG); /* This effectively means: journal for per-user generators, kmsg otherwise */ + log_parse_environment(); + (void) log_open(); }