Fix regressions in cgroup implementation
Two issues noticed when testing cgroup implementation: 1. Logging is not yet configured when dropPrivs() is called, so use print() instead of self.log.info(). 2. Environment variables need to be updated when reducing privileges to another user. Otherwise it failes ansible check in start up even if the ansible versions has been installed. Change-Id: I8f235298ec3405551feb6518ce526e6cc059c502
This commit is contained in:
1 parent
b4af233dde
commit
32a7a1f2be
1 file changed
+6
-1
@@ -87,7 +87,7 @@ class Executor(zuul.cmd.ZuulDaemonApp):
|
||||
if os.getuid() != 0:
|
||||
return
|
||||
|
||||
self.log.info("Changing to user %s", user)
|
||||
print(f"Changing to user {user}")
|
||||
pw = pwd.getpwnam(user)
|
||||
|
||||
# Change owner on our pid file so it can be removed by us after
|
||||
@@ -101,6 +101,11 @@ class Executor(zuul.cmd.ZuulDaemonApp):
|
||||
os.setuid(pw.pw_uid)
|
||||
os.umask(0o022)
|
||||
|
||||
# Update environment to reflect the new user
|
||||
os.environ['HOME'] = pw.pw_dir
|
||||
os.environ['USER'] = pw.pw_name
|
||||
os.environ['LOGNAME'] = pw.pw_name
|
||||
|
||||
def run(self):
|
||||
self.handleCommands()
|
||||
|
||||
|
||||
Reference in new issue
Block a user