diff options
| author | Roy Marples <roy@marples.name> | 2020-04-23 23:45:38 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-04-23 23:45:38 +0100 |
| commit | f10b3ded87b73e0d2e1018781ca874aea166eac0 (patch) | |
| tree | d2e1affc0fc70645fee5613104ef20f301ce4307 /src/dhcpcd.c | |
| parent | b18431f9b8feff00fdd9d71532c38723eaf9aad8 (diff) | |
| download | dhcpcd-f10b3ded87b73e0d2e1018781ca874aea166eac0.tar.xz | |
dhcpcd: Fix separation of per interface and per family
While here improve privsep proess titles for this.
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index fa52fdfc..06e94961 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -1751,7 +1751,7 @@ main(int argc, char **argv) struct ifaddrs *ifaddrs = NULL; struct if_options *ifo; struct interface *ifp; - uint16_t family = 0; + uint16_t family = AF_UNSPEC; int opt, oi = 0, i; unsigned int logopts, t; ssize_t len; @@ -2034,19 +2034,52 @@ printpidfile: goto exit_failure; } + if (sig != 0) { + pid = pidfile_read(ctx.pidfile); + if (pid != 0 && pid != -1) + loginfox("sending signal %s to pid %d", siga, pid); + if (pid == 0 || pid == -1 || kill(pid, sig) != 0) { + if (sig != SIGHUP && sig != SIGUSR1 && errno != EPERM) + logerrx(PACKAGE" not running"); + if (pid != 0 && pid != -1 && errno != ESRCH) { + logerr("kill"); + goto exit_failure; + } + unlink(ctx.pidfile); + if (sig != SIGHUP && sig != SIGUSR1) + goto exit_failure; + } else { + struct timespec ts; + + if (sig == SIGHUP || sig == SIGUSR1) + goto exit_success; + /* Spin until it exits */ + loginfox("waiting for pid %d to exit", pid); + ts.tv_sec = 0; + ts.tv_nsec = 100000000; /* 10th of a second */ + for(i = 0; i < 100; i++) { + nanosleep(&ts, NULL); + if (pidfile_read(ctx.pidfile) == -1) + goto exit_success; + } + logerrx("pid %d failed to exit", pid); + goto exit_failure; + } + } +#endif + /* Test against siga instead of sig to avoid gcc * warning about a bogus potential signed overflow. * The end result will be the same. */ if ((siga == NULL || i == 4 || ctx.ifc != 0) && !(ctx.options & DHCPCD_TEST)) { -#endif ctx.options |= DHCPCD_FORKED; /* avoid socket unlink */ if (!(ctx.options & DHCPCD_MASTER)) - ctx.control_fd = control_open(argv[optind], + ctx.control_fd = control_open(argv[optind], family, ctx.options & DHCPCD_DUMPLEASE); if (ctx.control_fd == -1) - ctx.control_fd = control_open(NULL, + ctx.control_fd = control_open(NULL, AF_UNSPEC, ctx.options & DHCPCD_DUMPLEASE); if (ctx.control_fd != -1) { if (!(ctx.options & DHCPCD_DUMPLEASE)) @@ -2075,42 +2108,6 @@ printpidfile: } } ctx.options &= ~DHCPCD_FORKED; -#ifdef USE_SIGNALS - } -#endif - -#ifdef USE_SIGNALS - if (sig != 0) { - pid = pidfile_read(ctx.pidfile); - if (pid != 0 && pid != -1) - loginfox("sending signal %s to pid %d", siga, pid); - if (pid == 0 || pid == -1 || kill(pid, sig) != 0) { - if (sig != SIGHUP && sig != SIGUSR1 && errno != EPERM) - logerrx(PACKAGE" not running"); - if (pid != 0 && pid != -1 && errno != ESRCH) { - logerr("kill"); - goto exit_failure; - } - unlink(ctx.pidfile); - if (sig != SIGHUP && sig != SIGUSR1) - goto exit_failure; - } else { - struct timespec ts; - - if (sig == SIGHUP || sig == SIGUSR1) - goto exit_success; - /* Spin until it exits */ - loginfox("waiting for pid %d to exit", pid); - ts.tv_sec = 0; - ts.tv_nsec = 100000000; /* 10th of a second */ - for(i = 0; i < 100; i++) { - nanosleep(&ts, NULL); - if (pidfile_read(ctx.pidfile) == -1) - goto exit_success; - } - logerrx("pid %d failed to exit", pid); - goto exit_failure; - } } if (!(ctx.options & DHCPCD_TEST)) { @@ -2128,7 +2125,6 @@ printpidfile: goto exit_failure; } } -#endif loginfox(PACKAGE "-" VERSION " starting"); freopen(_PATH_DEVNULL, "r", stdin); @@ -2211,7 +2207,7 @@ printpidfile: if (!(ctx.options & DHCPCD_TEST) && control_start(&ctx, - ctx.options & DHCPCD_MASTER ? NULL : argv[optind]) == -1) + ctx.options & DHCPCD_MASTER ? NULL : argv[optind], family) == -1) { logerr("%s: control_start", __func__); goto exit_failure; |
