NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/38539: libc/gen/syslog.c always logs to console if LOG_CONS is set
>Number: 38539
>Category: lib
>Synopsis: libc/gen/syslog.c always logs to console if LOG_CONS is set
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Apr 29 05:55:00 +0000 2008
>Originator: Ed Ravin
>Release: 4.0
>Organization:
Public Access Networks Corp
>Environment:
NetBSD panix5.panix.com 4.0 NetBSD 4.0 (PANIX-XEN3U-USER) #0: Thu Feb 28
22:13:03 EST 2008
root%juggler.panix.com@localhost:/misc2/obj/misc2/devel/netbsd/4.0/src/sys/arch/i386/compile/PANIX-XEN3U-USER
i386
>Description:
Sometime between NetBSD 3.1 and NetBSD 4.0, libc/gen/syslog.c was changed to
always fall through the code that tests if LOG_CONS is set.
According to syslog.3, LOG_CONS means log to console only if the logging to
syslogd failed. This was done properly in 3.1:
for (tries = 1; tries <= 2; tries++) {
if (!connected)
openlog_unlocked(LogTag, LogStat | LOG_NDELAY, 0);
if (send(LogFile, tbuf, cnt, 0) >= 0) {
mutex_unlock(&syslog_mutex);
return;
}
Note the "return" statement after it is determined that the send() to the
syslogd socket succeeded. That "return" is missing from the
syslog.c in NetBSD 4.0.
The result is that if you call openlog() with LOG_CONS, your syslog
output always goes to the console, even if it successfully went to syslogd.
>How-To-Repeat:
Run this program under ktrace:
$ cat testsyslogcons.c
#include <stdio.h>
#include <syslog.h>
main(int argc, char* argv)
{
openlog("test_log_cons", LOG_CONS | LOG_PID, LOG_DAEMON);
syslog(LOG_INFO, "I don't want this to go to the console");
}
Confirm from viewing the ktrace output that the result of send() was
not -1 but the program wrote to /dev/console anyway.
Correct output (on a NetBSD 3.1 system):
16834 testsyslogcons socket(0x1, 0x2, 0) = 3
16834 testsyslogcons fcntl(0x3, 0x2, 0x1) = 0
16834 testsyslogcons connect(0x3, 0xbdbe9280, 0xe) = 0
16834 testsyslogcons sendto(0x3, 0xbfbfe3a0, 0x50, 0, 0, 0) = 80
"<30>Apr 28 20:57:14 test_log_cons[16834]: I don't want this to go to "
16834 testsyslogcons exit(0)
Output showing the problem (on a NetBSD 4.0 system):
26208 1 testsyslogcons __socket30(0x1, 0x2, 0) = 3
26208 1 testsyslogcons fcntl(0x3, 0x2, 0x1) = 0
26208 1 testsyslogcons connect(0x3, 0xbbbd0980, 0x6a) = 0
26208 1 testsyslogcons sendto(0x3, 0xbfbfdedc, 0x50, 0, 0, 0) = 80
"<30>Apr 28 20:59:54 test_log_cons[26208]: I don't want this to go to "
26208 1 testsyslogcons open("/dev/console", 0x5, 0) Err#13 EACCES
26208 1 testsyslogcons exit(0xffffffff)
>Fix:
Home |
Main Index |
Thread Index |
Old Index