diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-07-24 17:53:34 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-07-24 17:53:34 +0000 |
commit | 6ea88394dfe4721dabe83361d058c1f8aa1e42c9 (patch) | |
tree | 57b4e7efae53a6f742e4cf6de356024cf681b30c /sbin/dhclient | |
parent | 46d0bbef01d8614fcb67e54feaced1d675fe9f30 (diff) |
Return fd of -1 if take_charge() detects 'quit' being set to
TERMINATE. Exit if take_charge() returns -1.
Set 'quit' to TERMINATE instead of directly calling 'exit(0)' in
rtm_dispatch().
Nuke erroneous "not reached" comment.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/dhclient.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 285bdefa030..9c7f42202ba 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.646 2019/07/19 20:50:22 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.647 2019/07/24 17:53:33 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -358,7 +358,8 @@ rtm_dispatch(struct interface_info *ifi, struct rt_msghdr *rtm) } else if ((ifi->flags & IFI_IN_CHARGE) != 0) { log_debug("%s: yielding responsibility", log_procname); - exit(0); + ifi->state = S_PREBOOT; + quit = TERMINATE; } } else if ((rtm->rtm_flags & RTF_PROTO2) != 0) { release_lease(ifi); /* OK even if we sent it. */ @@ -590,6 +591,9 @@ main(int argc, char *argv[]) fatal("setsockopt(ROUTE_TABLEFILTER)"); fd = take_charge(ifi, routefd, path_lease_db); + if (fd == -1) + fatalx("failed to take charge"); + read_lease_db(&ifi->lease_db); if ((leaseFile = fopen(path_lease_db, "w")) == NULL) @@ -643,7 +647,6 @@ main(int argc, char *argv[]) quit = RESTART; dispatch(ifi, routefd); - /* not reached */ return 0; } @@ -2453,11 +2456,11 @@ take_charge(struct interface_info *ifi, int routefd, char *leasespath) if (write(routefd, &rtm, sizeof(rtm)) == -1) fatal("write(routefd)"); - for (fd = -1; fd == -1;) { + for (fd = -1; fd == -1 && quit != TERMINATE;) { if (time(&cur_time) == -1) fatal("time"); if (cur_time - start_time >= MAXSECONDS) - fatalx("failed to take charge"); + break; if ((ifi->flags & IFI_IN_CHARGE) == 0) { if ((cur_time - sent_time) >= SENTSECONDS) { |