From b43bee2c62331d233400c3c238da3f05493f923a Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Wed, 22 Jun 2011 06:53:15 -0700 Subject: [PATCH] Streamline PERL in action.Drop and action.Reject - Rename read_action_param => get_action_params - Allow it to accept a list of indexes and to return a list Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Config.pm | 14 +++++++++----- Shorewall/action.Drop | 4 +--- Shorewall/action.Reject | 4 +--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 7dfa50707..a1ddcb969 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -52,7 +52,7 @@ our @EXPORT = qw( progress_message2 progress_message3 supplied - read_action_param + get_action_params set_action_param ); @@ -1840,11 +1840,15 @@ sub default_action_params { } } -sub read_action_param( $ ) { - my $i = shift; +sub get_action_params { + my @values; - fatal_error "Parameter numbers must be numeric" unless $i =~ /^\d+$/; - $actparms{$i}; + for ( @_ ) { + fatal_error "Parameter numbers must be numeric" unless $_ =~ /^\d+$/; + push @values, $actparms{$_}; + } + + @values; } sub set_action_param( $$ ) { diff --git a/Shorewall/action.Drop b/Shorewall/action.Drop index 2848228b5..a1db4c1dd 100644 --- a/Shorewall/action.Drop +++ b/Shorewall/action.Drop @@ -35,11 +35,9 @@ FORMAT 2 BEGIN PERL use Shorewall::Config; -my $p1 = read_action_param(1); +my ($p1, $p2, $p3 ) = get_action_params(1, 2, 3); if ( defined $p1 && $p1 eq 'audit' ) { - my ( $p2, $p3 ) = ( read_action_param(2) , read_action_param(3) ); - set_action_param( 2, 'A_REJECT') unless defined $p2; set_action_param( 3, 'A_DROP') unless defined $p3; }; diff --git a/Shorewall/action.Reject b/Shorewall/action.Reject index 3d11be9c3..a644efe54 100644 --- a/Shorewall/action.Reject +++ b/Shorewall/action.Reject @@ -31,11 +31,9 @@ FORMAT 2 BEGIN PERL use Shorewall::Config; -my $p1 = read_action_param(1); +my ( $p1, $p2, $p3 ) = get_action_params(1, 2, 3); if ( defined $p1 && $p1 eq 'audit' ) { - my ( $p2, $p3 ) = ( read_action_param(2) , read_action_param(3) ); - set_action_param( 2, 'A_REJECT') unless defined $p2; set_action_param( 3, 'A_REJECT') unless defined $p3; };