1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-12 09:17:44 +03:00

log: make sure generators never log into the journal to avoid activation deadlocks

This makes all generators log to kmsg by default.
This commit is contained in:
Lennart Poettering 2012-05-22 22:00:37 +02:00
parent 399c5f9633
commit a690306153
8 changed files with 11 additions and 7 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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"
};

View File

@ -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

View File

@ -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();