mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Turn off echoing of commands run via ptys, if we can
This commit is contained in:
@@ -273,16 +273,22 @@ if (!$@) {
|
||||
if (!$ptyfh) {
|
||||
&error("Failed to create new PTY with IO::Pty");
|
||||
}
|
||||
local $ttyfh = $ptyfh->slave();
|
||||
local $tty = $ptyfh->ttyname();
|
||||
local $pid = fork();
|
||||
if (!$pid) {
|
||||
local $ttyfh = $ptyfh->slave();
|
||||
local $tty = $ptyfh->ttyname();
|
||||
if (defined(&close_controlling_pty)) {
|
||||
&close_controlling_pty();
|
||||
}
|
||||
setsid(); # create a new session group
|
||||
$ptyfh->make_slave_controlling_terminal();
|
||||
|
||||
# Turn off echoing, if we can
|
||||
eval "use IO::Stty";
|
||||
if (!$@) {
|
||||
IO::Stty::stty($ttyfh, 'raw', '-echo');
|
||||
}
|
||||
|
||||
close(STDIN); close(STDOUT); close(STDERR);
|
||||
untie(*STDIN); untie(*STDOUT); untie(*STDERR);
|
||||
if ($_[1]) {
|
||||
@@ -290,10 +296,11 @@ if (!$@) {
|
||||
($>, $<) = ($_[1], $_[1]);
|
||||
}
|
||||
|
||||
open(STDIN, "<$tty");
|
||||
open(STDOUT, ">$tty");
|
||||
open(STDERR, ">&STDOUT");
|
||||
close($ptyfh);
|
||||
close($ptyfh); # Used by other side only
|
||||
open(STDIN, "<&".fileno($ttyfh));
|
||||
open(STDOUT, ">&".fileno($ttyfh));
|
||||
open(STDERR, ">&".fileno($ttyfh));
|
||||
close($ttyfh); # Already dup'd
|
||||
exec($cmd);
|
||||
print "Exec failed : $!\n";
|
||||
exit 1;
|
||||
@@ -323,6 +330,12 @@ else {
|
||||
open($ttyfh, "+<$tty") || &error("Failed to open $tty : $!");
|
||||
}
|
||||
|
||||
# Turn off echoing, if we can
|
||||
eval "use IO::Stty";
|
||||
if (!$@) {
|
||||
IO::Stty::stty($ttyfh, 'raw', '-echo');
|
||||
}
|
||||
|
||||
if (defined(&open_controlling_pty)) {
|
||||
&open_controlling_pty($ptyfh, $ttyfh, $pty, $tty);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user