summaryrefslogtreecommitdiff
path: root/src/kmsg-syslogd.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-04-03 22:14:34 +0200
committerLennart Poettering <lennart@poettering.net>2011-04-03 22:15:14 +0200
commit7c3b203c5c69fc37c8d143851cd395cbf8920786 (patch)
tree7702142c649171975c0b69a1c354652e48dfee2a /src/kmsg-syslogd.c
parent5b754353282e3ba3cf9c4ffc50579aff4b7d72db (diff)
kmsg-syslogd: pass facility value into kmsg
Diffstat (limited to 'src/kmsg-syslogd.c')
-rw-r--r--src/kmsg-syslogd.c57
1 files changed, 11 insertions, 46 deletions
diff --git a/src/kmsg-syslogd.c b/src/kmsg-syslogd.c
index c78011fe22..60d3244b3b 100644
--- a/src/kmsg-syslogd.c
+++ b/src/kmsg-syslogd.c
@@ -154,50 +154,6 @@ fail:
return r;
}
-static int read_priority(const char **buf) {
- int priority;
- size_t n;
- const char *p;
- int a, b, c;
-
- assert(buf);
- assert(*buf);
-
- p = *buf;
- n = strlen(p);
-
- if (n < 3 || p[0] != '<')
- goto fail;
-
- if (p[2] == '>') {
- a = b = 0;
- c = undecchar(p[1]);
- p += 3;
- } else if (n >= 4 && p[3] == '>') {
- a = 0;
- b = undecchar(p[1]);
- c = undecchar(p[2]);
- p += 4;
- } else if (n >= 5 && p[4] == '>') {
- a = undecchar(p[1]);
- b = undecchar(p[2]);
- c = undecchar(p[3]);
- p += 5;
- } else
- goto fail;
-
- if (a < 0 || b < 0 || c < 0)
- goto fail;
-
- *buf = p;
-
- priority = 100*a + 10*b + c;
- return LOG_PRI(priority);
-
-fail:
- return LOG_INFO;
-}
-
static void skip_date(const char **buf) {
enum {
LETTER,
@@ -334,17 +290,26 @@ static void skip_pid(const char **buf) {
static int write_message(Server *s, const char *buf, struct ucred *ucred) {
ssize_t k;
- char priority[4], pid[16];
+ char priority[6], pid[16];
struct iovec iovec[5];
unsigned i = 0;
char *process = NULL;
int r = 0;
+ int prio = LOG_USER | LOG_INFO;
assert(s);
assert(buf);
+ parse_syslog_priority((char**) &buf, &prio);
+
+ if (*buf == 0)
+ return 0;
+
+ if ((prio & LOG_FACMASK) == 0)
+ prio = LOG_USER | LOG_PRI(prio);
+
/* First, set priority field */
- snprintf(priority, sizeof(priority), "<%i>", read_priority(&buf));
+ snprintf(priority, sizeof(priority), "<%i>", prio);
char_array_0(priority);
IOVEC_SET_STRING(iovec[i++], priority);