drop_privileges should also set HOME
E.g. if HOME is not set, swift-proxy will create the keystone_signing file not in HOME but in /root. This is because the swift user doesn't have a shell in /etc/passwd and so it doesn't set environment variables when impersonating. Change-Id: I3013007e0dadf6ddccc176e142b7c78c5d63a351
This commit is contained in:
parent
8a6922b73e
commit
772da0a004
@ -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:
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user