[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: system/2178



On Wed, Nov 14, 2001 at 02:35:34PM -0700, Todd C. Miller wrote:
> Synopsis: rwhod sends errors to stderr after calling daemon
> 
> State-Changed-From-To: open-closed
> State-Changed-By: millert
> State-Changed-When: Wed Nov 14 14:35:04 MST 2001
> State-Changed-Why: 
> daemon() call moved to be after chdir()

This is wrong.  daemon chdirs to /, so this will make the chdir 
useless.

Try this instead (patch relative to 3.0 release source):
--- rwhod.c.orig	Wed Nov 14 17:37:39 2001
+++ rwhod.c	Wed Nov 14 17:38:58 2001
@@ -160,13 +160,13 @@
 	if (!debug)
 		daemon(1, 0);
 
+	(void) signal(SIGHUP, hup);
+	openlog("rwhod", LOG_PID, LOG_DAEMON);
+
 	if (chdir(_PATH_RWHODIR) < 0) {
-		(void)fprintf(stderr, "rwhod: %s: %s\n",
-		    _PATH_RWHODIR, strerror(errno));
+		syslog(LOG_ERR, "chdir: %m");
 		exit(1);
 	}
-	(void) signal(SIGHUP, hup);
-	openlog("rwhod", LOG_PID, LOG_DAEMON);
 	/*
 	 * Establish host name as returned by system.
 	 */

-- 
David Terrell            | "When we said that you needed to cut the
dbt@meat.net             | wires for ultimate security, we didn't
Nebcorp Prime Minister   | mean that you should go wireless instead."
http://wwn.nebcorp.com/  |   - Casper Dik