mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
journald: restore syslog priority *with* facility bits for stream connections when restarting journald
Fixes: #19019
This commit is contained in:
parent
d267ac6e64
commit
d977ef2542
@ -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);
|
||||
@ -742,7 +760,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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user