[ Avaa Bypassed ]




Upload:

Command:

www-data@18.218.26.136: ~ $
#!/usr/bin/perl
# sshd-lib.pl
# Common functions for the ssh daemon config file

BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();

# Get version information
if (!&read_file("$module_config_directory/version", \%version)) {
	%version = &get_sshd_version();
	}

# get_sshd_version()
# Returns a hash containing the version type, number and full version
sub get_sshd_version
{
local %version;
local $out = &backquote_command(
	&quote_path($config{'sshd_path'})." -h 2>&1 </dev/null");
if ($config{'sshd_version'}) {
	# Forced version
	$version{'type'} = 'openssh';
	$version{'number'} = $version{'full'} = $config{'sshd_version'};
	}
elsif ($out =~ /(sshd\s+version\s+([0-9\.]+))/i ||
    $out =~ /(ssh\s+secure\s+shell\s+([0-9\.]+))/i) {
	# Classic commercial SSH
	$version{'type'} = 'ssh';
	$version{'number'} = $2;
	$version{'full'} = $1;
	}
elsif ($out =~ /(OpenSSH.([0-9\.]+))/i) {
	# OpenSSH .. assume all versions are supported
	$version{'type'} = 'openssh';
	$version{'number'} = $2;
	$version{'full'} = $1;
	}
elsif ($out =~ /(Sun_SSH_([0-9\.]+))/i) {
	# Solaris 9 SSH is actually OpenSSH 2.x
	$version{'type'} = 'openssh';
	$version{'number'} = 2.0;
	$version{'full'} = $1;
	}
elsif (($out = $config{'sshd_version'}) && ($out =~ /(Sun_SSH_([0-9\.]+))/i)) {
	# Probably Solaris 10 SSHD that didn't display version.  Use it.
	$version{'type'} = 'openssh';
	$version{'number'} = 2.0;
	$version{'full'} = $1;
	}
return %version;
}

# get_sshd_config()
# Returns a reference to an array of SSHD config file options
sub get_sshd_config
{
local @rv = ( { 'dummy' => 1,
		'indent' => 0,
		'file' => $config{'sshd_config'},
		'line' => -1,
		'eline' => -1 } );
local $lnum = 0;
open(CONF, "<".$config{'sshd_config'});
while(<CONF>) {
	s/\r|\n//g;
	s/^\s*#.*$//g;
	local ($name, @values) = split(/\s+/, $_);
	if ($name) {
		local $dir = { 'name' => $name,
			       'values' => \@values,
			       'file' => $config{'sshd_config'},
			       'line' => $lnum };
		push(@rv, $dir);
		}
	$lnum++;
	}
close(CONF);
return \@rv;
}

# find_value(name, &config)
sub find_value
{
foreach $c (@{$_[1]}) {
	if (lc($c->{'name'}) eq lc($_[0])) {
		return wantarray ? @{$c->{'values'}} : $c->{'values'}->[0];
		}
	}
return wantarray ? ( ) : undef;
}

# find(value, &config)
sub find
{
local @rv;
foreach $c (@{$_[1]}) {
	if (lc($c->{'name'}) eq lc($_[0])) {
		push(@rv, $c);
		}
	}
return wantarray ? @rv : $rv[0];
}

# save_directive(name, &config, [value*|&values], [before])
sub save_directive
{
local @o = &find($_[0], $_[1]);
local @n = ref($_[2]) ?
		grep { defined($_) } @{$_[2]} :
		grep { defined($_) } @_[2..@_-1];
local $lref = &read_file_lines($_[1]->[0]->{'file'});
local $id = ("\t" x $_[1]->[0]->{'indent'});
local $i;
local $before = $_[3] && ref($_[2]) ? &find($_[3], $_[1]) : undef;
for($i=0; $i<@o || $i<@n; $i++) {
	if ($o[$i] && $n[$i]) {
		# Replacing a line
		$lref->[$o[$i]->{'line'}] = "$id$_[0] $n[$i]";
		}
	elsif ($o[$i]) {
		# Removing a line
		splice(@$lref, $o[$i]->{'line'}, 1);
		foreach $c (@{$_[1]}) {
			if ($c->{'line'} > $o[$i]->{'line'}) {
				$c->{'line'}--;
				}
			}
		}
	elsif ($n[$i] && !$before) {
		# Adding a line at the end, but before the first Match directive
		local $ll = $_[1]->[@{$_[1]}-1]->{'line'};
		foreach my $m (&find("Match", $_[1])) {
			$ll = $m->{'line'} - 1;
			last;
			}
		splice(@$lref, $ll+1, 0, "$id$_[0] $n[$i]");
		}
	elsif ($n[$i] && $before) {
		# Adding a line before the first instance of some directive
		splice(@$lref, $before->{'line'}, 0, "$id$_[0] $n[$i]");
		foreach $c (@{$_[1]}) {
			if ($c->{'line'} >= $before->{'line'}) {
				$c->{'line'}--;
				}
			}
		}
	}
}

# scmd(double)
sub scmd
{
if ($cmd_count % 2 == 0) {
	print "<tr>\n";
	}
elsif ($_[0]) {
	print "<td colspan=2></td> </tr>\n";
	print "<tr>\n";
	$cmd_count = 0;
	}
$cmd_count += ($_[0] ? 2 : 1);
}

# ecmd()
sub ecmd
{
if ($cmd_count % 2 == 0) {
	print "</tr>\n";
	}
}

# get_client_config()
# Returns a list of structures, one for each host
sub get_client_config
{
local @rv = ( { 'dummy' => 1,
		'indent' => 0,
		'file' => $config{'client_config'},
		'line' => -1,
		'eline' => -1 } );
local $host;
local $lnum = 0;
open(CLIENT, "<".$config{'client_config'});
while(<CLIENT>) {
	s/\r|\n//g;
	s/^\s*#.*$//g;
	s/^\s*//g;
	local ($name, @values) = split(/\s+/, $_);
	if (lc($name) eq 'host') {
		# Start of new host
		$host = { 'name' => $name,
			  'values' => \@values,
			  'file' => $config{'client_config'},
			  'line' => $lnum,
			  'eline' => $lnum,
			  'members' => [ { 'dummy' => 1,
					   'indent' => 1,
					   'file' => $config{'client_config'},
					   'line' => $lnum } ] };
		push(@rv, $host);
		}
	elsif ($name) {
		# A directive inside a host
		local $dir = { 'name' => $name,
			       'values' => \@values,
			       'file' => $config{'client_config'},
			       'line' => $lnum };
		push(@{$host->{'members'}}, $dir);
		$host->{'eline'} = $lnum;
		}
	$lnum++;
	}
close(CLIENT);
return \@rv;
}

# create_host(&host)
sub create_host
{
local $lref = &read_file_lines($config{'client_config'});
$_[0]->{'line'} = $_[0]->{'eline'} = scalar(@$lref);
push(@$lref, "Host ".join(" ", @{$_[0]->{'values'}}));
$_[0]->{'members'} = [ { 'dummy' => 1,
			 'indent' => 1,
			 'file' => $config{'client_config'},
			 'line' => $_[0]->{'line'} } ];
}

# modify_host(&host)
sub modify_host
{
local $lref = &read_file_lines($config{'client_config'});
$lref->[$_[0]->{'line'}] = "Host ".join(" ", @{$_[0]->{'values'}});
}

# delete_host(&host)
sub delete_host
{
local $lref = &read_file_lines($config{'client_config'});
splice(@$lref, $_[0]->{'line'}, $_[0]->{'eline'} - $_[0]->{'line'} + 1);
}

# restart_sshd()
# Re-starts the SSH server, and returns an error message on failure or
# undef on success
sub restart_sshd
{
if ($config{'restart_cmd'}) {
	local $out = `$config{'restart_cmd'} 2>&1 </dev/null`;
	return "<pre>$out</pre>" if ($?);
	}
else {
	local $pid = &get_sshd_pid();
	$pid || return $text{'apply_epid'};
	&kill_logged('HUP', $pid);
	}
return undef;
}

# stop_sshd()
# Kills the SSH server, and returns an error message on failure or
# undef on success
sub stop_sshd
{
if ($config{'stop_cmd'}) {
	local $out = `$config{'stop_cmd'} 2>&1 </dev/null`;
	return "<pre>$out</pre>" if ($?);
	}
else {
	local $pid = &get_sshd_pid();
	$pid || return $text{'apply_epid'};
	&kill_logged('TERM', $pid);
	}
return undef;
}

# start_sshd()
# Attempts to start the SSH server, returning undef on success or an error
# message on failure.
sub start_sshd
{
# Remove PID file if invalid
if (-f $config{'pid_file'} && !&check_pid_file($config{'pid_file'})) {
	&unlink_file($config{'pid_file'});
	}

if ($config{'start_cmd'}) {
	$out = &backquote_logged("$config{'start_cmd'} 2>&1 </dev/null");
	if ($?) { return "<pre>$out</pre>"; }
	}
else {
	$out = &backquote_logged("$config{'sshd_path'} 2>&1 </dev/null");
	if ($?) { return "<pre>$out</pre>"; }
	}
return undef;
}

# get_pid_file()
# Returns the SSH server PID file
sub get_pid_file
{
local $conf = &get_sshd_config();
local $pidfile = &find_value("PidFile", $conf);
$pidfile ||= $config{'pid_file'};
return $pidfile;
}

# get_sshd_pid()
# Returns the PID of the running SSHd process
sub get_sshd_pid
{
local $file = &get_pid_file();
if ($file) {
	return &check_pid_file($file);
	}
else {
	local ($rv) = &find_byname("sshd");
	return $rv;
	}
}

# get_mlvalues(file, id, [splitchar])
# Return an array with values from a file, where the
# values are one per line with an id preceding them
sub get_mlvalues
{
local @rv;
local $_;
local $split = defined($_[2]) ? $_[2] : " ";
local $realfile = &translate_filename($_[0]);
&open_readfile(ARFILE, $_[0]) || return 0;
while(<ARFILE>) {
	chomp;
	local $hash = index($_, "#");
	local $eq = index($_, $split);
	if ($hash != 0 && $eq >= 0) {
		local $n = substr($_, 0, $eq);
		local $v = substr($_, $eq+1);
		chomp($v);
		if ($n eq $_[1]) {
			push(@rv, $v);
						}
        	}
        }
close(ARFILE);
return @rv;
}

# list_syslog_facilities()
# Returns an upper-case list of syslog facility names
sub list_syslog_facilities
{
local @facils;
if (&foreign_check("syslog")) {
	local %sconfig = &foreign_config("syslog");
	@facils = map { uc($_) } split(/\s+/, $sconfig{'facilities'});
	}
if (!@facils) {
	@facils = ( 'DAEMON', 'USER', 'AUTH', 'AUTHPRIV', 'LOCAL0', 'LOCAL1', 'LOCAL2',
		    'LOCAL3', 'LOCAL4', 'LOCAL5', 'LOCAL6', 'LOCAL7' );
	}
return @facils;
}

sub list_logging_levels
{
return ('QUIET', 'FATAL', 'ERROR', 'INFO', 'VERBOSE', 'DEBUG');
}

sub yes_no_default_radio
{
local ($name, $value) = @_;
return &ui_radio($name, lc($value) eq 'yes' ? 1 :
			lc($value) eq 'no' ? 0 : 2,
		 [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ],
		   [ 2, $text{'default'} ] ]);
}

sub get_preferred_key_type
{
if ($version{'type'} eq 'openssh' && $version{'number'} >= 6.5) {
	return "ed25519";
	}
if ($version{'type'} eq 'openssh' && $version{'number'} >= 3.2) {
	return "rsa1";
	}
return undef;
}

1;


Filemanager

Name Type Size Permission Actions
help Folder 0755
images Folder 0755
lang Folder 0755
CHANGELOG File 1.04 KB 0644
apply.cgi File 233 B 0755
backup_config.pl File 892 B 0755
cgi_args.pl File 264 B 0755
config File 202 B 0644
config-AlmaLinux-8.0-ALL File 296 B 0644
config-CentOS-Stream-Linux-8.0-ALL File 296 B 0644
config-CloudLinux-8.0-ALL File 296 B 0644
config-Oracle-Linux-8.0-ALL File 296 B 0644
config-Rocky-Linux-8.0-ALL File 296 B 0644
config-Ubuntu-Linux-10.10-17.10 File 256 B 0644
config-Ubuntu-Linux-18.04-ALL File 296 B 0644
config-coherent-linux File 276 B 0644
config-debian-linux-10.0-ALL File 296 B 0644
config-debian-linux-2.2-9.0 File 264 B 0644
config-macos File 194 B 0644
config-macos-8.1-ALL File 183 B 0644
config-mandrake-linux-7.1-ALL File 258 B 0644
config-open-linux-3.1 File 276 B 0644
config-openSUSE-Linux-15.0-ALL File 296 B 0644
config-openmamba-linux File 276 B 0644
config-pardus-linux File 235 B 0644
config-redhat-linux-24.0-ALL File 296 B 0644
config-redhat-linux-7.0-23.0 File 258 B 0644
config-slackware-linux-8.0-ALL File 268 B 0644
config-sol-linux File 274 B 0644
config-solaris-10-ALL File 344 B 0644
config-solaris-9 File 205 B 0644
config-suse-linux-7.1-8.0 File 266 B 0644
config-suse-linux-8.2-ALL File 271 B 0644
config-syno-linux File 342 B 0644
config-trustix-linux File 303 B 0644
config-turbo-linux-7.0 File 276 B 0644
config-united-linux File 266 B 0644
config-windows File 267 B 0644
config.info File 479 B 0644
config.info.bg File 909 B 0644
config.info.ca File 577 B 0644
config.info.cs File 555 B 0644
config.info.de File 574 B 0644
config.info.es File 372 B 0644
config.info.eu File 597 B 0644
config.info.fa File 569 B 0644
config.info.fr File 647 B 0644
config.info.hu File 0 B 0644
config.info.it File 576 B 0644
config.info.ja File 558 B 0644
config.info.ko File 498 B 0644
config.info.nl File 598 B 0644
config.info.no File 499 B 0644
config.info.pl File 595 B 0644
config.info.ru File 488 B 0644
config.info.sk File 498 B 0644
config.info.uk File 511 B 0644
edit_access.cgi File 2.25 KB 0755
edit_host.cgi File 5.81 KB 0755
edit_keys.cgi File 1.38 KB 0755
edit_manual.cgi File 879 B 0755
edit_misc.cgi File 3.35 KB 0755
edit_net.cgi File 3.84 KB 0755
edit_sync.cgi File 934 B 0755
edit_users.cgi File 6.13 KB 0755
index.cgi File 2.61 KB 0755
install_check.pl File 370 B 0755
list_hosts.cgi File 707 B 0755
log_parser.pl File 612 B 0755
module.info File 127 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 107 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 135 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 143 B 0644
module.info.bg File 25 B 0644
module.info.bg.auto File 118 B 0644
module.info.ca File 91 B 0644
module.info.ca.auto File 13 B 0644
module.info.cs File 19 B 0644
module.info.cs.auto File 90 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 92 B 0644
module.info.de File 89 B 0644
module.info.de.auto File 13 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 164 B 0644
module.info.es File 21 B 0644
module.info.es.auto File 92 B 0644
module.info.eu File 24 B 0644
module.info.eu.auto File 81 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 147 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 92 B 0644
module.info.fr File 20 B 0644
module.info.fr.auto File 97 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 120 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 110 B 0644
module.info.hu File 30 B 0644
module.info.hu.auto File 99 B 0644
module.info.it File 19 B 0644
module.info.it.auto File 78 B 0644
module.info.ja File 22 B 0644
module.info.ja.auto File 116 B 0644
module.info.ko File 19 B 0644
module.info.ko.auto File 93 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 105 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 103 B 0644
module.info.ms File 94 B 0644
module.info.ms.auto File 13 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 94 B 0644
module.info.nl File 19 B 0644
module.info.nl.auto File 82 B 0644
module.info.no File 19 B 0644
module.info.no.auto File 82 B 0644
module.info.pl File 21 B 0644
module.info.pl.auto File 84 B 0644
module.info.pt File 0 B 0644
module.info.pt.auto File 100 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 109 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 110 B 0644
module.info.ru File 25 B 0644
module.info.ru.auto File 124 B 0644
module.info.sk File 19 B 0644
module.info.sk.auto File 84 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 99 B 0644
module.info.sv File 0 B 0644
module.info.sv.auto File 96 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 251 B 0644
module.info.tr File 0 B 0644
module.info.tr.auto File 109 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 155 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 162 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 115 B 0644
module.info.zh File 0 B 0644
module.info.zh.auto File 103 B 0644
module.info.zh_TW File 0 B 0644
module.info.zh_TW.auto File 112 B 0644
save_access.cgi File 1.87 KB 0755
save_host.cgi File 4.69 KB 0755
save_manual.cgi File 542 B 0755
save_misc.cgi File 2.53 KB 0755
save_net.cgi File 2.9 KB 0755
save_sync.cgi File 493 B 0755
save_users.cgi File 3.85 KB 0755
sshd-lib.pl File 8.73 KB 0755
start.cgi File 209 B 0755
stop.cgi File 193 B 0755
useradmin_update.pl File 1.34 KB 0755