Actually, the signal handling was simplified 14(!) years ago by miod@ when 
he changed rbootd to do all processing from its main loop, with signals 
just setting flags tested there.  This diff just removes the blocking and 
unblocking that was rendered superfluous by that previous change.

Back when signal were processed directly from the signal handler, opening 
and closing the debug output file and reparsing the config, the "normal" 
code had to block those signals when it wanted to keep those actions from 
happening.  After miod's changes, the signal handler just sets a flag, so 
there's no need to mask signals across sections of code.  While here, 
delete some unnecessary #includes.

I believe this removes the last uses of the obsolete sigblock(), 
sigsetmask(), and sigmask() from non-GNU base.

ok?

Philip Guenther

Index: usr.sbin/rbootd/parseconf.c
===================================================================
RCS file: /data/src/openbsd/src/usr.sbin/rbootd/parseconf.c,v
retrieving revision 1.12
diff -u -p -r1.12 parseconf.c
--- usr.sbin/rbootd/parseconf.c 16 Jan 2015 06:40:19 -0000      1.12
+++ usr.sbin/rbootd/parseconf.c 21 May 2016 07:06:23 -0000
@@ -47,8 +47,6 @@
 
 #include <ctype.h>
 #include <dirent.h>
-#include <fcntl.h>
-#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -76,7 +74,6 @@ ParseConfig(void)
 {
        char line[C_LINELEN], *cp, *bcp;
        int i, j, linecnt = 0;
-       sigset_t mask, omask;
        u_int8_t *addr;
        CLIENT *client;
        FILE *fp;
@@ -93,17 +90,6 @@ ParseConfig(void)
        }
 
        /*
-        *  We've got to block SIGHUP to prevent reconfiguration while
-        *  dealing with the linked list of Clients.  This can be done
-        *  when actually linking the new client into the list, but
-        *  this could have unexpected results if the server was HUP'd
-        *  whilst reconfiguring.  Hence, it is done here.
-        */
-       sigemptyset(&mask);
-       sigaddset(&mask, SIGHUP);
-       sigprocmask(SIG_BLOCK, &mask, &omask);
-
-       /*
         *  GETSTR positions `bcp' at the start of the current token,
         *  and null terminates it.  `cp' is positioned at the start
         *  of the next token.  spaces & commas are separators.
@@ -206,7 +192,6 @@ ParseConfig(void)
        }
 
        (void) fclose(fp);                              /* close config file */
-       sigprocmask(SIG_SETMASK, &omask, NULL);         /* reset signal mask */
        return(1);                                      /* return success */
 }
 
Index: usr.sbin/rbootd/rbootd.c
===================================================================
RCS file: /data/src/openbsd/src/usr.sbin/rbootd/rbootd.c,v
retrieving revision 1.30
diff -u -p -r1.30 rbootd.c
--- usr.sbin/rbootd/rbootd.c    16 Mar 2016 15:41:11 -0000      1.30
+++ usr.sbin/rbootd/rbootd.c    21 May 2016 07:11:54 -0000
@@ -45,10 +45,8 @@
 
 #include <sys/time.h>
 
-#include <ctype.h>
 #include <err.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -83,7 +81,6 @@ int
 main(int argc, char *argv[])
 {
        int c, fd;
-       sigset_t hmask, omask;
        struct passwd *pw;
        struct pollfd pfd[1];
 
@@ -170,9 +167,6 @@ main(int argc, char *argv[])
        /*
         *  Initial configuration.
         */
-       sigemptyset(&hmask);
-       sigaddset(&hmask, SIGHUP);
-       sigprocmask(SIG_BLOCK, &hmask, &omask); /* prevent reconfig's */
        if (GetBootFiles() == 0)                /* get list of boot files */
                DoExit();
        if (ParseConfig() == 0)                 /* parse config file */
@@ -194,8 +188,6 @@ main(int argc, char *argv[])
        }
        endpwent();
 
-       sigprocmask(SIG_SETMASK, &omask, NULL); /* allow reconfig's */
-
        /*
         *  Main loop: receive a packet, determine where it came from,
         *  and if we service this host, call routine to handle request.
@@ -244,8 +236,6 @@ main(int argc, char *argv[])
                                if (DbgFp != NULL)      /* display packet */
                                        DispPkt(&rconn,DIR_RCVD);
 
-                               sigprocmask(SIG_BLOCK, &hmask, &omask);
-
                                /*
                                 *  If we do not restrict service, set the
                                 *  client to NULL (ProcessPacket() handles
@@ -259,13 +249,10 @@ main(int argc, char *argv[])
                                        syslog(LOG_INFO,
                                            "%s: boot packet ignored",
                                            EnetStr(&rconn));
-                                       sigprocmask(SIG_SETMASK, &omask, NULL);
                                        continue;
                                }
 
                                ProcessPacket(&rconn,client);
-
-                               sigprocmask(SIG_SETMASK, &omask, NULL);
                        }
                }
        }
Index: usr.sbin/rbootd/utils.c
===================================================================
RCS file: /data/src/openbsd/src/usr.sbin/rbootd/utils.c,v
retrieving revision 1.14
diff -u -p -r1.14 utils.c
--- usr.sbin/rbootd/utils.c     20 Aug 2015 22:39:29 -0000      1.14
+++ usr.sbin/rbootd/utils.c     21 May 2016 06:59:45 -0000
@@ -43,8 +43,6 @@
  * Author: Jeff Forys, University of Utah CSS
  */
 
-#include <fcntl.h>
-#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -75,21 +73,10 @@ DispPkt(RMPCONN *rconn, int direct)
            "\t\tRetCode:%u Offset:%x SessID:%x\n";
        struct tm *tmp;
        struct rmp_packet *rmp;
-       int i, omask;
+       int i;
        u_int32_t t;
        time_t tim;
 
-       /*
-        *  Since we will be working with RmpConns as well as DbgFp, we
-        *  must block signals that can affect either.
-        */
-       omask = sigblock(sigmask(SIGHUP)|sigmask(SIGUSR1)|sigmask(SIGUSR2));
-
-       if (DbgFp == NULL) {                    /* sanity */
-               (void) sigsetmask(omask);
-               return;
-       }
-
        /* display direction packet is going using '>>>' or '<<<' */
        fputs((direct==DIR_RCVD)?"<<< ":(direct==DIR_SENT)?">>> ":"", DbgFp);
 
@@ -173,8 +160,6 @@ DispPkt(RMPCONN *rconn, int direct)
        }
        (void) fputc('\n', DbgFp);
        (void) fflush(DbgFp);
-
-       (void) sigsetmask(omask);               /* reset old signal mask */
 }
 
 

Reply via email to