diff --git a/log.c b/log.c index c6e64da9a..0a5eb58b1 100644 --- a/log.c +++ b/log.c @@ -17,6 +17,7 @@ #include "util.h" #include "cr_options.h" #include "servicefd.h" +#include "security.h" #define DEFAULT_LOGFD STDERR_FILENO /* Enable timestamps if verbosity is increased from default */ @@ -191,6 +192,12 @@ int write_pidfile(int pid) return -1; } + if (cr_fchown(fd)) { + pr_perror("Can't chown pidfile %s", opts.pidfile); + close(fd); + return -1; + } + dprintf(fd, "%d", pid); close(fd); return 0;