From: Roy Marples Date: Fri, 9 Oct 2020 14:06:57 +0000 (+0100) Subject: privsep: Always try and open syslog X-Git-Tag: v9.3.1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=908b028ca6c944774454eb37e7c286d79691ecba;p=thirdparty%2Fdhcpcd.git privsep: Always try and open syslog Even if we don't print as otherwise we can't in a chroot. --- diff --git a/src/logerr.c b/src/logerr.c index 5fba91d3..ad337ba0 100644 --- a/src/logerr.c +++ b/src/logerr.c @@ -366,20 +366,24 @@ int logopen(const char *path) { struct logctx *ctx = &_logctx; + int opts = 0; /* Cache timezone */ tzset(); (void)setvbuf(stderr, ctx->log_buf, _IOLBF, sizeof(ctx->log_buf)); - if (path == NULL) { - int opts = 0; + if (!(ctx->log_opts & LOGERR_LOG)) + return 1; - if (ctx->log_opts & LOGERR_LOG_PID) - opts |= LOG_PID; - openlog(NULL, opts, LOGERR_SYSLOG_FACILITY); +#ifdef LOG_NDELAY + opts |= LOG_NDELAY; +#endif + if (ctx->log_opts & LOGERR_LOG_PID) + opts |= LOG_PID; + openlog(NULL, opts, LOGERR_SYSLOG_FACILITY); + if (path == NULL) return 1; - } #ifndef SMALL if ((ctx->log_file = fopen(path, "ae")) == NULL)