From 7190cd1265afa64eae632aa0258e99e3b279932f Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 6 Dec 2012 15:20:10 -0800 Subject: [PATCH] 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 Conflicts: Shorewall/Perl/Shorewall/Config.pm --- Shorewall/Perl/Shorewall/Config.pm | 12 ++++++------ Shorewall/Perl/Shorewall/Rules.pm | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 29ff0f928..1e0b31f71 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -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 = (); diff --git a/Shorewall/Perl/Shorewall/Rules.pm b/Shorewall/Perl/Shorewall/Rules.pm index ffb87c262..52c13e360 100644 --- a/Shorewall/Perl/Shorewall/Rules.pm +++ b/Shorewall/Perl/Shorewall/Rules.pm @@ -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 );