# HG changeset patch # User Roy Marples # Date 1604070962 0 # Node ID 071a9ea183636cdfa05efd5c6f98839694f8b8e5 # Parent b1a3d9055662bff5461831e283138a639290faf1 log: Allow logopen to be called without logclose logclose is meant to free resources. On Linux this means that _log_prog is also free'd and once in the chroot we cannot work it out again. As such allow logopen to close what it needs to so that reopening works. diff -r b1a3d9055662 -r 071a9ea18363 src/dhcpcd.c --- a/src/dhcpcd.c Fri Oct 30 14:19:16 2020 +0000 +++ b/src/dhcpcd.c Fri Oct 30 15:16:02 2020 +0000 @@ -1426,7 +1426,6 @@ if (ps_root_logreopen(ctx) == -1) logerr("ps_root_logreopen"); } else { - logclose(); if (logopen(ctx->logfile) == -1) logerr("logopen"); } diff -r b1a3d9055662 -r 071a9ea18363 src/logerr.c --- a/src/logerr.c Fri Oct 30 14:19:16 2020 +0000 +++ b/src/logerr.c Fri Oct 30 15:16:02 2020 +0000 @@ -452,6 +452,13 @@ (void)setvbuf(stderr, ctx->log_buf, _IOLBF, sizeof(ctx->log_buf)); +#ifndef SMALL + if (ctx->log_file != NULL) { + fclose(ctx->log_file); + ctx->log_file = NULL; + } +#endif + if (ctx->log_opts & LOGERR_LOG_PID) opts |= LOG_PID; openlog(getprogname(), opts, LOGERR_SYSLOG_FACILITY); diff -r b1a3d9055662 -r 071a9ea18363 src/logerr.h --- a/src/logerr.h Fri Oct 30 14:19:16 2020 +0000 +++ b/src/logerr.h Fri Oct 30 15:16:02 2020 +0000 @@ -102,8 +102,10 @@ void logsettag(const char *); #endif +/* Can be called more than once. */ int logopen(const char *); + +/* Should only be called at program exit. */ void logclose(void); -int logreopen(void); #endif diff -r b1a3d9055662 -r 071a9ea18363 src/privsep-root.c --- a/src/privsep-root.c Fri Oct 30 14:19:16 2020 +0000 +++ b/src/privsep-root.c Fri Oct 30 15:16:02 2020 +0000 @@ -562,7 +562,6 @@ } break; case PS_LOGREOPEN: - logclose(); err = logopen(ctx->logfile); break; #ifdef AUTH