Source-Changes-HG archive

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

[src/trunk]: src/libexec/rpc.rquotad Delay daemonization until RPC services h...



details:   https://anonhg.NetBSD.org/src/rev/9c328dc2cfb0
branches:  trunk
changeset: 327839:9c328dc2cfb0
user:      gson <gson%NetBSD.org@localhost>
date:      Tue Mar 18 11:00:20 2014 +0000

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

diffstat:

 libexec/rpc.rquotad/rquotad.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (45 lines):

diff -r c6093cd17811 -r 9c328dc2cfb0 libexec/rpc.rquotad/rquotad.c
--- a/libexec/rpc.rquotad/rquotad.c     Tue Mar 18 10:21:47 2014 +0000
+++ b/libexec/rpc.rquotad/rquotad.c     Tue Mar 18 11:00:20 2014 +0000
@@ -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 (bouyer%ensta.fr@localhost). 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 @@
                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 @@
                }
        }
 
+       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);



Home | Main Index | Thread Index | Old Index