From 32a7a1f2be8e517189e7f9d599deaf681785a32f Mon Sep 17 00:00:00 2001 From: Dong Zhang Date: Thu, 9 Jul 2026 09:12:33 +0200 Subject: [PATCH] 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 --- zuul/cmd/executor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zuul/cmd/executor.py b/zuul/cmd/executor.py index bb223b6663..2d0e901c56 100755 --- a/zuul/cmd/executor.py +++ b/zuul/cmd/executor.py @@ -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()