From 3392312cefb5a11bf198211b0503c3ebfa7783d5 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 9 Jan 2011 13:12:36 -0800 Subject: [PATCH] Automate the maintenance of the hash of compiler-defined entries in %params --- Shorewall/Perl/Shorewall/Config.pm | 37 ++++++++++++++++++------------ Shorewall/Perl/Shorewall/Zones.pm | 2 +- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index c37eb4043..a085911a7 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -103,6 +103,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script which qt ensure_config_path + add_param export_params get_configuration require_capability @@ -125,7 +126,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script $debug %config %globals - %params F_IPV4 F_IPV6 @@ -278,6 +278,10 @@ our @openstack; # our %params; # +# Entries that the compiler adds to %params +# +our %compiler_params; +# # Action parameters # our %actparms; @@ -718,13 +722,17 @@ sub initialize( $ ) { $shorewall_dir = ''; #Shorewall Directory $debug = 0; - + %params = ( root => '', system => '', command => '', files => '', destination => '' ); + %compiler_params = (); + + $compiler_params{$_} = 1 for keys %params; + %actparms = (); } @@ -2742,7 +2750,7 @@ sub ensure_config_path() { open_file $f; - $params{CONFDIR} = $globals{CONFDIR}; + add_param( CONFDIR => $globals{CONFDIR} ); while ( read_a_line ) { if ( $currentline =~ /^\s*([a-zA-Z]\w*)=(.*?)\s*$/ ) { @@ -3025,25 +3033,24 @@ sub get_params() { } } +# +# Add an entry to %params +# +sub add_param( $$ ) { + my ( $param, $value ) = @_; + + $params{$param} = $value; + $compiler_params{$param} = 1; +} + # # emit param=value for each param set in the params file # sub export_params() { - # - # These are variables that the compiler adds to the hash - # - my %exclude = ( root => 1, - system => 1, - files => 1, - destination => 1, - command => 1, - FW => 1, - CONFDIR => 1 ); - my $count = 0; while ( my ( $param, $value ) = each %params ) { - next if $exclude{$param}; + next if $compiler_params{$param}; # # Don't export pairs from %ENV # diff --git a/Shorewall/Perl/Shorewall/Zones.pm b/Shorewall/Perl/Shorewall/Zones.pm index c07cd2271..8cfdc5243 100644 --- a/Shorewall/Perl/Shorewall/Zones.pm +++ b/Shorewall/Perl/Shorewall/Zones.pm @@ -429,7 +429,7 @@ sub process_zone( \$ ) { fatal_error 'Firewall zone may not be nested' if @parents; fatal_error "Only one firewall zone may be defined ($zone)" if $firewall_zone; $firewall_zone = $zone; - $params{FW} = $zone; + add_param( FW => $zone ); $type = FIREWALL; } elsif ( $type eq 'vserver' ) { fatal_error 'Vserver zones may not be nested' if @parents;