On 12/1/12 11:09 AM, Tom Eastep wrote: > On 12/1/12 9:32 AM, Mr Dash Four wrote:
>> Finally, two suggestions: >> >> 1. I don't seem to be able to invoke action with parameters *and* log >> level specified as action parameter. In other words, something like: >> "circ1(circ2(whatever):debug):info". It would be nice to have that ability. The attached patch seems to handle this case correctly. -Tom -- Tom Eastep \ When I die, I want to go like my Grandfather who Shoreline, \ died peacefully in his sleep. Not screaming like Washington, USA \ all of the passengers in his car http://shorewall.net \________________________________________________
diff --git a/Shorewall/Perl/Shorewall/Config.pm
b/Shorewall/Perl/Shorewall/Config.pm
index 691d43f..14ec041 100644
--- a/Shorewall/Perl/Shorewall/Config.pm
+++ b/Shorewall/Perl/Shorewall/Config.pm
@@ -105,6 +105,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
find_file
split_list
split_list1
+ split_list2
split_line
split_line1
first_entry
@@ -1688,6 +1689,59 @@ sub split_list1( $$ ) {
@list2;
}
+sub split_list2( $$ ) {
+ my ($list, $type ) = @_;
+
+ fatal_error "Invalid $type ($list)" if $list =~ /^:|::/;
+
+ my @list1 = split /:/, $list;
+ my @list2;
+ my $element = '';
+ my $opencount = 0;
+
+
+ for ( @list1 ) {
+ my $count;
+
+ if ( ( $count = tr/(/(/ ) > 0 ) {
+ $opencount += $count;
+ if ( $element eq '' ) {
+ $element = $_;
+ } else {
+ $element = join( ':', $element, $_ );
+ }
+
+ if ( ( $count = tr/)/)/ ) > 0 ) {
+ if ( ! ( $opencount -= $count ) ) {
+ push @list2 , $element;
+ $element = '';
+ } else {
+ fatal_error "Invalid $type ($list)" if $opencount < 0;
+ }
+ }
+ } elsif ( ( $count = tr/)/)/ ) > 0 ) {
+ fatal_error "Invalid $type ($list)" unless $element ne '';
+ $element = join (':', $element, $_ );
+ if ( ! ( $opencount -= $count ) ) {
+ push @list2 , $element;
+ $element = '';
+ } else {
+ fatal_error "Invalid $type ($list)" if $opencount < 0;
+ }
+ } elsif ( $element eq '' ) {
+ push @list2 , $_;
+ } else {
+ $element = join ':', $element , $_;
+ }
+ }
+
+ unless ( $opencount == 0 ) {
+ fatal_error "Invalid $type ($list)";
+ }
+
+ @list2;
+}
+
#
# Determine if a value has been supplied
#
diff --git a/Shorewall/Perl/Shorewall/Rules.pm
b/Shorewall/Perl/Shorewall/Rules.pm
index a6e31e9..4d83c46 100644
--- a/Shorewall/Perl/Shorewall/Rules.pm
+++ b/Shorewall/Perl/Shorewall/Rules.pm
@@ -916,26 +916,11 @@ sub finish_section ( $ ) {
sub split_action ( $ ) {
my $action = $_[0];
- my $target = '';
- my $max = 3;
- #
- # The following rather grim RE, when matched, breaks the action into two
parts:
- #
- # basicaction(param)
- # logging part (may be empty)
- #
- # The param may contain one or more ':' characters
- #
- if ( $action =~ /^([^(:]+\(.*?\))(:(.*))?$/ ) {
- $target = $1;
- $action = $2 ? $3 : '';
- $max = 2;
- }
+ my @list = split_list2( $action, 'ACTION' );
+
+ fatal_error "Invalid ACTION ($action)" if @list > 3;
- my @a = split( /:/ , $action, 4 );
- fatal_error "Invalid ACTION ($action)" if ( $action =~ /::/ ) || ( @a >
$max );
- $target = shift @a unless $target;
- ( $target, join ":", @a );
+ ( shift @list, join( ':', @list ) );
}
#
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Keep yourself connected to Go Parallel: INSIGHTS What's next for parallel hardware, programming and related areas? Interviews and blogs by thought leaders keep you ahead of the curve. http://goparallel.sourceforge.net
_______________________________________________ Shorewall-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/shorewall-devel
