[ Avaa Bypassed ]




Upload:

Command:

www-data@3.20.221.0: ~ $
# An OpenSLP webmin module
# by Monty Charlton <monty@caldera.com>,
#
# Copyright (c) 2000 Caldera Systems
#
# Permission to use, copy, modify, and distribute this software and its
# documentation under the terms of the GNU General Public License is hereby 
# granted. No representations are made about the suitability of this software 
# for any purpose. It is provided "as is" without express or implied warranty.
# See the GNU General Public License for more details.
#

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

#$config_file = "./config-$gconfig{'os_type'}";
$config_file = "$module_config_directory/config";
$config = &parse_config_file;

# get_snda_config()
sub get_snda_config
{
local $snda;
flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
while(<SLP>) {
	s/\r|\n//g;
	if (/^(\s|#|;)*net.slp.useScopes\s*=\s*(.*)/) {
		push(@{$snda->{'useScopes'}}, split(/\s*,\s*/, $2));
		$snda->{'useScopesDisabled'}++ if ($1 =~ /;|#/);
		}
	elsif (/^(\s|#|;)*net.slp.DAAddresses\s*=\s*(.*)/) {
		push(@{$snda->{'DAAddresses'}}, split(/\s*,\s*/, $2));
		$snda->{'DAAddressesDisabled'}++ if ($1 =~ /;|#/);
		}
	}
close(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
return $snda;
}

# get_netcfg_config()
sub get_netcfg_config
{
local $netcfg;
flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
while(<SLP>) {
        s/\r|\n//g;
        if (/^(\s|#|;)*net.slp.isBroadcastOnly\s*=\s*(\S+)/) {
                $netcfg->{'isBroadcastOnly'} = $2;
                $netcfg->{'isBroadcastOnlyDisabled'}++ if ($1 =~ /;|#/);
                }
        elsif (/^(\s|#|;)*net.slp.passiveDADetection\s*=\s*(\S+)/) {
                $netcfg->{'passiveDADetection'} = $2;
                $netcfg->{'passiveDADetectionDisabled'}++ if ($1 =~ /;|#/);
                }
        elsif (/^(\s|#|;)*net.slp.activeDADetection\s*=\s*(\S+)/) {
                $netcfg->{'activeDADetection'} = $2;
                $netcfg->{'activeDADetectionDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.DAActiveDiscoveryInterval\s*=\s*(\S+)/) {
		$netcfg->{'DAActiveDiscoveryInterval'} = $2;
		$netcfg->{'DAActiveDiscoveryIntervalDisabled'}++ if ($1 =~ /;|#/);
		}
	elsif (/^(\s|#|;)*net.slp.multicastTTL\s*=\s*(\S+)/) {
                $netcfg->{'multicastTTL'} = $2;
                $netcfg->{'multicastTTLDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.DADiscoveryMaximumWait\s*=\s*(\S+)/) {
                $netcfg->{'DADiscoveryMaximumWait'} = $2;
                $netcfg->{'DADiscoveryMaximumWaitDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.DADiscoveryTimeouts\s*=\s*(.*)/) {
                push(@{$netcfg->{'DADiscoveryTimeouts'}}, split(/\s*,\s*/, $2));
                $netcfg->{'DADiscoveryTimeoutsDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.HintsFile\s*=\s*(\S+)/) {
                $netcfg->{'HintsFile'} = $2;
                $netcfg->{'HintsFileDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.multicastMaximumWait\s*=\s*(\S+)/) {
                $netcfg->{'multicastMaximumWait'} = $2;
                $netcfg->{'multicastMaximumWaitDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.multicastTimeouts\s*=\s*(.*)/) {
                push(@{$netcfg->{'multicastTimeouts'}}, split(/\s*,\s*/, $2));
                $netcfg->{'multicastTimeoutsDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.unicastMaximumWait\s*=\s*(\S+)/) {
                $netcfg->{'unicastMaximumWait'} = $2;
                $netcfg->{'unicastMaximumWaitDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.randomWaitBound\s*=\s*(\S+)/) {
                $netcfg->{'randomWaitBound'} = $2;
                $netcfg->{'randomWaitBoundDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net.slp.MTU\s*=\s*(\S+)/) {
                $netcfg->{'MTU'} = $2;
                $netcfg->{'MTUDisabled'}++ if ($1 =~ /;|#/);
                }
	elsif (/^(\s|#|;)*net\.slp\.interfaces\s*=\s*(.*)/) {
                push(@{$netcfg->{'interfaces'}}, split(/\s*,\s*/, $2));
                $netcfg->{'interfacesDisabled'}++ if ($1 =~ /;|#/);
                }
        }
close(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
return $netcfg;
} 

# get_dacfg_config()
sub get_dacfg_config
{
local $dacfg;
flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
while(<SLP>) {
	s/\r|\n//g;
	if (/^(\s|#|;)*net.slp.isDA\s*=\s*(\S+)/) {
		$dacfg->{'isDA'} = $2;
		$dacfg->{'isDADisabled'}++ if ($1 =~ /;|#/);
		}
	}
close(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
return $dacfg;
}

# get_log_config()
sub get_log_config
{
local $log;
flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
while(<SLP>) {
	s/\r|\n//g;
	if (/^(\s|#|;)*net.slp.traceDATraffic\s*=\s*(\S+)/) {
		$dacfg->{'traceDATraffic'} = $2;
		$dacfg->{'traceDATrafficDisabled'}++ if ($1 =~ /;|#/);
		}
	elsif (/^(\s|#|;)*net.slp.traceMsg\s*=\s*(\S+)/) {
		$dacfg->{'traceMsg'} = $2;
		$dacfg->{'traceMsgDisabled'}++ if ($1 =~ /;|#/);
		}
	elsif (/^(\s|#|;)*net.slp.traceDrop\s*=\s*(\S+)/) {
		$dacfg->{'traceDrop'} = $2;
		$dacfg->{'traceDropDisabled'}++ if ($1 =~ /;|#/);
		}
	elsif (/^(\s|#|;)*net.slp.traceReg\s*=\s*(\S+)/) {
		$dacfg->{'traceReg'} = $2;
		$dacfg->{'traceRegDisabled'}++ if ($1 =~ /;|#/);
		}

	}
close(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
return $dacfg;
}

# enable_list_line(&list, &line)
sub enable_list_line
{
flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
local @slp = <SLP>;
close(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
flock SLP, 2 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
&open_tempfile(SLP, ">$config->{'slpd_conf'}") || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
local $line = pop;
local $list = join ",", @_;
foreach(@slp) {
	if (/^(\s|#|;)*net.slp.$line\s*=\s*\S+/ && $list) {
		&print_tempfile(SLP, "net.slp.$line=$list\n");
		}
	else {
		&print_tempfile(SLP, $_);
		}
	}
&close_tempfile(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
}

# enable_single_val_line(&val, &line)
sub enable_single_val_line
{
open(SLP, "<".$config->{slpd_conf}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
local @slp = <SLP>;
close(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
flock SLP, 2 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
&open_tempfile(SLP, ">$config->{'slpd_conf'}") || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
local $line = pop;
foreach(@slp) {
	if (/^(\s|#|;)*net.slp.$line\s*=\s*\S+\s*$/) {
		&print_tempfile(SLP, "net.slp.$line=@_[0]\n");
		}
	else {
		&print_tempfile(SLP, $_);
		}
	}
&close_tempfile(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
}

# disable_line(line)
sub disable_line
{
flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
local @slp = <SLP>;
close(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
flock SLP, 2 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n");
&open_tempfile(SLP, ">$config->{'slpd_conf'}") || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n");
foreach(@slp) {
	if (/^(\s|#|;)*net.slp.@_[0]\s*=\s*(\S+)/) {
		&print_tempfile(SLP, ";net.slp.@_[0]=$2\n");
		}
	else {
		&print_tempfile(SLP, $_);
		}
	}
&close_tempfile(SLP);
flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n");
}

# parse_config_file
sub parse_config_file
{ 
local %dummy;
flock FH, 1 || &error("$text->{'error_flock_on'} $config_file: $!\n");
open(FH, "<".$config_file) || &error("$text->{'error_open'} $config_file: $!\n");
while (<FH>) {
  $dummy{$1} = $2 if (/(\S+)=(.+)/)
}
return \%dummy;
close(FH);
flock FH, 8 || &error("$text->{'error_flock_off'} $config_file: $!\n");
}

# restart
sub restart
{
local $pid;
flock PID, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_pid'}: $!\n");
open(PID, "<".$config->{'slpd_pid'}) || &start_slpd;
while (<PID>) {
  $pid=$1, last if (/(\d+)/)
}
close(PID);
flock PID, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_pid'}: $!\n");
if ($pid =~ /\d+/) {
  kill('HUP', $pid) || &error("$text->{'error_hup'}: $config->{'slpd_pid'}\n");
} else {
  &start_slpd;
}
}

# is slpd running?
sub slpd_is_running
{
local $pid;
flock PID, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_pid'}: $!\n");
open(PID, "<".$config->{'slpd_pid'}) || return 0;
while (<PID>) {
  $pid=$1, last if (/(\d+)/)
}
close(PID);
flock PID, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_pid'}: $!\n");
if ($pid =~ /\d+/) {
  # the pid file has a number in it but 
  # we need to check if slpd is _actually_ running
  if (kill 0 => $pid) {
    return $pid;
  } else {
    &stop_slpd;
    return 0;
  }
} else {
  return 0;
}
}

sub start_slpd
{
&error_setup($text->{'start_err'});
local $temp = &transname();
local $rv = &system_logged("($config->{'start_cmd'}) >$temp 2>&1");
local $out = `cat $temp`;
unlink($temp);
sleep(2);
&webmin_log("start");
}

sub stop_slpd
{
$out = &backquote_logged("$config->{'stop_cmd'} 2>&1");
&error_setup($text->{'stop_err'});
if ($?) {
  &error("<pre>$?\n$out</pre>");
}
&webmin_log("stop");
}

1;


Filemanager

Name Type Size Permission Actions
help Folder 0755
images Folder 0755
lang Folder 0755
README File 1.23 KB 0644
backup_config.pl File 646 B 0755
config File 120 B 0644
config-cobalt-linux File 194 B 0644
config-coherent-linux File 194 B 0644
config-freebsd File 220 B 0644
config-mandrake-linux File 176 B 0644
config-msc-linux File 194 B 0644
config-open-linux File 194 B 0644
config-openSUSE-Linux-15.0-ALL File 194 B 0644
config-openmamba-linux File 194 B 0644
config-pardus-linux File 120 B 0644
config-redhat-linux File 194 B 0644
config-suse-linux File 194 B 0644
config-syno-linux File 120 B 0644
config-trustix-linux File 194 B 0644
config-turbo-linux File 194 B 0644
config-united-linux File 184 B 0644
config.info File 336 B 0644
config.info.ca File 394 B 0644
config.info.cs File 383 B 0644
config.info.de File 370 B 0644
config.info.ms File 349 B 0644
config.info.nl File 379 B 0644
config.info.no File 352 B 0644
config.info.ru File 519 B 0644
config.info.uk File 546 B 0644
edit_dacfg.cgi File 1.49 KB 0755
edit_log.cgi File 2.7 KB 0755
edit_netcfg.cgi File 8.4 KB 0755
edit_snda.cgi File 2.04 KB 0755
index.cgi File 2.23 KB 0755
install_check.pl File 323 B 0755
module.info File 174 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 100 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 113 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 139 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 182 B 0644
module.info.ca File 102 B 0644
module.info.ca.auto File 16 B 0644
module.info.cs File 23 B 0644
module.info.cs.auto File 81 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 100 B 0644
module.info.de File 86 B 0644
module.info.de.auto File 16 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 165 B 0644
module.info.es File 0 B 0644
module.info.es.auto File 117 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 116 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 125 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 101 B 0644
module.info.fr File 0 B 0644
module.info.fr.auto File 113 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 130 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 106 B 0644
module.info.hu File 0 B 0644
module.info.hu.auto File 120 B 0644
module.info.it File 0 B 0644
module.info.it.auto File 118 B 0644
module.info.ja File 0 B 0644
module.info.ja.auto File 135 B 0644
module.info.ko File 0 B 0644
module.info.ko.auto File 111 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 116 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 118 B 0644
module.info.ms File 84 B 0644
module.info.ms.auto File 16 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 114 B 0644
module.info.nl File 23 B 0644
module.info.nl.auto File 73 B 0644
module.info.no File 23 B 0644
module.info.no.auto File 77 B 0644
module.info.pl File 0 B 0644
module.info.pl.auto File 102 B 0644
module.info.pt File 0 B 0644
module.info.pt.auto File 117 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 126 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 114 B 0644
module.info.ru File 29 B 0644
module.info.ru.auto File 122 B 0644
module.info.sk File 0 B 0644
module.info.sk.auto File 104 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 108 B 0644
module.info.sv File 0 B 0644
module.info.sv.auto File 98 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 199 B 0644
module.info.tr File 0 B 0644
module.info.tr.auto File 104 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 149 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 161 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 113 B 0644
module.info.zh File 0 B 0644
module.info.zh.auto File 90 B 0644
module.info.zh_TW File 0 B 0644
module.info.zh_TW.auto File 99 B 0644
save_dacfg.cgi File 680 B 0755
save_log.cgi File 1015 B 0755
save_netcfg.cgi File 2.95 KB 0755
save_snda.cgi File 1.03 KB 0755
slp-lib.pl File 10.16 KB 0755
start.cgi File 408 B 0755
stop.cgi File 330 B 0755