Merge branch 'master' of github.com:webmin/webmin

This commit is contained in:
iliajie
2022-11-11 10:51:02 +02:00
2 changed files with 18 additions and 5 deletions

View File

@@ -248,11 +248,11 @@ do { local $oldexit = $?;
} while($xp > 0);
}
# pty_process_exec(command, [uid, gid])
# pty_process_exec(command, [uid, gid], [force-binary-name])
# Starts the given command in a new pty and returns the pty filehandle and PID
sub pty_process_exec
{
local ($cmd, $uid, $gid) = @_;
local ($cmd, $uid, $gid, $binary) = @_;
if (&is_readonly_mode()) {
# When in readonly mode, don't run the command
$cmd = "/bin/true";
@@ -294,7 +294,12 @@ if (!$@) {
open(STDOUT, ">&".fileno($ttyfh));
open(STDERR, ">&".fileno($ttyfh));
close($ttyfh); # Already dup'd
exec($cmd);
if ($binary) {
exec $cmd $binary;
}
else {
exec($cmd);
}
print "Exec failed : $!\n";
exit 1;
}
@@ -344,7 +349,12 @@ else {
open(STDOUT, ">&$ttyfh");
open(STDERR, ">&STDOUT");
close($ptyfh);
exec($cmd);
if ($binary) {
exec $cmd $binary;
}
else {
exec($cmd);
}
print "Exec failed : $!\n";
exit 1;
}

View File

@@ -61,7 +61,10 @@ if ($config{'flavors'} == 1 ||
# Set terminal
$ENV{'TERM'} = 'xterm-256color';
chdir($dir || $uinfo[7] || "/");
my ($shellfh, $pid) = &proc::pty_process_exec($uinfo[8], $uid, $gid);
my $shell = $uinfo[8];
$shell =~ s/^.*\///;
$shell = "-".$shell;
my ($shellfh, $pid) = &proc::pty_process_exec($uinfo[8], $uid, $gid, $shell);
&reset_environment();
if (!$pid) {
&cleanup_miniserv();