summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-06-24 10:09:27 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-06-24 10:09:27 +0000
commitc359a3a54bda738ec8209eb89ee3586ae166c141 (patch)
tree9347682c5d11f8b63a2d227c74b7c099b2fcfd62
parent4c0e028822a0874e280e1be6911eb0da8434ae03 (diff)
Use a local variable rather than a global flag to record
the reception of a IMSG_HUP message and trigger the desired restart. Nuke the now pointless IFI_HUP.
-rw-r--r--sbin/dhclient/dhclient.c10
-rw-r--r--sbin/dhclient/dhcpd.h3
-rw-r--r--sbin/dhclient/privsep.c9
-rw-r--r--sbin/dhclient/privsep.h4
4 files changed, 14 insertions, 12 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index cb05d88474c..64b915531ce 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -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);
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 530d0250570..7c8170959d7 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -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;
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index 4e5b0ec95c1..7e7d2205d47 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -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;
}
diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h
index 3d367634bac..ed2f9c652f6 100644
--- a/sbin/dhclient/privsep.h
+++ b/sbin/dhclient/privsep.h
@@ -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);