From d05e81330e2940b878c9469cbffac6d6cbf3f3e4 Mon Sep 17 00:00:00 2001 From: teastep Date: Mon, 26 Mar 2007 20:10:59 +0000 Subject: [PATCH] Fix a couple of bugs found testing Bleve's configuration git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5702 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- New/Shorewall/Actions.pm | 16 +++------------- New/Shorewall/Macros.pm | 12 ++++++++++++ New/Shorewall/Rules.pm | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/New/Shorewall/Actions.pm b/New/Shorewall/Actions.pm index e0a936d3d..210377cd6 100644 --- a/New/Shorewall/Actions.pm +++ b/New/Shorewall/Actions.pm @@ -33,7 +33,6 @@ use strict; our @ISA = qw(Exporter); our @EXPORT = qw( merge_levels - split_action isolate_basic_target add_requiredby createlogactionchain @@ -111,21 +110,12 @@ sub merge_levels ($$) { $subordinate; } -# -# Return ( action, level[:tag] ) from passed full action -# -sub split_action ( $ ) { - my $action = $_[0]; - my @a = split /:/ , $action; - fatal_error "Invalid ACTION $action in rule \"$line\"" if ( $action =~ /::/ ) || ( @a > 3 ); - ( shift @a, join ":", @a ); -} - -# # Get Macro Name # sub isolate_basic_target( $ ) { - ( split '/' , $_[0] )[0]; + my $result = ( split '/' , $_[0] )[0]; + + ( split /:/, $result )[0]; } # diff --git a/New/Shorewall/Macros.pm b/New/Shorewall/Macros.pm index b3fc720e1..0476442e1 100644 --- a/New/Shorewall/Macros.pm +++ b/New/Shorewall/Macros.pm @@ -33,6 +33,7 @@ use strict; our @ISA = qw(Exporter); our @EXPORT = qw( find_macro expand_shell_variables + split_action substitute_action merge_macro_source_dest merge_macro_column @@ -67,6 +68,17 @@ sub expand_shell_variables( $ ) { my $line = $_[0]; $line = $1 . ( $ENV{$2} || '' ) . $3 while $line =~ /^(.*?)\$([a-zA-Z]\w*)(.*)$/; $line; } +# +# Return ( action, level[:tag] ) from passed full action +# +sub split_action ( $ ) { + my $action = $_[0]; + my @a = split /:/ , $action; + fatal_error "Invalid ACTION $action in rule \"$line\"" if ( $action =~ /::/ ) || ( @a > 3 ); + ( shift @a, join ":", @a ); +} + +# # This function substitutes the second argument for the first part of the first argument up to the first colon (":") # # Example: diff --git a/New/Shorewall/Rules.pm b/New/Shorewall/Rules.pm index 867149c33..bdc9ed13e 100644 --- a/New/Shorewall/Rules.pm +++ b/New/Shorewall/Rules.pm @@ -720,7 +720,7 @@ sub process_macro ( $$$$$$$$$$$ ) { } my $action = isolate_basic_target $mtarget; - my $actiontype = $targets{$action}; + my $actiontype = $targets{$action} || 0; if ( $actiontype & ACTION ) { unless ( $usedactions{$action} ) {