version 1.27, 2024/06/13 17:18:38
|
version 1.28, 2024/09/13 03:52:03
|
Line 82 sub firewall_open_port {
|
Line 82 sub firewall_open_port {
|
return 'inactive firewall' if (!&firewall_is_active()); |
return 'inactive firewall' if (!&firewall_is_active()); |
return 'port number unknown' if !$lond_port; |
return 'port number unknown' if !$lond_port; |
return 'invalid firewall chain' unless (ref($fw_chains) eq 'ARRAY'); |
return 'invalid firewall chain' unless (ref($fw_chains) eq 'ARRAY'); |
my (@opened,@okchains,$zone); |
my (@opened,@okchains,$zone,$firewalld_num_opened); |
if ($firewalld) { |
if ($firewalld) { |
$zone = &get_default_zone(); |
$zone = &get_default_zone(); |
return 'invalid zone' if ($zone eq ''); |
return 'invalid zone' if ($zone eq ''); |
|
$firewalld_num_opened = 0; |
} else { |
} else { |
my @badchains; |
my @badchains; |
foreach my $chain (@{$fw_chains}) { |
foreach my $chain (@{$fw_chains}) { |
Line 161 sub firewall_open_port {
|
Line 162 sub firewall_open_port {
|
close(PIPE); |
close(PIPE); |
if ($result eq 'success') { |
if ($result eq 'success') { |
push(@lond_port_open,$ip); |
push(@lond_port_open,$ip); |
|
$firewalld_num_opened ++; |
} else { |
} else { |
push(@port_error,$ip); |
push(@port_error,$ip); |
} |
} |
Line 242 sub firewall_open_port {
|
Line 244 sub firewall_open_port {
|
close(PIPE); |
close(PIPE); |
if ($result eq 'success') { |
if ($result eq 'success') { |
push(@opened,$port); |
push(@opened,$port); |
|
$firewalld_num_opened ++; |
} else { |
} else { |
$port_error = $port; |
$port_error = $port; |
} |
} |
Line 282 sub firewall_open_port {
|
Line 285 sub firewall_open_port {
|
} |
} |
} |
} |
} |
} |
|
if ($firewalld && $firewalld_num_opened) { |
|
system('firewall-cmd --runtime-to-permanent'); |
|
} |
foreach my $port (@{$ports}) { |
foreach my $port (@{$ports}) { |
if (!grep(/^\Q$port\E$/,@opened)) { |
if (!grep(/^\Q$port\E$/,@opened)) { |
return 'Required port not open: '.$port."\n"; |
return 'Required port not open: '.$port."\n"; |
Line 389 sub firewall_close_port {
|
Line 395 sub firewall_close_port {
|
return 'inactive firewall' if (!&firewall_is_active()); |
return 'inactive firewall' if (!&firewall_is_active()); |
return 'port number unknown' if !$lond_port; |
return 'port number unknown' if !$lond_port; |
return 'invalid firewall chain' unless (ref($fw_chains) eq 'ARRAY'); |
return 'invalid firewall chain' unless (ref($fw_chains) eq 'ARRAY'); |
my (@okchains,$zone); |
my (@okchains,$zone,$firewalld_num_closed); |
if ($firewalld) { |
if ($firewalld) { |
$zone = &get_default_zone(); |
$zone = &get_default_zone(); |
return 'no default zone' if ($zone eq ''); |
return 'no default zone' if ($zone eq ''); |
|
$firewalld_num_closed = 0; |
} else { |
} else { |
my @badchains; |
my @badchains; |
foreach my $chain (@{$fw_chains}) { |
foreach my $chain (@{$fw_chains}) { |
Line 449 sub firewall_close_port {
|
Line 456 sub firewall_close_port {
|
close(PIPE); |
close(PIPE); |
if ($result eq 'success') { |
if ($result eq 'success') { |
push(@lond_port_close,$ip); |
push(@lond_port_close,$ip); |
|
$firewalld_num_closed ++; |
} else { |
} else { |
push(@port_error,$ip); |
push(@port_error,$ip); |
} |
} |
Line 537 sub firewall_close_port {
|
Line 545 sub firewall_close_port {
|
close(PIPE); |
close(PIPE); |
if ($result eq 'success') { |
if ($result eq 'success') { |
print "Port: $port closed in zone: $zone.\n"; |
print "Port: $port closed in zone: $zone.\n"; |
|
$firewalld_num_closed ++; |
} else { |
} else { |
print "Error closing port: $port in zone: $zone.\n"; |
print "Error closing port: $port in zone: $zone.\n"; |
} |
} |
Line 577 sub firewall_close_port {
|
Line 586 sub firewall_close_port {
|
} |
} |
} |
} |
} |
} |
|
if ($firewalld && $firewalld_num_closed) { |
|
system('firewall-cmd --runtime-to-permanent'); |
|
} |
return; |
return; |
} |
} |
|
|
Line 614 sub firewall_close_anywhere {
|
Line 626 sub firewall_close_anywhere {
|
close(PIPE); |
close(PIPE); |
if ($result eq 'success') { |
if ($result eq 'success') { |
print 'Port '.$port.' closed for source "anywhere"'."\n"; |
print 'Port '.$port.' closed for source "anywhere"'."\n"; |
|
system('firewall-cmd --runtime-to-permanent'); |
} else { |
} else { |
print 'Error closing port '.$port.' for source "anywhere".'."\n"; |
print 'Error closing port '.$port.' for source "anywhere".'."\n"; |
} |
} |