From: Thibault Godouet Date: Sat, 21 Apr 2001 08:39:22 +0000 (+0000) Subject: we set the umask to the value read by fcron before changing it before running a job X-Git-Tag: ver2_9_4~384 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2dc928d25314bb78daf963ddeca3273782d3077;p=thirdparty%2Ffcron.git we set the umask to the value read by fcron before changing it before running a job --- diff --git a/job.c b/job.c index 59816d9..69bf70b 100644 --- a/job.c +++ b/job.c @@ -22,7 +22,7 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: job.c,v 1.36 2001-03-02 17:50:34 thib Exp $ */ + /* $Id: job.c,v 1.37 2001-04-21 08:39:22 thib Exp $ */ #include "fcron.h" @@ -37,6 +37,9 @@ change_user(char *user_name) { struct passwd *pas; + /* First, restore umask to default */ + umask (saved_umask); + /* Obtain password entry and change privileges */ if ((pas = getpwnam(user_name)) == NULL) @@ -338,25 +341,21 @@ temp_file(void) die_e("Can't find a unique temporary filename"); #else const int max_retries = 50; - char *name; + char *name = NULL; int i; i = 0; - name = NULL; do { i++; - free(name); name = tempnam(NULL, NULL); if (name == NULL) die("Can't find a unique temporary filename"); fd = open(name, O_RDWR|O_CREAT|O_EXCL|O_APPEND,S_IRUSR|S_IWUSR); + free(name); /* I'm not sure we actually need to be so persistent here */ } while (fd == -1 && errno == EEXIST && i < max_retries); if (fd == -1) die_e("Can't open temporary file"); #endif if (unlink(name)) die_e("Can't unlink temporary file"); -#ifndef HAVE_MKSTEMP - free(name); -#endif fcntl(fd, F_SETFD,1); /* set close-on-exec flag */ return fd; }