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

This commit is contained in:
Jamie Cameron
2024-07-22 16:11:37 -07:00
parent 2751224d4d
commit c1f45d6d61

View File

@ -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