summaryrefslogtreecommitdiff
path: root/lib/pid_output.c
diff options
context:
space:
mode:
authorgdt <gdt>2003-12-22 20:15:53 +0000
committergdt <gdt>2003-12-22 20:15:53 +0000
commitaa593d5e2638566ead1e69381e60639550991ff2 (patch)
treec865f642c1029fa47b8fc6cc86302468b9b2aef4 /lib/pid_output.c
parent47ce02a8f12134a6ba515fbf1d2b9276e39d4c06 (diff)
2003-12-22 Christian Hammers <ch@lathspell.de>
* configure.ac (and everywhere a regular file is opened for writing): use file permissions from configure rather than compiled-in umask.
Diffstat (limited to 'lib/pid_output.c')
-rw-r--r--lib/pid_output.c11
1 files changed, 10 insertions, 1 deletions
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;