diff --git a/swift/common/utils.py b/swift/common/utils.py index 963e3b8694..3bf207e291 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -756,6 +756,7 @@ def drop_privileges(user): os.setgroups([]) os.setgid(user[3]) os.setuid(user[2]) + os.environ['HOME'] = user[5] try: os.setsid() except OSError: diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index db5422f3b4..25a9b45226 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -632,6 +632,8 @@ log_name = %(yarr)s''' utils.drop_privileges(user) for func in required_func_calls: 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 utils.os = MockOs(called_funcs=required_func_calls,