[daemon] change umask after creating pid file

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

authorJulien Cristau <julien.cristau@logilab.fr>
changesetdc16c9f7a67d
branchdefault
phasedraft
hiddenyes
parent revision#5cdfa02c4ea5 [date] Fix utcdatetime
child revision#f468f201d2c1 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 dc16c9f7a67d56127d240461d13fcba14152831f
# Parent 5cdfa02c4ea5af155a7c3fc6fdc612706db24436
[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