From: Lennart Poettering Date: Tue, 22 May 2012 20:00:37 +0000 (+0200) Subject: log: make sure generators never log into the journal to avoid activation deadlocks X-Git-Tag: v183~32 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6903061530cac5fbaa99a080a93221c02c349f9;p=systemd log: make sure generators never log into the journal to avoid activation deadlocks This makes all generators log to kmsg by default. --- diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index c0b1cf09..7eb122d2 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -249,7 +249,7 @@ int main(int argc, char *argv[]) { if (argc > 1) arg_dest = argv[1]; - log_set_target(LOG_TARGET_AUTO); + log_set_target(LOG_TARGET_SAFE); log_parse_environment(); log_open(); diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 39af18a9..86cbc45b 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -503,7 +503,7 @@ int main(int argc, char *argv[]) { if (argc > 1) arg_dest = argv[1]; - log_set_target(LOG_TARGET_AUTO); + log_set_target(LOG_TARGET_SAFE); log_parse_environment(); log_open(); diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c index 13dca7d1..b2e4f52c 100644 --- a/src/getty-generator/getty-generator.c +++ b/src/getty-generator/getty-generator.c @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - log_set_target(LOG_TARGET_AUTO); + log_set_target(LOG_TARGET_SAFE); log_parse_environment(); log_open(); diff --git a/src/journal/journald.c b/src/journal/journald.c index 232457aa..c429896a 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -2774,7 +2774,7 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - log_set_target(LOG_TARGET_KMSG); + log_set_target(LOG_TARGET_SAFE); log_set_facility(LOG_SYSLOG); log_parse_environment(); log_open(); diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index a5987f97..1464c8e4 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - log_set_target(LOG_TARGET_AUTO); + log_set_target(LOG_TARGET_SAFE); log_parse_environment(); log_open(); diff --git a/src/shared/log.c b/src/shared/log.c index da530988..6a10dc45 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -240,7 +240,7 @@ int log_open(void) { return 0; } - if (log_target != LOG_TARGET_AUTO || + if ((log_target != LOG_TARGET_AUTO && log_target != LOG_TARGET_SAFE) || getpid() == 1 || isatty(STDERR_FILENO) <= 0) { @@ -266,6 +266,7 @@ int log_open(void) { } if (log_target == LOG_TARGET_AUTO || + log_target == LOG_TARGET_SAFE || log_target == LOG_TARGET_JOURNAL_OR_KMSG || log_target == LOG_TARGET_SYSLOG_OR_KMSG || log_target == LOG_TARGET_KMSG) { @@ -547,6 +548,7 @@ static int log_dispatch( if (k <= 0 && (log_target == LOG_TARGET_AUTO || + log_target == LOG_TARGET_SAFE || log_target == LOG_TARGET_SYSLOG_OR_KMSG || log_target == LOG_TARGET_JOURNAL_OR_KMSG || log_target == LOG_TARGET_KMSG)) { @@ -744,6 +746,7 @@ static const char *const log_target_table[] = { [LOG_TARGET_SYSLOG] = "syslog", [LOG_TARGET_SYSLOG_OR_KMSG] = "syslog-or-kmsg", [LOG_TARGET_AUTO] = "auto", + [LOG_TARGET_SAFE] = "safe", [LOG_TARGET_NULL] = "null" }; diff --git a/src/shared/log.h b/src/shared/log.h index b2f5f2a9..59d4c00f 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -36,6 +36,7 @@ typedef enum LogTarget{ LOG_TARGET_SYSLOG, LOG_TARGET_SYSLOG_OR_KMSG, LOG_TARGET_AUTO, /* console if stderr is tty, JOURNAL_OR_KMSG otherwise */ + LOG_TARGET_SAFE, /* console if stderr is tty, KMSG otherwise */ LOG_TARGET_NULL, _LOG_TARGET_MAX, _LOG_TARGET_INVALID = -1 diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c index 30fdbc3e..f4e8dafe 100644 --- a/src/system-update-generator/system-update-generator.c +++ b/src/system-update-generator/system-update-generator.c @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) { if (argc > 1) arg_dest = argv[1]; - log_set_target(LOG_TARGET_AUTO); + log_set_target(LOG_TARGET_SAFE); log_parse_environment(); log_open();