version 1.6, 2011/05/14 23:38:07
|
version 1.7, 2018/10/24 04:19:27
|
Line 88 if (-e $tmpfile) {
|
Line 88 if (-e $tmpfile) {
|
&Exit(3); |
&Exit(3); |
} |
} |
|
|
|
my ($opened,$closed); |
my $lond_port = &LONCAPA::Firewall::get_lond_port(); |
my $lond_port = &LONCAPA::Firewall::get_lond_port(); |
|
if (($lond_port eq '') || ($lond_port =~ /\D/)) { |
|
print "Error. Invalid lond port\n" unless $noprint; |
|
&Exit(3); |
|
} |
|
my $iptables = &LONCAPA::Firewall::get_pathto_iptables(); |
|
if ($iptables eq '') { |
|
print "Error. No path to iptables\n" unless $noprint; |
|
&Exit(3); |
|
} |
|
|
|
my $firewalld = &LONCAPA::Firewall::uses_firewalld(); |
|
|
&EnableRoot(); |
&EnableRoot(); |
|
|
my @fw_chains = &LONCAPA::Firewall::get_fw_chains(); |
my @fw_chains = &LONCAPA::Firewall::get_fw_chains(); |
my $iptables = &LONCAPA::Firewall::get_pathto_iptables(); |
if ($firewalld) { |
my $firewall_result = |
$<=0; |
&LONCAPA::Firewall::firewall_close_port($iptables,\@fw_chains,$lond_port,\%iphost,[$lond_port]); |
} |
if ($firewall_result) { |
$opened = |
print "$firewall_result\n"; |
&LONCAPA::Firewall::firewall_close_port($iptables,\@fw_chains,$lond_port,\%iphost,[$lond_port]); |
} |
$closed = |
$firewall_result = &LONCAPA::Firewall::firewall_open_port($iptables,\@fw_chains,$lond_port,\%iphost,[$lond_port]); |
&LONCAPA::Firewall::firewall_open_port($iptables,\@fw_chains,$lond_port,\%iphost,[$lond_port]); |
if ($firewall_result) { |
if ($firewalld) { |
print "$firewall_result\n"; |
$<=$wwwid; |
} |
} |
|
&DisableRoot(); |
|
|
# -------------------------------------------------------- Exit script |
# -------------------------------------------------------- Exit script |
|
if ($opened) { |
|
print "$opened\n"; |
|
} |
|
if ($closed) { |
|
print "$closed\n"; |
|
} |
print "lciptables Exiting\n" unless $noprint; |
print "lciptables Exiting\n" unless $noprint; |
&DisableRoot; |
|
&Exit(0); |
&Exit(0); |
|
|
|
|
sub EnableRoot { |
sub EnableRoot { |
if ($wwwid==$>) { |
if ($wwwid==$>) { |
($<,$>)=($>,$<); |
($<,$>)=($>,$<); |