Subject: bin/27309: syslogd -u can't create pidfile
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <jschauma@stevens-tech.edu>
List: netbsd-bugs
Date: 10/21/2004 11:07:55
>Number:         27309
>Category:       bin
>Synopsis:       syslogd -u can't create pidfile
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 22 08:47:01 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Jan Schaumann
>Release:        NetBSD 2.0_RC3
>Organization:
	
>Environment:
	
	
System: NetBSD dogfish-head.cs.stevens.edu 2.0_RC3 NetBSD 2.0_RC3 (BOCK) #20: Mon Oct 4 14:19:22 EDT 2004 jschauma@doppelbock.hpcf.cs.stevens-tech.edu:/share/src/sys/arch/i386/compile/obj/BOCK i386
Architecture: i386
Machine: i386
>Description:
	When starting syslogd(8) with the '-u' option, syslogd will be unable
	to create the standard pidfile, as it changes UID and the user likely
	does not have write permission to /var/run/.
>How-To-Repeat:
	Add:

	syslogd=YES
	syslogd_flags="-u syslogd -g syslogd"

	to /etc/rc.conf

	/etc/rc.d/syslogd restart
	syslogd not running? (check /var/run/syslogd.pid).
	Starting syslogd.

	ls /var/run/syslogd.pid
	ls: /var/run/syslogd.pid: No such file or directory

	ps ax | grep sysl
	 8461 ?? Ss     0:00.00 /usr/sbin/syslogd -u syslogd -g syslogd

	/etc/rc.d/syslogd restart
	syslogd not running? (check /var/run/syslogd.pid).
	Starting syslogd.
	syslogd: bind() failed: Address already in use
	syslogd: Fatal error, exiting


>Fix:

	Well, create pidfile before changing UID.  However, there seems
	to be a problem:  syslogd.c around #464 indicates that we can't
	daemonize until we're sure we don't get any fatal errors.  So we
	can't daemonize until we've changed UID.  We can't create the pidfile
	before daemonizing, obviously, either.

>Release-Note:
>Audit-Trail:
>Unformatted: