diff options
| author | Roy Marples <roy@marples.name> | 2019-11-29 13:55:46 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-11-29 13:55:46 +0000 |
| commit | c920247719ccbe2a0297a5467f04f459eb052398 (patch) | |
| tree | 54368294ead2aa4b2f9eef4ca84a22a9fa767307 /src/privsep.c | |
| parent | e91451a20d134ff9e3b22cc398341b94e5e2904b (diff) | |
| download | dhcpcd-c920247719ccbe2a0297a5467f04f459eb052398.tar.xz | |
privsep: Use another eloop instead of a blocking read.
We need to read the error status from making a privileged request.
This happens in an eloop already, but the read itself needs to block.
So that we can still be interupted, use an inner eloop whose sole
purpose is to monitor the root fd for message back. Then we can
make the fd non blocking.
dhcpcd should now exit cleanly once more.
Diffstat (limited to 'src/privsep.c')
| -rw-r--r-- | src/privsep.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/privsep.c b/src/privsep.c index 70ce5a42..1ef46873 100644 --- a/src/privsep.c +++ b/src/privsep.c @@ -121,11 +121,7 @@ ps_dostart(struct dhcpcd_ctx *ctx, } create_sp: - stype = SOCK_CLOEXEC; - /* ps_root_fd needs to be a blocking socket so we can read - * the result of the command sent. */ - if (priv_fd != &ctx->ps_root_fd) - stype |= SOCK_NONBLOCK; + stype = SOCK_CLOEXEC | SOCK_NONBLOCK; if (socketpair(AF_UNIX, SOCK_DGRAM | stype, 0, fd) == -1) { logerr("socketpair"); return -1; @@ -312,10 +308,10 @@ ps_stop(struct dhcpcd_ctx *ctx) if (ctx->options & DHCPCD_FORKED || ctx->eloop == NULL) return 0; - r = ps_root_stop(ctx); + r = ps_inet_stop(ctx); if (r != 0) ret = r; - r = ps_inet_stop(ctx); + r = ps_root_stop(ctx); if (r != 0) ret = r; |
