From d1b9a71a3b7387ed7024cecacbfba2bf4a6aede9 Mon Sep 17 00:00:00 2001 From: teastep Date: Thu, 3 May 2007 16:02:24 +0000 Subject: [PATCH] Ensure that action extension scripts are always processed git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6213 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall-perl/Shorewall/Actions.pm | 39 ++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/Shorewall-perl/Shorewall/Actions.pm b/Shorewall-perl/Shorewall/Actions.pm index f3a62449e..6205094bd 100644 --- a/Shorewall-perl/Shorewall/Actions.pm +++ b/Shorewall-perl/Shorewall/Actions.pm @@ -173,7 +173,10 @@ sub createlogactionchain( $$ ) { $logactionchains{"$action:$level"} = $chainref = new_chain 'filter', '%' . $chain . $actionref->{actchain}++; + mark_referenced $chainref; # Just in case the action body is empty. + unless ( $targets{$action} & STANDARD ) { + my $file = find_file $chain; if ( -f $file ) { @@ -188,20 +191,46 @@ sub createlogactionchain( $$ ) { } } +sub createsimpleactionchain( $ ) { + my $action = shift; + my $chainref = new_chain 'filter', $action; + + $logactionchains{"$action:none"} = $chainref; + + mark_referenced $chainref; # Just in case the action body is empty. + + unless ( $targets{$action} & STANDARD ) { + + my $file = find_file $action; + + if ( -f $file ) { + progress_message "Processing $file..."; + + unless ( my $return = eval `cat $file` ) { + fatal_error "Couldn't parse $file: $@" if $@; + fatal_error "Couldn't do $file: $!" unless defined $return; + fatal_error "Couldn't run $file" unless $return; + } + } + } +} + # # Create an action chain and run it's associated user exit # sub createactionchain( $ ) { my ( $action , $level ) = split_action $_[0]; - if ( $level ) { + my $chainref; + + if ( $level ne '' ) { if ( $level eq 'none' ) { - $logactionchains{"$action:none"} = new_chain 'filter', $action; + createsimpleactionchain $action; } else { createlogactionchain $action , $level; } } else { - $logactionchains{"$action:none"} = new_chain 'filter', $action; + createsimpleactionchain $action; } } @@ -345,7 +374,7 @@ sub process_actions2 () { for my $target (keys %usedactions) { my ($action, $level) = split_action $target; my $actionref = $actions{$action}; - die "Null Action Reference in process_actions2" unless $actionref; + fatal_error "Null Action Reference in process_actions2" unless $actionref; for my $action1 ( keys %{$actionref->{requires}} ) { my $action2 = merge_levels $target, $action1; unless ( $usedactions{ $action2 } ) { @@ -386,8 +415,6 @@ sub process_action3( $$$$$ ) { my $actionfile = find_file "action.$action"; my $standard = ( $actionfile =~ /^$globals{SHAREDIR}/ ); - mark_referenced $chainref; # Just in case the action body is empty. - fatal_error "Missing Action File: $actionfile" unless -f $actionfile; progress_message2 "Processing $actionfile for chain $chainref->{name}...";