version 1.19, 2019/07/02 19:40:22
|
version 1.23, 2021/12/20 03:13:29
|
Line 51 sub uses_firewalld {
|
Line 51 sub uses_firewalld {
|
if ($1 >= 18) { |
if ($1 >= 18) { |
$checkfirewalld = 1; |
$checkfirewalld = 1; |
} |
} |
} elsif ($distro =~ /^(?:centos|rhes|scientific|oracle)(\d+)/) { |
} elsif ($distro =~ /^(?:centos|rhes|scientific|oracle|rocky|alma)(\d+)/) { |
if ($1 >= 7) { |
if ($1 >= 7) { |
$checkfirewalld = 1; |
$checkfirewalld = 1; |
} |
} |
Line 119 sub firewall_open_port {
|
Line 119 sub firewall_open_port {
|
@lond_port_curropen); |
@lond_port_curropen); |
if (ref($iphost) eq 'HASH') { |
if (ref($iphost) eq 'HASH') { |
if (keys(%{$iphost}) > 0) { |
if (keys(%{$iphost}) > 0) { |
|
my $count = scalar(keys(%{$iphost})); |
|
if ($count > 1) { |
|
print "Please be patient. Checking $count IPs.\n"; |
|
} |
my %curropen; |
my %curropen; |
if ($firewalld) { |
if ($firewalld) { |
&firewall_close_anywhere($iptables,$zone,$port,$firewalld); |
&firewall_close_anywhere($iptables,$zone,$port,$firewalld); |
Line 132 sub firewall_open_port {
|
Line 136 sub firewall_open_port {
|
$lond_port,$iphost,\%curropen); |
$lond_port,$iphost,\%curropen); |
} |
} |
} |
} |
|
my $countok = 0; |
foreach my $key (keys(%{$iphost})) { |
foreach my $key (keys(%{$iphost})) { |
my $ip = ''; |
my $ip = ''; |
if ($key =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) { |
if ($key =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) { |
Line 179 sub firewall_open_port {
|
Line 184 sub firewall_open_port {
|
} |
} |
} |
} |
} |
} |
|
if ($count > 1) { |
|
$countok ++; |
|
print '.'; |
|
if ($countok%40 == 0) { |
|
print "\n"; |
|
} |
|
} |
|
} |
|
if ($count > 1) { |
|
if ($countok%40) { |
|
print "\n"; |
|
} |
} |
} |
} else { |
} else { |
print "no key found in $iphost hash ref\n"; |
print "no key found in \$iphost hash ref.\n". |
|
"Domain Name Service (DNS) may not be available.\n". |
|
"If this LON-CAPA node is standalone, then you can fix this issue by modifying /etc/hosts.\n". |
|
"Use a text editor to add: IPaddress Hostname\n"; |
} |
} |
} else { |
} else { |
print "$iphost is not a reference to a hash\n"; |
print "\$iphost is not a reference to a hash\n"; |
} |
} |
if (@lond_port_curropen) { |
if (@lond_port_curropen) { |
unless (grep(/^\Q$port\E$/,@opened)) { |
unless (grep(/^\Q$port\E$/,@opened)) { |
Line 276 sub firewall_is_port_open {
|
Line 296 sub firewall_is_port_open {
|
# for other ports returns 1 if the firewall port is open, 0 if not. |
# for other ports returns 1 if the firewall port is open, 0 if not. |
# if firewalld is in use, checks for rich rules only. |
# if firewalld is in use, checks for rich rules only. |
my $count = 0; |
my $count = 0; |
|
# check if firewall is active or installed |
return $count if (! &firewall_is_active()); |
return $count if (! &firewall_is_active()); |
if ($firewalld) { |
if ($firewalld) { |
my $zone = &get_default_zone(); |
my $zone = &get_default_zone(); |
Line 307 sub firewall_is_port_open {
|
Line 328 sub firewall_is_port_open {
|
close(PIPE); |
close(PIPE); |
} |
} |
} |
} |
return $count; |
} elsif (($fw_chain =~ /^[\w-]+$/) && (open(PIPE,"$iptables -L $fw_chain -n |"))) { |
} |
|
return $count unless ($fw_chain !~ /^[\w-]+$/); |
|
if (open(PIPE,"$iptables -L $fw_chain -n |")) { |
|
# check if firewall is active or installed |
|
return if (! &firewall_is_active()); |
|
while(<PIPE>) { |
while(<PIPE>) { |
if ($port eq $lond_port) { |
if ($port eq $lond_port) { |
if (ref($iphost) eq 'HASH') { |
if (ref($iphost) eq 'HASH') { |
Line 640 sub get_fw_chains {
|
Line 656 sub get_fw_chains {
|
my $firewalld = &uses_firewalld($distro); |
my $firewalld = &uses_firewalld($distro); |
if ($firewalld) { |
if ($firewalld) { |
my ($dist,$version) = ($distro =~ /^([\D]+)(\d+)$/); |
my ($dist,$version) = ($distro =~ /^([\D]+)(\d+)$/); |
if (((($dist eq 'rhes') || ($dist eq 'centos')) && |
if (((($dist eq 'rhes') || ($dist eq 'centos') || ($dist eq 'rocky') || ($dist eq 'alma')) && |
($version >= 8)) || (($dist eq 'oracle') && ($version >= 7))) { |
($version >= 8)) || (($dist eq 'oracle') && ($version >= 7))) { |
push(@fw_chains,'INPUT'); |
push(@fw_chains,'INPUT'); |
} else { |
} else { |
Line 660 sub get_fw_chains {
|
Line 676 sub get_fw_chains {
|
} else { |
} else { |
if ($distro =~ /^(debian|ubuntu|suse|sles)/) { |
if ($distro =~ /^(debian|ubuntu|suse|sles)/) { |
@posschains = ('INPUT'); |
@posschains = ('INPUT'); |
} elsif ($distro =~ /^(fedora|rhes|centos|scientific|oracle)(\d+)$/) { |
} elsif ($distro =~ /^(fedora|rhes|centos|scientific|oracle|rocky|alma)(\d+)$/) { |
if ((($1 eq 'fedora') && ($2 > 15)) || (($1 ne 'fedora') && ($2 >= 7))) { |
if ((($1 eq 'fedora') && ($2 > 15)) || (($1 ne 'fedora') && ($2 >= 7))) { |
@posschains = ('INPUT'); |
@posschains = ('INPUT'); |
} else { |
} else { |
Line 673 sub get_fw_chains {
|
Line 689 sub get_fw_chains {
|
print("Unable to find iptables file containing static definitions.\n"); |
print("Unable to find iptables file containing static definitions.\n"); |
} |
} |
} |
} |
if ($distro =~ /^(fedora|rhes|centos|scientific|oracle)(\d+)$/) { |
if ($distro =~ /^(fedora|rhes|centos|scientific|oracle|rocky|alma)(\d+)$/) { |
unless ((($1 eq 'fedora') && ($2 > 15)) || (($1 ne 'fedora') && ($2 >= 7))) { |
unless ((($1 eq 'fedora') && ($2 > 15)) || (($1 ne 'fedora') && ($2 >= 7))) { |
push(@fw_chains,'RH-Firewall-1-INPUT'); |
push(@fw_chains,'RH-Firewall-1-INPUT'); |
} |
} |