Handle nested parens when pushing action parameters.

- Add an optional argument to split_list1 that causes parens to be retained.

Signed-off-by: Tom Eastep <teastep@shorewall.net>

Conflicts:

	Shorewall/Perl/Shorewall/Config.pm
This commit is contained in:
Tom Eastep 2012-12-06 15:20:10 -08:00
parent 61d67a4741
commit 7190cd1265
2 changed files with 7 additions and 7 deletions

View File

@ -1652,8 +1652,8 @@ sub split_list( $$;$ ) {
split /,/, $list;
}
sub split_list1( $$ ) {
my ($list, $type ) = @_;
sub split_list1( $$;$ ) {
my ($list, $type, $keepparens ) = @_;
fatal_error "Invalid $type list ($list)" if $list =~ /^,|,$|,,|!,|,!$/;
@ -1666,17 +1666,17 @@ sub split_list1( $$ ) {
if ( ( $count = tr/(/(/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" if $element || $count > 1;
s/\(//;
s/\(// unless $keepparens;
if ( ( $count = tr/)/)/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" if $count > 1;
s/\)//;
s/\)// unless $keepparens;
push @list2 , $_;
} else {
$element = $_;
}
} elsif ( ( $count = tr/)/)/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" unless $element && $count == 1;
s/\)//;
s/\)// unless $keepparens;
push @list2, join ',', $element, $_;
$element = '';
} elsif ( $element ) {
@ -2470,7 +2470,7 @@ sub embedded_perl( $ ) {
# Push/pop action params
#
sub push_action_params( $$ ) {
my @params = split /,/, $_[1];
my @params = split_list1 $_[1], 'parameter', 1;
my @oldparams = @actparms;
@actparms = ();

View File

@ -1987,7 +1987,7 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$$$ ) {
return $generated;
} elsif ( $actiontype & ( ACTION | INLINE ) ) {
split_list $param, 'Action parameter';
split_list1 $param, 'Action parameter';
} elsif ( $actiontype & NFQ ) {
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules', '' );
my $paramval = $param eq '' ? 0 : numeric_value( $param );