]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
dhcpcd.c: Fix -n opening sockets.
authorRoy Marples <roy@marples.name>
Thu, 20 Apr 2017 16:14:29 +0000 (17:14 +0100)
committerRoy Marples <roy@marples.name>
Wed, 3 May 2017 08:18:57 +0000 (09:18 +0100)
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

src/dhcpcd.c

index ac6c6ba9611fff4f652d7170329030753f4c3879..ce5fb447f7e2a722435533b803eaafb89b2a2b76 100644 (file)
@@ -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,