From: Adam Dickmeiss Date: Mon, 2 Feb 2015 10:19:20 +0000 (+0100) Subject: daemon reopen flag change ownership of logfile to -u uid YAZ-819 X-Git-Tag: v5.9.0~1 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=4588c6059ab91814bcfe2da9a4c956d99ec8dc23;p=yaz-moved-to-github.git daemon reopen flag change ownership of logfile to -u uid YAZ-819 --- diff --git a/src/daemon.c b/src/daemon.c index 4448e1d..27e97db 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -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");