Completed Webmin command to open up ports

https://www.virtualmin.com/node/18624
This commit is contained in:
Jamie Cameron
2011-06-30 14:36:08 -07:00
parent 5b4422b0cb
commit a854223fdf
2 changed files with 8 additions and 2 deletions

View File

@@ -36,3 +36,5 @@ Added a button to rename an existing custom chain.
---- Changes since 1.510 ----
Better handle the case where a rule has a --comment format description, but # format comments are enabled.
Added support for physdev module options, for matching based on the bridged interface.
---- Changes since 1.550 ----
Added the open-ports.pl command which can be run from the shell to open ports on the firewall.

View File

@@ -69,11 +69,13 @@ PORT: foreach $p (@ARGV) {
if ($r->{'chain'} eq 'INPUT' &&
$r->{'j'} && $r->{'j'}->[1] eq 'ACCEPT' &&
$r->{'p'} && $r->{'p'}->[0] eq '' &&
$r->{'p'}->[1] eq 'tcp') {
$r->{'p'}->[1] eq 'tcp') {
# Found tcp rule .. check ports
@rports = ( );
$rrange = undef;
if ($r->{'dports'} && $r->{'dports'}->[0] eq '') {
push(@rports, split(/,/, $r->{'dports'}->[1]));
$rrange = $r->{'dports'}->[1];
}
if ($r->{'dport'} && $r->{'dport'}->[0] eq '') {
($s, $e) = split(":", $r->{'dport'}->[1]);
@@ -83,8 +85,10 @@ PORT: foreach $p (@ARGV) {
elsif ($s) {
push(@rports, $s);
}
$rrange = $r->{'dport'}->[1];
}
if (&indexof($p, @rports) >= 0) {
if (&indexof($p, @rports) >= 0 ||
$p eq $rrange) {
print STDERR ".. already allowed\n";
next PORT;
}