syslog(), openlog(), bug in syslog.c patch

Tad Guy tadguy at cs.odu.edu
Fri Dec 16 13:40:09 AEST 1988


In article <17826 at adm.BRL.MIL>, becker at trantor (Don Becker) writes:
>I installed a fix similar to the one suggested by Tad Guy
><tadguy at cs.odu.edu>.  A quick look at his change suggests that he
>doesn't deal with the case where a connect() is not done -- he always
>has syslog() do a send() rather than a sendto() to the socket.

I considered this, and unless I am reading the source wrong, connect()
is guaranteed to have been called before the send().  Even if you call
syslog() without first calling openlog() (or after calling openlog()
but without LOG_NDELAY set), syslog() calls openlog() for you with
LOG_NDELAY set, thus guarantying that the socket is created and (with
my patch) connected before any calls to send() occur.

This is with the 4.3BSD syslog.c (version 5.9 dated 5/7/86).  Your
version may be different.

>Making a connection is the Right Thing, and should be default.  It
>should be more efficient than doing namei() on "/dev/log" each time
>inside of sendto, but I suspect that it isn't.

It is.  But, as Louis Mamakos pointed out, doing the connect() is a
bad idea for long running processes, because they run the risk of
having the inode info for an obsolete "/dev/log" should syslogd be
restarted.

	...tad

-- 
Tad Guy         <tadguy at cs.odu.edu>     Old Dominion University, Norfolk, VA



More information about the Comp.unix.wizards mailing list