From 6da786adbb6f7ad3e2d8bd31db6151778a08685b Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Fri, 28 Nov 2014 14:13:54 +0100 Subject: [daemon] change umask after creating pid file No reason to hide the pid file / dir behind restrictive permissions. --- daemon.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/daemon.py b/daemon.py index 6324b20..2f2caea 100644 --- a/daemon.py +++ b/daemon.py @@ -71,9 +71,6 @@ def daemonize(pidfile=None, uid=None, umask=077): return 2 # move to the root to avoit mount pb os.chdir('/') - # set umask if specified - if umask is not None: - os.umask(umask) # redirect standard descriptors null = os.open('/dev/null', os.O_RDWR) for i in range(3): @@ -95,7 +92,9 @@ def daemonize(pidfile=None, uid=None, umask=077): f = file(pidfile, 'w') f.write(str(os.getpid())) f.close() - os.chmod(pidfile, 0644) + # set umask if specified + if umask is not None: + os.umask(umask) # change process uid if uid: setugid(uid) -- cgit v1.2.1