diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-07-26 12:57:33 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-08-19 11:14:14 -0400 |
commit | ac50788b0f5aeee09e7d45db28ae8ab7f39cd52e (patch) | |
tree | d215e1df7bf20f2e44c04256d1f44248d9885e20 /src/journal/journald-syslog.c | |
parent | 763a24a3b62f0eaac43fb58202ad3594f1af09ac (diff) |
journal: fix parsing of facility in syslog messages
In 49998b383 (journald: do not overwrite syslog facility when
parsing priority) journald started ignoring facility part when
reading service stderr to convert to syslog messages. In this
case it is fine, because only the priority is allowed.
But the same codepath is used for syslog messages, where the
facility should be used. Split the two codepaths by explicitly
specyfing whether the facility should be ignored or not.
https://bugzilla.redhat.com/show_bug.cgi?id=988814
Diffstat (limited to 'src/journal/journald-syslog.c')
-rw-r--r-- | src/journal/journald-syslog.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 7cbb34608b..c2770a53d0 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -236,7 +236,7 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid) return e; } -void syslog_parse_priority(char **p, int *priority) { +void syslog_parse_priority(char **p, int *priority, bool with_facility) { int a = 0, b = 0, c = 0; int k; @@ -265,10 +265,14 @@ void syslog_parse_priority(char **p, int *priority) { } else return; - if (a < 0 || b < 0 || c < 0) + if (a < 0 || b < 0 || c < 0 || + (!with_facility && (a || b || c > 7))) return; - *priority = (*priority & LOG_FACMASK) | (a*100 + b*10 + c); + if (with_facility) + *priority = a*100 + b*10 + c; + else + *priority = (*priority & LOG_FACMASK) | c; *p += k; } @@ -361,7 +365,7 @@ void server_process_syslog_message( assert(buf); orig = buf; - syslog_parse_priority((char**) &buf, &priority); + syslog_parse_priority((char**) &buf, &priority, true); if (s->forward_to_syslog) forward_syslog_raw(s, priority, orig, ucred, tv); |