From c1f45d6d611db9bab39b69eb93151995a8337dce Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Mon, 22 Jul 2024 16:11:37 -0700 Subject: [PATCH] When running a command as a different user, the username needs to be passed to switch_to_unix_user so that all the secondary groups can be populated https://github.com/webmin/webmin/issues/2223 --- proc/proc-lib.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/proc/proc-lib.pl b/proc/proc-lib.pl index 5aa195232..d59f594b9 100755 --- a/proc/proc-lib.pl +++ b/proc/proc-lib.pl @@ -286,8 +286,9 @@ if (!$@) { close(STDIN); close(STDOUT); close(STDERR); untie(*STDIN); untie(*STDOUT); untie(*STDERR); - if ($_[1]) { - &switch_to_unix_user([ undef, undef, $_[1], $_[2] ]); + if ($uid) { + my $username = getpwuid($uid); + &switch_to_unix_user([ $username, undef, $uid, $gid ]); } close($ptyfh); # Used by other side only