summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Cristau <julien.cristau@logilab.fr>2014-11-28 14:13:54 +0100
committerJulien Cristau <julien.cristau@logilab.fr>2014-11-28 14:13:54 +0100
commit6da786adbb6f7ad3e2d8bd31db6151778a08685b (patch)
tree397261e3a007e8e099a0a0cf05d342ff558e64eb
parentadabb02f93efa946e245c68c34281216e07fabbc (diff)
downloadlogilab-common-6da786adbb6f7ad3e2d8bd31db6151778a08685b.tar.gz
[daemon] change umask after creating pid file
No reason to hide the pid file / dir behind restrictive permissions.
-rw-r--r--daemon.py7
1 files 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)