From aa593d5e2638566ead1e69381e60639550991ff2 Mon Sep 17 00:00:00 2001 From: gdt Date: Mon, 22 Dec 2003 20:15:53 +0000 Subject: 2003-12-22 Christian Hammers * configure.ac (and everywhere a regular file is opened for writing): use file permissions from configure rather than compiled-in umask. --- lib/pid_output.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/pid_output.c') diff --git a/lib/pid_output.c b/lib/pid_output.c index 125ca403..2d90afca 100644 --- a/lib/pid_output.c +++ b/lib/pid_output.c @@ -32,16 +32,20 @@ pid_output (char *path) #ifndef HAVE_FCNTL FILE *fp; pid_t pid; + mask_t oldumask; pid = getpid(); + oldumask = umask(0777 & ~LOGFILE_MASK); fp = fopen (path, "w"); if (fp != NULL) { fprintf (fp, "%d\n", (int) pid); fclose (fp); + umask(oldumask); return -1; } + umask(oldumask); return pid; #else return pid_output_lock(path); @@ -57,18 +61,23 @@ pid_output_lock (char *path) pid_t pid; char buf[16]; struct flock lock; + mode_t oldumask; pid = getpid (); - fd = open (path, O_RDWR | O_CREAT, 0644); + oldumask = umask(0777 & ~LOGFILE_MASK); + zlog_err( "old umask %d %d", oldumask, 0777 & ~LOGFILE_MASK); + fd = open (path, O_RDWR | O_CREAT, LOGFILE_MASK); if (fd < 0) { zlog_err( "Can't creat pid lock file %s (%s), exit", path, strerror(errno)); + umask(oldumask); exit (-1); } else { + umask(oldumask); memset (&lock, 0, sizeof(lock)); lock.l_type = F_WRLCK; -- cgit v1.2.1