From ae62d5cd20647276fbe27040d72f8be204b6f92a Mon Sep 17 00:00:00 2001 From: teastep Date: Sat, 28 Jul 2007 14:56:39 +0000 Subject: [PATCH] More log level editing; and fix odd cut/paste of macro module into actions module git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6979 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall-perl/Shorewall/Actions.pm | 42 ++++++++++++++--------------- Shorewall-perl/Shorewall/Chains.pm | 4 +++ Shorewall-perl/Shorewall/Config.pm | 2 +- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Shorewall-perl/Shorewall/Actions.pm b/Shorewall-perl/Shorewall/Actions.pm index be1483a5b..e442a7b67 100644 --- a/Shorewall-perl/Shorewall/Actions.pm +++ b/Shorewall-perl/Shorewall/Actions.pm @@ -117,6 +117,27 @@ sub merge_levels ($$) { my $subparts = @subparts; my $target = $subparts[0]; + + push @subparts, '' while @subparts < 3; #Avoid undefined values + + my $level = $supparts[1]; + my $tag = $supparts[2]; + + if ( @supparts == 3 ) { + return "$target:none!:$tag" if $level eq 'none!'; + return "$target:$level:$tag" if $level =~ /!$/; + return $subordinate if $subparts >= 2; + return "$target:$level:$tag"; + } + + if ( @supparts == 2 ) { + return "$target:none!" if $level eq 'none!'; + return "$target:$level" if ($level =~ /!$/) || ($subparts < 2); + } + + $subordinate; +} + # # Try to find a macro file -- RETURNS false if the file doesn't exist or MACRO if it does. # If the file exists, the macro is entered into the 'targets' table and the fully-qualified @@ -195,27 +216,6 @@ sub merge_macro_column( $$ ) { } } - - push @subparts, '' while @subparts < 3; #Avoid undefined values - - my $level = $supparts[1]; - my $tag = $supparts[2]; - - if ( @supparts == 3 ) { - return "$target:none!:$tag" if $level eq 'none!'; - return "$target:$level:$tag" if $level =~ /!$/; - return $subordinate if $subparts >= 2; - return "$target:$level:$tag"; - } - - if ( @supparts == 2 ) { - return "$target:none!" if $level eq 'none!'; - return "$target:$level" if ($level =~ /!$/) || ($subparts < 2); - } - - $subordinate; -} - # # Get Macro Name -- strips away trailing /* and :* from the first column in a rule, macro or action. # diff --git a/Shorewall-perl/Shorewall/Chains.pm b/Shorewall-perl/Shorewall/Chains.pm index 84b35b152..f7485ecd4 100644 --- a/Shorewall-perl/Shorewall/Chains.pm +++ b/Shorewall-perl/Shorewall/Chains.pm @@ -1274,6 +1274,10 @@ sub log_rule_limit( $$$$$$$$ ) { my $prefix; + $level = validate_level $level; + + return 1 if $level eq ''; + unless ( $predicates =~ /-m limit / ) { $limit = $globals{LOGLIMIT} unless $limit && $limit ne '-'; $predicates .= $limit if $limit; diff --git a/Shorewall-perl/Shorewall/Config.pm b/Shorewall-perl/Shorewall/Config.pm index 2a72d3613..bf85b0001 100644 --- a/Shorewall-perl/Shorewall/Config.pm +++ b/Shorewall-perl/Shorewall/Config.pm @@ -948,7 +948,7 @@ my %validlevels = ( debug => 7, ULOG => 'ULOG' ); # -# Validate a log level -- Drop the trailing '!' that some fools think is important. +# Validate a log level -- Drop the trailing '!' and translate to numeric value if appropriate" # sub validate_level( $ ) { my $level = $_[0];