Use a local variable rather than a global flag to record
authorkrw <krw@openbsd.org>
Sat, 24 Jun 2017 10:09:26 +0000 (10:09 +0000)
committerkrw <krw@openbsd.org>
Sat, 24 Jun 2017 10:09:26 +0000 (10:09 +0000)
the reception of a IMSG_HUP message and trigger the
desired restart.

Nuke the now pointless IFI_HUP.

sbin/dhclient/dhclient.c
sbin/dhclient/dhcpd.h
sbin/dhclient/privsep.c
sbin/dhclient/privsep.h

index cb05d88..64b9155 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dhclient.c,v 1.445 2017/06/23 19:51:07 krw Exp $      */
+/*     $OpenBSD: dhclient.c,v 1.446 2017/06/24 10:09:26 krw Exp $      */
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -2034,7 +2034,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
        struct pollfd pfd[1];
        struct imsgbuf *priv_ibuf;
        ssize_t n;
-       int nfds, rslt;
+       int nfds, rslt, got_imsg_hup = 0;
 
        switch (fork()) {
        case -1:
@@ -2086,7 +2086,9 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
                        continue;
                }
 
-               dispatch_imsg(ifi, priv_ibuf);
+               got_imsg_hup = dispatch_imsg(ifi, priv_ibuf);
+               if (got_imsg_hup)
+                       quit = SIGHUP;
        }
 
        imsg_clear(priv_ibuf);
@@ -2110,7 +2112,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
        }
 
        if (quit == SIGHUP) {
-               if (!(ifi->flags & IFI_HUP))
+               if (!got_imsg_hup)
                        log_warnx("%s; restarting.", strsignal(quit));
                signal(SIGHUP, SIG_IGN); /* will be restored after exec */
                execvp(saved_argv[0], saved_argv);
index 530d025..7c81709 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dhcpd.h,v 1.193 2017/06/23 19:51:07 krw Exp $ */
+/*     $OpenBSD: dhcpd.h,v 1.194 2017/06/24 10:09:26 krw Exp $ */
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -135,7 +135,6 @@ struct interface_info {
        int                      rdomain;
        int                      flags;
 #define        IFI_VALID_LLADDR        0x01
-#define IFI_HUP                        0x04
 #define IFI_IS_RESPONSIBLE     0x08
 #define IFI_IN_CHARGE          0x10
        struct dhcp_packet       recv_packet;
index 4e5b0ec..7e7d220 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: privsep.c,v 1.48 2017/06/23 16:18:02 krw Exp $ */
+/*     $OpenBSD: privsep.c,v 1.49 2017/06/24 10:09:26 krw Exp $ */
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -35,7 +35,7 @@
 #include "log.h"
 #include "privsep.h"
 
-void
+int
 dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf)
 {
        struct imsg                      imsg;
@@ -102,8 +102,8 @@ dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf)
                            sizeof(struct imsg_hup))
                                log_warnx("bad IMSG_HUP");
                        else {
-                               ifi->flags |= IFI_HUP;
-                               quit = SIGHUP;
+                               imsg_free(&imsg);
+                               return 1;
                        }
                        break;
 
@@ -114,4 +114,5 @@ dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf)
 
                imsg_free(&imsg);
        }
+       return 0;
 }
index 3d36763..ed2f9c6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: privsep.h,v 1.36 2017/06/23 15:40:56 krw Exp $ */
+/*     $OpenBSD: privsep.h,v 1.37 2017/06/24 10:09:26 krw Exp $ */
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -57,7 +57,7 @@ struct imsg_set_interface_mtu {
        int     mtu;
 };
 
-void   dispatch_imsg(struct interface_info *, struct imsgbuf *);
+int    dispatch_imsg(struct interface_info *, struct imsgbuf *);
 
 void   add_direct_route(struct in_addr, struct in_addr, struct in_addr);
 void   add_default_route(struct in_addr, struct in_addr);