mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-19 17:28:35 +02:00
Correct handling of exclusion with ipset lists
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
d02bc69cd9
commit
e74f48410f
@ -3564,7 +3564,30 @@ sub expand_rule( $$$$$$$$$$;$ )
|
||||
# Determine if there is Source Exclusion
|
||||
#
|
||||
if ( $inets ) {
|
||||
fatal_error "Invalid SOURCE" if $inets =~ /^([^!]+)?,!([^!]+)$/ || $inets =~ /.*!.*!/;
|
||||
if ( $inets =~ /^(!?)(\+\[(.+)\])$/ ) {
|
||||
if ( $1 ) {
|
||||
$inets = '';
|
||||
|
||||
my @iexcl = mysplit $3;
|
||||
|
||||
for ( @iexcl ) {
|
||||
fatal_error "Expected ipset name ($_)" unless /^(!?)(\+?)[a-zA-Z][-\w]*(\[.*\])?/;
|
||||
s/^/+/ unless $2;
|
||||
}
|
||||
|
||||
$iexcl = join ',', @iexcl;
|
||||
} else {
|
||||
$inets = $2;
|
||||
$iexcl = '';
|
||||
}
|
||||
} else {
|
||||
my @inets = mysplit $inets;
|
||||
|
||||
shift @inets;
|
||||
|
||||
for ( @inets ) {
|
||||
fatal_error "Invalid SOURCE ($inets)" if /^!/;
|
||||
}
|
||||
|
||||
if ( $inets =~ /^([^!]+)?!([^!]+)$/ ) {
|
||||
$inets = $1;
|
||||
@ -3580,6 +3603,7 @@ sub expand_rule( $$$$$$$$$$;$ )
|
||||
$iexcl = '';
|
||||
$trivialiexcl = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
@ -3590,6 +3614,31 @@ sub expand_rule( $$$$$$$$$$;$ )
|
||||
# Determine if there is Destination Exclusion
|
||||
#
|
||||
if ( $dnets ) {
|
||||
if ( $dnets =~ /^(!?)(\+\[(.+)\])$/ ) {
|
||||
if ( $1 ) {
|
||||
$dnets = '';
|
||||
|
||||
my @dexcl = mysplit $3;
|
||||
|
||||
for ( @dexcl ) {
|
||||
fatal_error "Expected ipset name ($_)" unless /^(!?)(\+?)[a-zA-Z][-\w]*(\[.*\])?/;
|
||||
s/^/+/ unless $2;
|
||||
}
|
||||
|
||||
$dexcl = join ',', @dexcl;
|
||||
} else {
|
||||
$dnets = $2;
|
||||
$dexcl = '';
|
||||
}
|
||||
} else {
|
||||
my @dnets = mysplit $dnets;
|
||||
|
||||
shift @dnets;
|
||||
|
||||
for ( @dnets ) {
|
||||
fatal_error "Invalid DEST ($dnets)" if /^!/;
|
||||
}
|
||||
|
||||
fatal_error "Invalid DEST" if $dnets =~ /^([^!]+)?,!([^!]+)$/ || $dnets =~ /.*!.*!/;
|
||||
|
||||
if ( $dnets =~ /^([^!]+)?!([^!]+)$/ ) {
|
||||
@ -3599,7 +3648,7 @@ sub expand_rule( $$$$$$$$$$;$ )
|
||||
$dexcl = '';
|
||||
}
|
||||
|
||||
unless ( $dnets ) {
|
||||
unless ( $dnets || $dexcl =~ /!/ ) {
|
||||
my @dexcl = mysplit $dexcl;
|
||||
if ( @dexcl == 1 ) {
|
||||
$rule .= match_dest_net "!$dexcl";
|
||||
@ -3607,6 +3656,7 @@ sub expand_rule( $$$$$$$$$$;$ )
|
||||
$trivialdexcl = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$dexcl = '';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user