]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Always try and open syslog
authorRoy Marples <roy@marples.name>
Fri, 9 Oct 2020 14:06:57 +0000 (15:06 +0100)
committerRoy Marples <roy@marples.name>
Fri, 9 Oct 2020 14:06:57 +0000 (15:06 +0100)
Even if we don't print as otherwise we can't in a chroot.

src/logerr.c

index 5fba91d33c58a365117f45a1edc41724d1838e78..ad337ba060dcfa014359cb1259e7951ba2249ad4 100644 (file)
@@ -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)