Merge "drop_privileges should also set HOME"

This commit is contained in:
Jenkins 2012-12-04 20:08:29 +00:00 committed by Gerrit Code Review
commit 7e8959ff0a
2 changed files with 3 additions and 0 deletions

View File

@ -756,6 +756,7 @@ def drop_privileges(user):
os.setgroups([]) os.setgroups([])
os.setgid(user[3]) os.setgid(user[3])
os.setuid(user[2]) os.setuid(user[2])
os.environ['HOME'] = user[5]
try: try:
os.setsid() os.setsid()
except OSError: except OSError:

View File

@ -632,6 +632,8 @@ log_name = %(yarr)s'''
utils.drop_privileges(user) utils.drop_privileges(user)
for func in required_func_calls: for func in required_func_calls:
self.assert_(utils.os.called_funcs[func]) self.assert_(utils.os.called_funcs[func])
import pwd
self.assertEquals(pwd.getpwnam(user)[5], utils.os.environ['HOME'])
# reset; test same args, OSError trying to get session leader # reset; test same args, OSError trying to get session leader
utils.os = MockOs(called_funcs=required_func_calls, utils.os = MockOs(called_funcs=required_func_calls,