Skip to content

Commit

Permalink
Fix more cases where switch_to_unix_user isn't being passed the username
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Jul 22, 2024
1 parent c8c6c3e commit c391830
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions proc/proc-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ sub safe_process_exec
close(OUTr); close(INw);

if ($_[1]) {
local @u = getpwuid($_[1]);
if (defined($_[2])) {
# switch to given UID and GID
&switch_to_unix_user(
[ undef, undef, $_[1], $_[2] ]);
[ $u[0], undef, $_[1], $_[2] ]);
}
else {
# switch to UID and all GIDs
local @u = getpwuid($_[1]);
&switch_to_unix_user(\@u);
}
}
Expand Down Expand Up @@ -346,8 +346,9 @@ sub pty_process_exec
close(STDIN); close(STDOUT); close(STDERR);
untie(*STDIN); untie(*STDOUT); untie(*STDERR);
#setpgrp(0, $$);
if ($_[1]) {
&switch_to_unix_user([ undef, undef, $_[1], $_[2] ]);
if ($uid) {
my $username = getpwuid($uid);
&switch_to_unix_user([ $username, undef, $uid, $gid ]);
}

open(STDIN, "<$tty");
Expand Down

0 comments on commit c391830

Please sign in to comment.