No need to protect exports from SIGHUP, the handler just sets a flag.
authormillert <millert@openbsd.org>
Thu, 2 Mar 2023 16:58:43 +0000 (16:58 +0000)
committermillert <millert@openbsd.org>
Thu, 2 Mar 2023 16:58:43 +0000 (16:58 +0000)
The signal handlers in mountd.c were made safe in rev 1.34 from 2001.
OK bluhm@ kn@

sbin/mountd/mountd.c

index 634b67f..51bc545 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: mountd.c,v 1.90 2023/03/01 23:27:46 millert Exp $     */
+/*     $OpenBSD: mountd.c,v 1.91 2023/03/02 16:58:43 millert Exp $     */
 /*     $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */
 
 /*
@@ -736,7 +736,6 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
        char rpcpath[RPCMNT_PATHLEN+1], dirpath[PATH_MAX];
        struct hostent *hp = NULL;
        struct exportlist *ep;
-       sigset_t sighup_mask;
        int defset, hostset;
        struct fhreturn fhr;
        struct dirlist *dp;
@@ -746,8 +745,6 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
        u_short sport;
        long bad = 0;
 
-       sigemptyset(&sighup_mask);
-       sigaddset(&sighup_mask, SIGHUP);
        saddr = transp->xp_raddr.sin_addr.s_addr;
        sport = ntohs(transp->xp_raddr.sin_port);
        switch (rqstp->rq_proc) {
@@ -792,7 +789,6 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
                }
 
                /* Check in the exports list */
-               sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
                ep = bad ? NULL : ex_search(&fsb.f_fsid);
                hostset = defset = 0;
                if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset) ||
@@ -804,7 +800,6 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
                                if (!svc_sendreply(transp, xdr_long,
                                    (caddr_t)&bad))
                                        syslog(LOG_ERR, "Can't send reply");
-                               sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
                                return;
                        }
                        if (hostset & DP_HOSTSET)
@@ -820,7 +815,6 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
                                if (!svc_sendreply(transp, xdr_long,
                                    (caddr_t)&bad))
                                        syslog(LOG_ERR, "Can't send reply");
-                               sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
                                return;
                        }
                        if (!svc_sendreply(transp, xdr_fhs, (caddr_t)&fhr))
@@ -844,7 +838,6 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
 
                if (bad && !svc_sendreply(transp, xdr_long, (caddr_t)&bad))
                        syslog(LOG_ERR, "Can't send reply");
-               sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
                return;
        case RPCMNT_DUMP:
                if (!svc_sendreply(transp, xdr_mlist, NULL))
@@ -958,11 +951,7 @@ xdr_explist(XDR *xdrsp, caddr_t cp)
 {
        struct exportlist *ep;
        int false = 0, putdef;
-       sigset_t sighup_mask;
 
-       sigemptyset(&sighup_mask);
-       sigaddset(&sighup_mask, SIGHUP);
-       sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
        ep = exphead;
        while (ep) {
                putdef = 0;
@@ -973,12 +962,10 @@ xdr_explist(XDR *xdrsp, caddr_t cp)
                        goto errout;
                ep = ep->ex_next;
        }
-       sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
        if (!xdr_bool(xdrsp, &false))
                return (0);
        return (1);
 errout:
-       sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
        return (0);
 }
 
@@ -1050,7 +1037,6 @@ void
 new_exportlist(int signo)
 {
        gothup = 1;
-
 }
 
 /*