From 5c314412f0a54b50f55d739ef009f35ceef426a0 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 29 Nov 2023 15:57:46 +0100 Subject: [PATCH] core: Always call log_open() in systemd-executor log_setup() will open the console in systemd-executor because it's not pid 1 and it's not connected to the journal. So if the log target is later changed to kmsg, we have to reopen the log. But since log_open() won't open the same log twice, let's just call it unconditionally since it will be a noop if we try to reopen the same log. This makes sure that systemd-executor will log to the log target passed via --log-target= after parsing arguments. --- src/core/executor.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/executor.c b/src/core/executor.c index e07a689..2026055 100644 --- a/src/core/executor.c +++ b/src/core/executor.c @@ -207,11 +207,9 @@ int main(int argc, char *argv[]) { if (r <= 0) return r; - /* Now try again if we were told it's fine to use a different target */ - if (log_get_target() != LOG_TARGET_KMSG) { - log_set_prohibit_ipc(false); - log_open(); - } + /* Now that we know the intended log target, allow IPC and open the final log target. */ + log_set_prohibit_ipc(false); + log_open(); /* Initialize lazily. SMACK is just a few operations, but the SELinux is very slow as it requires * loading the entire database in memory, so we will do it lazily only if it is actually needed, to -- 2.7.4