daemon reopen flag change ownership of logfile to -u uid YAZ-819
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 2 Feb 2015 10:19:20 +0000 (11:19 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 2 Feb 2015 10:19:20 +0000 (11:19 +0100)
src/daemon.c

index 4448e1d..27e97db 100644 (file)
@@ -261,6 +261,15 @@ int yaz_daemon(const char *progname,
             yaz_log(YLOG_FATAL, "%s: Unknown user", uid);
             exit(1);
         }
+        if (flags & YAZ_DAEMON_LOG_REOPEN)
+        {
+            FILE *f = yaz_log_file();
+            if (f)
+            {
+                if (fchown(fileno(f), pw->pw_uid, -1))
+                    yaz_log(YLOG_WARN|YLOG_ERRNO, "fchown logfile");
+            }
+        }
         if (setuid(pw->pw_uid) < 0)
         {
             yaz_log(YLOG_FATAL|YLOG_ERRNO, "setuid");