From df2b72ada581c0c61b8f6deea6e2c0884dd87c27 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Tue, 15 Feb 2011 02:46:28 +0000 Subject: [PATCH] * Old PID files are already checked via checkforrunning() and exits if process found so we don't need O_EXCL in writepidfile() and can instead just overwrite. Also fix permissions as well to not give world write access. Thanks to Alan Swanson. --- daemonize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemonize.c b/daemonize.c index bf7bd40..b1bfe9c 100644 --- a/daemonize.c +++ b/daemonize.c @@ -93,7 +93,7 @@ writepidfile(const char * fname, int pid) if(!fname || (strlen(fname) == 0)) return -1; - if( (pidfile = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0) + if( (pidfile = open(fname, O_WRONLY|O_CREAT, 0644)) < 0) { DPRINTF(E_ERROR, L_GENERAL, "Unable to open pidfile for writing %s: %s\n", fname, strerror(errno)); return -1;