From: Roy Marples Date: Thu, 20 Apr 2017 16:14:29 +0000 (+0100) Subject: dhcpcd.c: Fix -n opening sockets. X-Git-Tag: v7.0.0-rc1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63c9e25765c9b68d1f4899893cfbd5eef4bcdd5e;p=thirdparty%2Fdhcpcd.git dhcpcd.c: Fix -n opening sockets. Summary: Open sockets when dumping leases OR actually starting up. If just sending a control message or signal, don't bother. Test Plan: Start dhcpcd using -n Reviewers: sthen Reviewed By: sthen Subscribers: sthen Differential Revision: https://dev.marples.name/D106 --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index ac6c6ba9..ce5fb447 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -1657,20 +1657,13 @@ printpidfile: goto exit_failure; } - /* Open our persistent sockets. - * This is needed early for dumping leases on valid interfaces. */ -#ifdef USE_SIGNALS - if (sig == 0) { -#endif + if (ctx.options & DHCPCD_DUMPLEASE) { + /* Open sockets so we can dump something about + * valid interfaces. */ if (if_opensockets(&ctx) == -1) { logerr("%s: if_opensockets", __func__); goto exit_failure; } -#ifdef USE_SIGNALS - } -#endif - - if (ctx.options & DHCPCD_DUMPLEASE) { if (optind != argc) { /* We need to try and find the interface so we can load * the hardware address to compare automated IAID */ @@ -1817,6 +1810,12 @@ printpidfile: logdebugx(PACKAGE "-" VERSION " starting"); ctx.options |= DHCPCD_STARTED; + + if (if_opensockets(&ctx) == -1) { + logerr("%s: if_opensockets", __func__); + goto exit_failure; + } + #ifdef USE_SIGNALS if (eloop_signal_set_cb(ctx.eloop, dhcpcd_signals, dhcpcd_signals_len,