Mercurial > hg > dhcpcd
changeset 4952:e77138b6ec3b draft
DHCP: Spawn a listener in non master mode for a new lease
Fixes a privsep issue
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 09 Jan 2020 14:48:56 +0000 |
| parents | 3a8e7a111dd9 |
| children | 109206a59cc6 |
| files | src/dhcp.c |
| diffstat | 1 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcp.c Thu Jan 09 00:33:03 2020 +0000 +++ b/src/dhcp.c Thu Jan 09 14:48:56 2020 +0000 @@ -2172,7 +2172,7 @@ struct dhcp_state *state = D_STATE(ifp); struct if_options *ifo = ifp->options; struct dhcp_lease *lease = &state->lease; - bool wasfake; + uint8_t old_state; state->reason = NULL; /* If we don't have an offer, we are re-binding a lease on preference, @@ -2285,18 +2285,19 @@ /* Close the BPF filter as we can now receive DHCP messages * on a UDP socket. */ - wasfake = state->added & STATE_FAKE; + old_state = state->added; if (ctx->options & DHCPCD_MASTER || state->old == NULL || - state->old->yiaddr != state->new->yiaddr || wasfake) + state->old->yiaddr != state->new->yiaddr || old_state & STATE_FAKE) dhcp_close(ifp); ipv4_applyaddr(ifp); /* If not in master mode, open an address specific socket. */ if (ctx->options & DHCPCD_MASTER || - state->old == NULL || - (state->old->yiaddr == state->new->yiaddr && !wasfake)) + (state->old != NULL && + state->old->yiaddr == state->new->yiaddr && + old_state & STATE_ADDED && !(old_state & STATE_FAKE))) return; #ifdef PRIVSEP
