summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Dykstra <dwd@samba.org>1999-03-24 16:39:07 +0000
committerDavid Dykstra <dwd@samba.org>1999-03-24 16:39:07 +0000
commitad517ce5b33eb59873ec8468af704f43867cd8cb (patch)
treec8104c1ee9823f380d939ce28225e0e7c6edf03f
parent1f8413449dc6430e59b7383c25454de72503f007 (diff)
downloadrsync-ad517ce5b33eb59873ec8468af704f43867cd8cb.tar.gz
The "pid file" was getting created mode 666, not applying the umask
because at that point in the program the umask is set to 0. Now creating the file with mode (666 & ~orig_umask).
-rw-r--r--clientserver.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/clientserver.c b/clientserver.c
index 9e79538e..ace360b4 100644
--- a/clientserver.c
+++ b/clientserver.c
@@ -417,6 +417,7 @@ static int start_daemon(int fd)
int daemon_main(void)
{
extern char *config_file;
+ extern int orig_umask;
char *pid_file;
if (is_a_socket(STDIN_FILENO)) {
@@ -447,16 +448,19 @@ int daemon_main(void)
rprintf(FINFO,"rsyncd version %s starting\n",VERSION);
if (((pid_file = lp_pid_file()) != NULL) && (*pid_file != '\0')) {
- FILE *f;
+ char pidbuf[16];
+ int fd;
int pid = (int) getpid();
cleanup_set_pid(pid);
- if ((f = fopen(lp_pid_file(), "w")) == NULL) {
+ if ((fd = do_open(lp_pid_file(), O_WRONLY|O_CREAT|O_TRUNC,
+ 0666 & ~orig_umask)) == -1) {
cleanup_set_pid(0);
fprintf(stderr,"failed to create pid file %s\n", pid_file);
exit_cleanup(RERR_FILEIO);
}
- fprintf(f, "%d\n", pid);
- fclose(f);
+ slprintf(pidbuf, sizeof(pidbuf), "%d\n", pid);
+ write(fd, pidbuf, strlen(pidbuf));
+ close(fd);
}
start_accept_loop(rsync_port, start_daemon);