summaryrefslogtreecommitdiffstats
path: root/src/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2017-04-20 17:14:29 +0100
committerRoy Marples <roy@marples.name>2017-05-03 09:18:57 +0100
commit17793702f2a35126fe81d782034d40bf40d132c7 (patch)
tree4c4d44d724369267c0e0497be9ab7d2c4e28b155 /src/dhcpcd.c
parent0658f2c585850c9ea7e83e63a723360b614376d2 (diff)
downloaddhcpcd-17793702f2a35126fe81d782034d40bf40d132c7.tar.xz
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
Diffstat (limited to 'src/dhcpcd.c')
-rw-r--r--src/dhcpcd.c19
1 files changed, 9 insertions, 10 deletions
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,