diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-09-30 16:19:12 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-09-30 16:28:34 +0200 |
commit | dee29aeb5909f4f5604012ced250488286b8d468 (patch) | |
tree | ab29a4e4ed3e35cf798a80bbff3925e2cdbd9b4b | |
parent | ef9bddb79984aa1b9d605d44b8c0890e8289bef1 (diff) | |
download | systemd-dee29aeb5909f4f5604012ced250488286b8d468.tar.gz |
generator: use kmsg in system-level generators, journal otherwise
Fixes: #17129.
-rw-r--r-- | src/shared/generator.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shared/generator.c b/src/shared/generator.c index 04d2f86a4a..d61b367d33 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -4,6 +4,7 @@ #include <unistd.h> #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(); } |