summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/journal/journald-stream.c2
-rw-r--r--src/journal/journald-syslog.c12
-rw-r--r--src/journal/journald-syslog.h2
3 files changed, 10 insertions, 6 deletions
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index e98fe94b46..9c4efec9bc 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -90,7 +90,7 @@ static int stdout_stream_log(StdoutStream *s, const char *p) {
priority = s->priority;
if (s->level_prefix)
- syslog_parse_priority((char**) &p, &priority);
+ syslog_parse_priority((char**) &p, &priority, false);
if (s->forward_to_syslog || s->server->forward_to_syslog)
server_forward_syslog(s->server, syslog_fixup_facility(priority), s->identifier, p, &s->ucred, NULL);
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);
diff --git a/src/journal/journald-syslog.h b/src/journal/journald-syslog.h
index 324b70eef0..8ccdb77a09 100644
--- a/src/journal/journald-syslog.h
+++ b/src/journal/journald-syslog.h
@@ -25,7 +25,7 @@
int syslog_fixup_facility(int priority) _const_;
-void syslog_parse_priority(char **p, int *priority);
+void syslog_parse_priority(char **p, int *priority, bool with_facility);
size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid);
void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred, struct timeval *tv);