From 66535179928000124b3b3a7814d0707ac78f8cf3 Mon Sep 17 00:00:00 2001 From: krw Date: Sat, 24 Jun 2017 10:09:26 +0000 Subject: [PATCH] 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. --- sbin/dhclient/dhclient.c | 10 ++++++---- sbin/dhclient/dhcpd.h | 3 +-- sbin/dhclient/privsep.c | 9 +++++---- sbin/dhclient/privsep.h | 4 ++-- 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 @@ -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 @@ -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 @@ -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 @@ -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); -- 2.20.1