From 88d1d9397270c4ae4472a646f14041207d2a93be Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Fri, 7 Jun 2024 11:59:33 +0100 Subject: [PATCH] [global][utilities] Move the chdir after the runas If the chdir would have been set as well as runas, the chdir would not have taken effect, so updating to reflect the correct behaviour Related: #3648 Signed-off-by: Arif Ali --- sos/utilities.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sos/utilities.py b/sos/utilities.py index 535e3d336c..a69536b309 100644 --- a/sos/utilities.py +++ b/sos/utilities.py @@ -231,12 +231,12 @@ def sos_get_command_output(command, timeout=TIMEOUT_DEFAULT, stderr=False, def _child_prep_fn(): if chroot and chroot != '/': os.chroot(chroot) - if (chdir): - os.chdir(chdir) if runas: os.setgid(pwd.getpwnam(runas).pw_gid) os.setuid(pwd.getpwnam(runas).pw_uid) os.chdir(pwd.getpwnam(runas).pw_dir) + if (chdir): + os.chdir(chdir) def _check_poller(proc): if poller() or proc.poll() == 124: