[daemon] change umask after creating pid file

No reason to hide the pid file / dir behind restrictive permissions.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset33bd3d623d2b
branchdefault
phasepublic
hiddenno
parent revision#123b72695560 [date] Fix utcdatetime
child revision#f9fd7e96e9bd Fix python3 syntax errors
files modified by this revision
daemon.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1417180434 -3600
# Fri Nov 28 14:13:54 2014 +0100
# Node ID 33bd3d623d2b90e07bba247bef52c844467ad0a5
# Parent 123b72695560acdabcbf4af77ccc36ea0a24e972
[daemon] change umask after creating pid file

No reason to hide the pid file / dir behind restrictive permissions.

diff --git a/daemon.py b/daemon.py
@@ -69,13 +69,10 @@
1      # terminal.
2      if os.fork():   # launch child again.
3          return 2
4      # move to the root to avoit mount pb
5      os.chdir('/')
6 -    # set umask if specified
7 -    if umask is not None:
8 -        os.umask(umask)
9      # redirect standard descriptors
10      null = os.open('/dev/null', os.O_RDWR)
11      for i in range(3):
12          try:
13              os.dup2(null, i)
@@ -93,10 +90,12 @@
14          if not os.path.exists(piddir):
15              os.makedirs(piddir)
16          f = file(pidfile, 'w')
17          f.write(str(os.getpid()))
18          f.close()
19 -        os.chmod(pidfile, 0644)
20 +    # set umask if specified
21 +    if umask is not None:
22 +        os.umask(umask)
23      # change process uid
24      if uid:
25          setugid(uid)
26      return None