Mercurial > hg > dhcpcd
changeset 5506:9c7bd8bd8729 draft
privsep: Always try and open syslog
Even if we don't print as otherwise we can't in a chroot.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 09 Oct 2020 15:06:57 +0100 |
| parents | 5aedb51585b6 |
| children | 78f2fda6ee5d |
| files | src/logerr.c |
| diffstat | 1 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/logerr.c Fri Oct 09 14:45:57 2020 +0100 +++ b/src/logerr.c Fri Oct 09 15:06:57 2020 +0100 @@ -366,20 +366,24 @@ 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)
