diff options
| author | Roy Marples <roy@marples.name> | 2020-01-21 16:11:37 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-01-21 16:11:37 +0000 |
| commit | 18043c2fba9868086534f99b072a7ef7f53a547f (patch) | |
| tree | bf13f7c1ff34f1b617a7202d6b10eac2a66df100 /src/dhcpcd.c | |
| parent | 068e30162ae3259a5325ab90810332dbfad19881 (diff) | |
| download | dhcpcd-18043c2fba9868086534f99b072a7ef7f53a547f.tar.xz | |
privsep: Close stdout/stderr after forking processes
Well, redirect them to /dev/null anyway.
Also tidy a few things in common whilst here.
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 31e21a5d..f437977b 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -41,6 +41,7 @@ const char dhcpcd_copyright[] = "Copyright (c) 2006-2020 Roy Marples"; #include <fcntl.h> #include <getopt.h> #include <limits.h> +#include <paths.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -352,7 +353,8 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx) eloop_event_delete(ctx->eloop, ctx->fork_fd); close(ctx->fork_fd); ctx->fork_fd = -1; - close_std(); + freopen(_PATH_DEVNULL, "w", stdout); + freopen(_PATH_DEVNULL, "w", stderr); #endif } @@ -611,7 +613,7 @@ configure_interface(struct interface *ifp, int argc, char **argv, /* If the mtime has changed drop any old lease */ if (old != 0 && ifp->options->mtime != old) { - logwarnx("%s: confile file changed, expiring leases", + logwarnx("%s: config file changed, expiring leases", ifp->name); dhcpcd_drop(ifp, 0); } @@ -2009,6 +2011,7 @@ printpidfile: #endif logdebugx(PACKAGE "-" VERSION " starting"); + freopen(_PATH_DEVNULL, "r", stdin); #ifdef PRIVSEP if (ps_init(&ctx) == -1 && errno != 0) { |
