Private
Server IP : 195.201.23.43  /  Your IP : 18.191.239.71
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/webmin/status/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/status/rssh-monitor.pl
# rssh-monitor.pl
# Test a host by attempting to SSH into it

sub get_rssh_status
{
# Run the SSH command
&foreign_require("proc", "proc-lib.pl");
local $ruser = $_[0]->{'ruser'} || "root";
local ($fh, $fpid) = &proc::pty_process_exec(
	"ssh ".
	($_[0]->{'port'} ? "-p ".quotemeta($_[0]->{'port'})." " : "").
	quotemeta($ruser)."\@".
	quotemeta($_[0]->{'host'})." echo ok");
local ($out, $wrong_password, $connect_failed, $got_password);
while(1) {
	local $rv = &wait_for($fh, "password:|passphrase.*:", "yes\\/no", "(^|\\n)\\s*Permission denied.*\n", "ssh: connect.*\n", ".*\n");
	$out .= $wait_for_input;
	if ($rv == 0) {
		if ($_[0]->{'rpass'} eq '*') {
			# We got to the password phase, but aren't logging in
			$got_password = 1;
			last;
			}
		else {
			syswrite($fh, "$_[0]->{'rpass'}\n");
			}
		}
	elsif ($rv == 1) {
		syswrite($fh, "yes\n");
		}
	elsif ($rv == 2) {
		$wrong_password++;
		last;
		}
	elsif ($rv == 3) {
		$connect_failed++;
		}
	elsif ($rv < 0) {
		last;
		}
	}
close($fh);
kill('KILL', $fpid);
local $got = waitpid($fpid, 0);
if ($got_password) {
	return { 'up' => 1 };
	}
elsif ($wrong_password) {
	return { 'up' => 0,
		 'desc' => $text{'rssh_wrongpass'} };
	}
if ($connect_failed) {
	return { 'up' => 0,
		 'desc' => $text{'rssh_failed'} };
	}
if ($?) {
	return { 'up' => 0,
		 'desc' => $text{'rssh_error'} };
	}
return { 'up' => 1 };

}

sub show_rssh_dialog
{
print &ui_table_row($text{'rssh_host'},
		    &ui_textbox("host", $_[0]->{'host'}, 50), 3);

print &ui_table_row($text{'rssh_port'},
		    &ui_opt_textbox("port", $_[0]->{'port'}, 6,
				    $text{'default'}), 3);

print &ui_table_row($text{'rssh_ruser'},
		    &ui_textbox("ruser", $_[0]->{'ruser'}, 50), 3);

local $pmode = $_[0]->{'rpass'} eq '' ? 1 :
	       $_[0]->{'rpass'} eq '*' ? 2 : 0;
print &ui_table_row($text{'rssh_rpass'},
		    &ui_radio("rpass_def", $pmode,
		      [ [ 1, $text{'rssh_nopass'}."<br>" ],
			[ 2, $text{'rssh_nologin'}."<br>" ],
			[ 0, $text{'rssh_haspass'}." ".
			     &ui_textbox("rpass",
				$rpmode == 0 ? $_[0]->{'rpass'} : "", 30) ] ]));
}

sub parse_rssh_dialog
{
&has_command("ssh") || &error($text{'rssh_ecmd'});
&foreign_installed("proc") || &error($text{'rssh_eproc'});
$in{'host'} =~ /^[a-z0-9\.\-\_]+$/i || &error($text{'rssh_ehost'});
$_[0]->{'host'} = $in{'host'};
if ($in{'port_def'}) {
	delete($_[0]->{'port'});
	}
else {
	$in{'port'} =~ /^[1-9][0-9]*$/ || &error($text{'rssh_eport'});
	$_[0]->{'port'} = $in{'port'};
	}
$in{'rpass_def'} == 2 || $in{'ruser'} =~ /\S/ || &error($text{'rssh_eruser'});
$_[0]->{'ruser'} = $in{'ruser'};
$_[0]->{'rpass'} = $in{'rpass_def'} == 1 ? undef :
		   $in{'rpass_def'} == 2 ? '*' :
					   $in{'rpass'};
}

Private