diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-10 02:01:51 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-10 02:01:51 +0000 |
commit | 3db254c8866de390c327d759ba615693e45aff6f (patch) | |
tree | 1dd0f6a0cc97f1f75a7b88d4488d4919ea2417bd /sysklogd | |
parent | 6cee58e9cfedfa09ede3f5499eb5f635fc2bb77c (diff) | |
download | busybox-w32-3db254c8866de390c327d759ba615693e45aff6f.tar.gz busybox-w32-3db254c8866de390c327d759ba615693e45aff6f.tar.bz2 busybox-w32-3db254c8866de390c327d759ba615693e45aff6f.zip |
apply accumulated post 1.8.0 fixes, bump version to 1.8.11_8_1
Diffstat (limited to 'sysklogd')
-rw-r--r-- | sysklogd/syslogd.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index ba46792b6..da63ced42 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -381,8 +381,8 @@ static void parse_fac_prio_20(int pri, char *res20) | |||
381 | } | 381 | } |
382 | 382 | ||
383 | /* len parameter is used only for "is there a timestamp?" check. | 383 | /* len parameter is used only for "is there a timestamp?" check. |
384 | * NB: some callers cheat and supply 0 when they know | 384 | * NB: some callers cheat and supply len==0 when they know |
385 | * that there is no timestamp, short-cutting the test. */ | 385 | * that there is no timestamp, short-circuiting the test. */ |
386 | static void timestamp_and_log(int pri, char *msg, int len) | 386 | static void timestamp_and_log(int pri, char *msg, int len) |
387 | { | 387 | { |
388 | char *timestamp; | 388 | char *timestamp; |
@@ -427,10 +427,10 @@ static void split_escape_and_log(char *tmpbuf, int len) | |||
427 | if (*p == '<') { | 427 | if (*p == '<') { |
428 | /* Parse the magic priority number */ | 428 | /* Parse the magic priority number */ |
429 | pri = bb_strtou(p + 1, &p, 10); | 429 | pri = bb_strtou(p + 1, &p, 10); |
430 | if (*p == '>') p++; | 430 | if (*p == '>') |
431 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) { | 431 | p++; |
432 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) | ||
432 | pri = (LOG_USER | LOG_NOTICE); | 433 | pri = (LOG_USER | LOG_NOTICE); |
433 | } | ||
434 | } | 434 | } |
435 | 435 | ||
436 | while ((c = *p++)) { | 436 | while ((c = *p++)) { |
@@ -526,14 +526,32 @@ static void do_syslogd(void) | |||
526 | 526 | ||
527 | for (;;) { | 527 | for (;;) { |
528 | size_t sz; | 528 | size_t sz; |
529 | 529 | read_again: | |
530 | sz = safe_read(sock_fd, G.recvbuf, MAX_READ - 1); | 530 | sz = safe_read(sock_fd, G.recvbuf, MAX_READ - 1); |
531 | if (sz <= 0) { | 531 | if (sz < 0) { |
532 | //if (sz == 0) | ||
533 | // continue; /* EOF from unix socket??? */ | ||
534 | bb_perror_msg_and_die("read from /dev/log"); | 532 | bb_perror_msg_and_die("read from /dev/log"); |
535 | } | 533 | } |
536 | 534 | ||
535 | /* Drop trailing NULs (typically there is one NUL) */ | ||
536 | while (1) { | ||
537 | if (sz == 0) | ||
538 | goto read_again; | ||
539 | /* man 3 syslog says: "A trailing newline is added when needed". | ||
540 | * However, neither glibc nor uclibc do this: | ||
541 | * syslog(prio, "test") sends "test\0" to /dev/log, | ||
542 | * syslog(prio, "test\n") sends "test\n\0", | ||
543 | * IOW: newline is passed verbatim! | ||
544 | * I take it to mean that it's syslogd's job | ||
545 | * to make those look identical in the log files */ | ||
546 | if (G.recvbuf[sz-1] && G.recvbuf[sz-1] != '\n') | ||
547 | break; | ||
548 | sz--; | ||
549 | } | ||
550 | /* Maybe we need to add '\n' here, not later? | ||
551 | * It looks like stock syslogd does send '\n' over network, | ||
552 | * but we do not (see sendto below) */ | ||
553 | G.recvbuf[sz] = '\0'; /* make sure it *is* NUL terminated */ | ||
554 | |||
537 | /* TODO: maybe suppress duplicates? */ | 555 | /* TODO: maybe suppress duplicates? */ |
538 | #if ENABLE_FEATURE_REMOTE_LOG | 556 | #if ENABLE_FEATURE_REMOTE_LOG |
539 | /* We are not modifying log messages in any way before send */ | 557 | /* We are not modifying log messages in any way before send */ |
@@ -549,7 +567,6 @@ static void do_syslogd(void) | |||
549 | } | 567 | } |
550 | } | 568 | } |
551 | #endif | 569 | #endif |
552 | G.recvbuf[sz] = '\0'; | ||
553 | split_escape_and_log(G.recvbuf, sz); | 570 | split_escape_and_log(G.recvbuf, sz); |
554 | } /* for */ | 571 | } /* for */ |
555 | } | 572 | } |