diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-03-16 16:09:47 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-03-23 10:08:13 +0100 |
commit | 0a87441aefacfe94a81ad89611349b531d684d08 (patch) | |
tree | aaf828eb74b3eaa5bb21694239fd9f8c83aac231 | |
parent | 0af10ee89913b282fab256948968b90cd1d61e83 (diff) | |
download | systemd-0a87441aefacfe94a81ad89611349b531d684d08.tar.gz |
journald: restore syslog priority *with* facility bits for stream connections when restarting journald
Fixes: #19019
(cherry picked from commit d977ef2542accd3e10a7540b3a8b6d1278cc0041)
(cherry picked from commit b55a7dd551d332440615d5efb07d6620ba4ffb1d)
-rw-r--r-- | src/journal/journald-stream.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index 241e2572e6..4f2356e320 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -334,6 +334,22 @@ static int stdout_stream_log( return 0; } +static int syslog_parse_priority_and_facility(const char *s) { + int prio, r; + + /* Parses both facility and priority in one value, i.e. is different from log_level_from_string() + * which only parses the priority and refuses any facility value */ + + r = safe_atoi(s, &prio); + if (r < 0) + return r; + + if (prio < 0 || prio > 999) + return -ERANGE; + + return prio; +} + static int stdout_stream_line(StdoutStream *s, char *p, LineBreak line_break) { char *orig; int r; @@ -373,15 +389,17 @@ static int stdout_stream_line(StdoutStream *s, char *p, LineBreak line_break) { s->state = STDOUT_STREAM_PRIORITY; return 0; - case STDOUT_STREAM_PRIORITY: - r = safe_atoi(p, &s->priority); - if (r < 0 || s->priority < 0 || s->priority > 999) { - log_warning("Failed to parse log priority line."); - return -EINVAL; - } + case STDOUT_STREAM_PRIORITY: { + int priority; + + priority = syslog_parse_priority_and_facility(p); + if (priority < 0) + return log_warning_errno(priority, "Failed to parse log priority line: %m"); + s->priority = priority; s->state = STDOUT_STREAM_LEVEL_PREFIX; return 0; + } case STDOUT_STREAM_LEVEL_PREFIX: r = parse_boolean(p); @@ -750,7 +768,7 @@ static int stdout_stream_load(StdoutStream *stream, const char *fname) { if (priority) { int p; - p = log_level_from_string(priority); + p = syslog_parse_priority_and_facility(priority); if (p >= 0) stream->priority = p; } |