Don't lookup standard target if target is an action, macro, or chain

This commit is contained in:
Tom Eastep 2011-01-09 10:10:27 -08:00
parent 97672455b2
commit 14c4bd99aa

View File

@ -44,7 +44,7 @@ our @EXPORT = qw(
); );
our @EXPORT_OK = qw( initialize ); our @EXPORT_OK = qw( initialize );
our $VERSION = '4.4_16'; our $VERSION = '4.4_17';
our %macros; our %macros;
@ -1020,32 +1020,34 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ ) {
# #
my $log_action = $action; my $log_action = $action;
if ( my $shorewall_target = lookup_shorewall_action( $basictarget ) ) { unless ( $actiontype & ( ACTION | MACRO | NFQ | CHAIN ) ) {
if ( $shorewall_target == TGT_REDIRECT ) { if ( my $shorewall_target = lookup_shorewall_action( $basictarget ) ) {
my $z = $actiontype & NATONLY ? '' : firewall_zone; if ( $shorewall_target == TGT_REDIRECT ) {
if ( $dest eq '-' ) { my $z = $actiontype & NATONLY ? '' : firewall_zone;
$dest = $inaction ? '' : join( '', $z, '::' , $ports =~ /[:,]/ ? '' : $ports ); if ( $dest eq '-' ) {
} elsif ( $inaction ) { $dest = $inaction ? '' : join( '', $z, '::' , $ports =~ /[:,]/ ? '' : $ports );
$dest = ":$dest"; } elsif ( $inaction ) {
} else { $dest = ":$dest";
$dest = join( '', $z, '::', $dest ) unless $dest =~ /^[^\d].*:/; } else {
} $dest = join( '', $z, '::', $dest ) unless $dest =~ /^[^\d].*:/;
} elsif ( $shorewall_target == TGT_REJECT ) { }
$action = 'reject'; } elsif ( $shorewall_target == TGT_REJECT ) {
} elsif ( $shorewall_target == TGT_CONTINUE ) { $action = 'reject';
$action = 'RETURN'; } elsif ( $shorewall_target == TGT_CONTINUE ) {
} elsif ( $shorewall_target == TGT_COUNT ) { $action = 'RETURN';
$action = ''; } elsif ( $shorewall_target == TGT_COUNT ) {
} elsif ( $shorewall_target == TGT_LOG ) { $action = '';
fatal_error 'LOG requires a log level' unless defined $loglevel and $loglevel ne ''; } elsif ( $shorewall_target == TGT_LOG ) {
} elsif ( $actiontype & SET ) { fatal_error 'LOG requires a log level' unless defined $loglevel and $loglevel ne '';
my %xlate = ( ADD => 'add-set' , DEL => 'del-set' ); } elsif ( $actiontype & SET ) {
my %xlate = ( ADD => 'add-set' , DEL => 'del-set' );
my ( $setname, $flags, $rest ) = split ':', $param, 3; my ( $setname, $flags, $rest ) = split ':', $param, 3;
fatal_error "Invalid ADD/DEL parameter ($param)" if $rest; fatal_error "Invalid ADD/DEL parameter ($param)" if $rest;
fatal_error "Expected ipset name ($setname)" unless $setname =~ s/^\+// && $setname =~ /^[a-zA-Z]\w*$/; fatal_error "Expected ipset name ($setname)" unless $setname =~ s/^\+// && $setname =~ /^[a-zA-Z]\w*$/;
fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/; fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/;
$action = join( ' ', 'SET --' . $xlate{$basictarget} , $setname , $flags ); $action = join( ' ', 'SET --' . $xlate{$basictarget} , $setname , $flags );
}
} }
} }
# #