Module Name:    src
Committed By:   gson
Date:           Tue Mar 18 11:00:20 UTC 2014

Modified Files:
        src/libexec/rpc.rquotad: rquotad.c

Log Message:
Delay daemonization until RPC services have been registered.
Fixes one of the race conditions of PR misc/48282.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/libexec/rpc.rquotad/rquotad.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/rpc.rquotad/rquotad.c
diff -u src/libexec/rpc.rquotad/rquotad.c:1.32 src/libexec/rpc.rquotad/rquotad.c:1.33
--- src/libexec/rpc.rquotad/rquotad.c:1.32	Mon Jan  9 15:37:34 2012
+++ src/libexec/rpc.rquotad/rquotad.c	Tue Mar 18 11:00:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rquotad.c,v 1.32 2012/01/09 15:37:34 dholland Exp $	*/
+/*	$NetBSD: rquotad.c,v 1.33 2014/03/18 11:00:20 gson Exp $	*/
 
 /*
  * by Manuel Bouyer ([email protected]). Public domain.
@@ -6,7 +6,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: rquotad.c,v 1.32 2012/01/09 15:37:34 dholland Exp $");
+__RCSID("$NetBSD: rquotad.c,v 1.33 2014/03/18 11:00:20 gson Exp $");
 #endif
 
 #include <sys/param.h>
@@ -62,13 +62,8 @@ main(int argc, char *argv[])
 		from_inetd = 0;
 
 	if (!from_inetd) {
-		daemon(0, 0);
-
 		(void) rpcb_unset(RQUOTAPROG, RQUOTAVERS, NULL);
 		(void) rpcb_unset(RQUOTAPROG, EXT_RQUOTAVERS, NULL);
-		(void) signal(SIGINT, cleanup);
-		(void) signal(SIGTERM, cleanup);
-		(void) signal(SIGHUP, cleanup);
 	}
 
 	openlog("rpc.rquotad", LOG_PID, LOG_DAEMON);
@@ -106,6 +101,12 @@ main(int argc, char *argv[])
 		}
 	}
 
+	if (!from_inetd) {
+		daemon(0, 0);
+		(void) signal(SIGINT, cleanup);
+		(void) signal(SIGTERM, cleanup);
+		(void) signal(SIGHUP, cleanup);
+	}
 	svc_run();
 	syslog(LOG_ERR, "svc_run returned");
 	exit(1);

Reply via email to