Mercurial > hg > dhcpcd
diff src/dhcpcd.c @ 5526:b1a3d9055662 draft
privsep: Allow logfile reopening in a chroot
Now that only the privileged actioneer does the actual logging
we can safely reopen the file we are logging to.
This also closes and re-opens the syslog connection.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 30 Oct 2020 14:19:16 +0000 |
| parents | 26b5d9bc2985 |
| children | 071a9ea18363 |
line wrap: on
line diff
--- a/src/dhcpcd.c Fri Oct 30 03:43:51 2020 +0000 +++ b/src/dhcpcd.c Fri Oct 30 14:19:16 2020 +0000 @@ -1422,10 +1422,14 @@ return; case SIGUSR2: loginfox(sigmsg, "SIGUSR2", "reopening log"); - /* XXX This may not work that well in a chroot */ - logclose(); - if (logopen(ctx->logfile) == -1) - logerr(__func__); + if (IN_PRIVSEP(ctx)) { + if (ps_root_logreopen(ctx) == -1) + logerr("ps_root_logreopen"); + } else { + logclose(); + if (logopen(ctx->logfile) == -1) + logerr("logopen"); + } return; case SIGCHLD: while (waitpid(-1, NULL, WNOHANG) > 0) @@ -1860,7 +1864,7 @@ ctx.dhcp6_wfd = -1; #endif #ifdef PRIVSEP - ctx.ps_root_fd = ctx.ps_syslog_fd = ctx.ps_data_fd = -1; + ctx.ps_root_fd = ctx.ps_log_fd = ctx.ps_data_fd = -1; ctx.ps_inet_fd = ctx.ps_control_fd = -1; TAILQ_INIT(&ctx.ps_processes); #endif @@ -2328,6 +2332,7 @@ /* We have now forked, setsid, forked once more. * From this point on, we are the controlling daemon. */ ctx.options |= DHCPCD_STARTED; + logdebugx("spawned master process on PID %d", getpid()); if ((pid = pidfile_lock(ctx.pidfile)) != 0) { logerr("%s: pidfile_lock %d", __func__, pid); #ifdef PRIVSEP
