]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: when journald namespace instances log, they can do so safely to the main...
authorLennart Poettering <lennart@poettering.net>
Tue, 8 Jun 2021 17:43:47 +0000 (19:43 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 9 Jun 2021 03:30:22 +0000 (12:30 +0900)
Fixes: #18951
src/journal/journald.c
units/systemd-journald@.service.in

index cfbaf366a9c7d36469e266d24fb2934e7630299b..536717ce0a2f3117079ac7402bf569bd63cf5c0e 100644 (file)
@@ -26,16 +26,23 @@ int main(int argc, char *argv[]) {
 
         namespace = argc > 1 ? empty_to_null(argv[1]) : NULL;
 
-        /* So here's the deal: journald can't be considered as regular daemon when it comes to
-         * logging hence LOG_TARGET_AUTO won't do the right thing for it. Hence explicitly log to
-         * the console if we're started from a console or to kmsg otherwise. */
-        log_target = isatty(STDERR_FILENO) > 0 ? LOG_TARGET_CONSOLE : LOG_TARGET_KMSG;
-
-        log_set_prohibit_ipc(true); /* better safe than sorry */
-        log_set_target(log_target);
         log_set_facility(LOG_SYSLOG);
-        log_parse_environment();
-        log_open();
+
+        if (namespace)
+                /* If we run for a log namespace, then we ourselves can log to the main journald. */
+                log_setup();
+        else {
+                /* So here's the deal if we run as the main journald: we can't be considered as regular
+                 * daemon when it comes to logging hence LOG_TARGET_AUTO won't do the right thing for
+                 * us. Hence explicitly log to the console if we're started from a console or to kmsg
+                 * otherwise. */
+                log_target = isatty(STDERR_FILENO) > 0 ? LOG_TARGET_CONSOLE : LOG_TARGET_KMSG;
+
+                log_set_prohibit_ipc(true); /* better safe than sorry */
+                log_set_target(log_target);
+                log_parse_environment();
+                log_open();
+        }
 
         umask(0022);
 
index 2863691c2d9173857232935fdcafb7d88f754ab5..35c998285f2fd013ff1dd52c2f19c9dd89ff903a 100644 (file)
@@ -32,7 +32,6 @@ RestrictSUIDSGID=yes
 RuntimeDirectory=systemd/journal.%i
 RuntimeDirectoryPreserve=yes
 Sockets=systemd-journald@%i.socket
-StandardOutput=null
 SystemCallArchitectures=native
 SystemCallErrorNumber=EPERM
 SystemCallFilter=@system-service