chiark / gitweb /
log: never ever log to syslog from PID 1, log to the journal again
authorLennart Poettering <lennart@poettering.net>
Mon, 11 Aug 2014 18:08:08 +0000 (20:08 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 11 Aug 2014 18:08:08 +0000 (20:08 +0200)
We don't support journal-less systems anyway, so let's avoid the
confusion.

src/core/main.c
src/core/manager.c
src/shared/log.c
src/shared/log.h

index d2104cb551e13dbc8922e0aa7aa355d2a67f3874..f33b78d375befecb06d81c072948e8ff7d8abf89 100644 (file)
@@ -1018,7 +1018,7 @@ static int help(void) {
                "     --crash-shell[=0|1]         Run shell on crash\n"
                "     --confirm-spawn[=0|1]       Ask for confirmation when spawning processes\n"
                "     --show-status[=0|1]         Show status updates on the console during bootup\n"
-               "     --log-target=TARGET         Set log target (console, journal, syslog, kmsg, journal-or-kmsg, syslog-or-kmsg, null)\n"
+               "     --log-target=TARGET         Set log target (console, journal, kmsg, journal-or-kmsg, null)\n"
                "     --log-level=LEVEL           Set log level (debug, info, notice, warning, err, crit, alert, emerg)\n"
                "     --log-color[=0|1]           Highlight important log messages\n"
                "     --log-location[=0|1]        Include code location in log messages\n"
@@ -1328,6 +1328,7 @@ int main(int argc, char *argv[]) {
         saved_argc = argc;
 
         log_show_color(isatty(STDERR_FILENO) > 0);
+        log_set_upgrade_syslog_to_journal(true);
 
         /* Disable the umask logic */
         if (getpid() == 1)
index 32c056588abca0493a5f62b02da87ae7d40cc2ea..445461b6b9ac9341e27e50b5eee212e668b70f32 100644 (file)
@@ -341,7 +341,7 @@ static int manager_setup_signals(Manager *m) {
                         SIGRTMIN+26, /* systemd: set log target to journal-or-kmsg */
                         SIGRTMIN+27, /* systemd: set log target to console */
                         SIGRTMIN+28, /* systemd: set log target to kmsg */
-                        SIGRTMIN+29, /* systemd: set log target to syslog-or-kmsg */
+                        SIGRTMIN+29, /* systemd: set log target to syslog-or-kmsg (obsolete)*/
                         -1);
         assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
 
@@ -1731,6 +1731,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                                 break;
 
                         case 26:
+                        case 29: /* compatibility: used to be mapped to LOG_TARGET_SYSLOG_OR_KMSG */
                                 log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
                                 log_notice("Setting log target to journal-or-kmsg.");
                                 break;
@@ -1745,11 +1746,6 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                                 log_notice("Setting log target to kmsg.");
                                 break;
 
-                        case 29:
-                                log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
-                                log_notice("Setting log target to syslog-or-kmsg.");
-                                break;
-
                         default:
                                 log_warning("Got unhandled signal <%s>.", signal_to_string(sfsi.ssi_signo));
                         }
index 078ccdc35bf709b842c32bb0075fb6dc65cf5dcd..2bac998bcdbe3dac9886a2210b71de51f4ad39c0 100644 (file)
@@ -51,6 +51,8 @@ static bool syslog_is_stream = false;
 static bool show_color = false;
 static bool show_location = false;
 
+static bool upgrade_syslog_to_journal = false;
+
 /* Akin to glibc's __abort_msg; which is private and we hence cannot
  * use here. */
 static char *log_abort_msg = NULL;
@@ -267,6 +269,13 @@ void log_set_target(LogTarget target) {
         assert(target >= 0);
         assert(target < _LOG_TARGET_MAX);
 
+        if (upgrade_syslog_to_journal) {
+                if (target == LOG_TARGET_SYSLOG)
+                        target = LOG_TARGET_JOURNAL;
+                else if (target == LOG_TARGET_SYSLOG_OR_KMSG)
+                        target = LOG_TARGET_JOURNAL_OR_KMSG;
+        }
+
         log_target = target;
 }
 
@@ -984,3 +993,7 @@ void log_received_signal(int level, const struct signalfd_siginfo *si) {
                          signal_to_string(si->ssi_signo));
 
 }
+
+void log_set_upgrade_syslog_to_journal(bool b) {
+        upgrade_syslog_to_journal = b;
+}
index 794af7be6af64aa004424d01131e558d418546bc..9918381d39df19dd5cceb63d887579613fedbbb5 100644 (file)
@@ -172,3 +172,5 @@ LogTarget log_target_from_string(const char *s) _pure_;
 #define MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x)
 
 void log_received_signal(int level, const struct signalfd_siginfo *si);
+
+void log_set_upgrade_syslog_to_journal(bool b);