[daemon] set $HOME when dropping privileges (closes #81297)

authorJulien Cristau <julien.cristau@logilab.fr>
changeset2520ee079cb5
branchstable
phasepublic
hiddenno
parent revision#bcc33a9bdf14 Added tag logilab-common-debian-version-0.57.0-1 for changeset 3381e3bf500b
child revision#091a372460a9 [compat] use instance of the class to have a real instance method (closes: #79268)
files modified by this revision
ChangeLog
daemon.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1319533910 -7200
# Tue Oct 25 11:11:50 2011 +0200
# Branch stable
# Node ID 2520ee079cb58ae866602b41fe94a635bb61ab19
# Parent bcc33a9bdf145900eb7cfe5271256bc09e371bad
[daemon] set $HOME when dropping privileges (closes #81297)

diff --git a/ChangeLog b/ChangeLog
@@ -1,9 +1,12 @@
1  ChangeLog for logilab.common
2  ============================
3 
4 -2011-10-12  --  0.53.0
5 + --
6 +    * daemon: change $HOME after dropping privileges (closes #81297)
7 +
8 +2011-10-12  --  0.57.0
9      * only install unittest2 when python version < 2.7 (closes: #76068)
10 
11      * daemon: make pidfile world-readable (closes #75968)
12 
13      * daemon: remove unused(?) DaemonMixin class
diff --git a/daemon.py b/daemon.py
@@ -44,10 +44,11 @@
14          if ctypes.CDLL(None).initgroups(passwd.pw_name, passwd.pw_gid) < 0:
15              err = ctypes.c_int.in_dll(ctypes.pythonapi,"errno").value
16              raise OSError(err, os.strerror(err), 'initgroups')
17      os.setgid(passwd.pw_gid)
18      os.setuid(passwd.pw_uid)
19 +    os.putenv('HOME', passwd.pw_dir)
20 
21 
22  def daemonize(pidfile=None, uid=None, umask=077):
23      """daemonize a Unix process. Set paranoid umask by default.
24