diff options
| author | Roy Marples <roy@marples.name> | 2020-01-09 15:39:18 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-01-09 15:39:18 +0000 |
| commit | a7ae35c4cc3bb69d07dade7bac79120e85eb6408 (patch) | |
| tree | 7c46914cbb6cd890425477524c52ad5d3b06bb30 /src/dhcpcd.c | |
| parent | 7f26a3de371a7818f91205bf615fde90a88614a8 (diff) | |
| download | dhcpcd-a7ae35c4cc3bb69d07dade7bac79120e85eb6408.tar.xz | |
privsep: Delay control startup after starting privsep
This means we don't need to close it for other processes.
Add ps_init so that we can change directory permissions before
starting privsep itself.
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index d2b205ab..13376b92 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -1917,7 +1917,6 @@ printpidfile: if (ctx.control_fd != -1) { loginfox("sending commands to master dhcpcd process"); len = control_send(&ctx, argc, argv); - control_close(&ctx); if (len > 0) { logdebugx("send OK"); goto exit_success; @@ -1989,6 +1988,13 @@ printpidfile: logdebugx(PACKAGE "-" VERSION " starting"); +#ifdef PRIVSEP + if (ps_init(&ctx) == -1 && errno != 0) { + logerr("ps_init"); + goto exit_failure; + } +#endif + #ifdef USE_SIGNALS if (pipe(sigpipe) == -1) { logerr("pipe"); @@ -2038,18 +2044,6 @@ printpidfile: } #endif - if (control_start(&ctx, - ctx.options & DHCPCD_MASTER ? NULL : argv[optind]) == -1) - { - logerr("%s: control_start", __func__); - goto exit_failure; - } - - setproctitle("%s%s%s", - ctx.options & DHCPCD_MASTER ? "[master]" : argv[optind], - ctx.options & DHCPCD_IPV4 ? " [ip4]" : "", - ctx.options & DHCPCD_IPV6 ? " [ip6]" : ""); - #ifdef BSD /* Disable the kernel RTADV sysctl as early as possible. */ if (ctx.options & DHCPCD_IPV6 && ctx.options & DHCPCD_IPV6RS) @@ -2057,7 +2051,7 @@ printpidfile: #endif #ifdef PRIVSEP - if (ps_start(&ctx) == -1 && errno != 0) { + if (ctx.options & DHCPCD_PRIVSEP && ps_start(&ctx) == -1) { logerr("ps_start"); goto exit_failure; } @@ -2065,6 +2059,18 @@ printpidfile: goto run_loop; #endif + if (control_start(&ctx, + ctx.options & DHCPCD_MASTER ? NULL : argv[optind]) == -1) + { + logerr("%s: control_start", __func__); + goto exit_failure; + } + + setproctitle("%s%s%s", + ctx.options & DHCPCD_MASTER ? "[master]" : argv[optind], + ctx.options & DHCPCD_IPV4 ? " [ip4]" : "", + ctx.options & DHCPCD_IPV6 ? " [ip6]" : ""); + if (if_opensockets(&ctx) == -1) { logerr("%s: if_opensockets", __func__); goto exit_failure; |
