Avoid two-stage processing of shorewall.conf when not updating.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2011-06-22 10:56:25 -07:00
parent 106ba52362
commit ba7d5fd720
2 changed files with 37 additions and 32 deletions

View File

@ -593,7 +593,7 @@ sub compiler {
# #
# S H O R E W A L L . C O N F A N D C A P A B I L I T I E S # S H O R E W A L L . C O N F A N D C A P A B I L I T I E S
# #
get_configuration( $export ); get_configuration( $export , $update );
report_capabilities unless $config{LOAD_HELPERS_ONLY}; report_capabilities unless $config{LOAD_HELPERS_ONLY};

View File

@ -2853,8 +2853,10 @@ sub set_shorewall_dir( $ ) {
# #
# Small functions called by get_configuration. We separate them so profiling is more useful # Small functions called by get_configuration. We separate them so profiling is more useful
# #
sub process_shorewall_conf() { sub process_shorewall_conf( $ ) {
my $update = shift;
my $file = find_file "$product.conf"; my $file = find_file "$product.conf";
my $config = $update ? \%rawconfig : \%config;
if ( -f $file ) { if ( -f $file ) {
$globals{CONFIGDIR} = $configfile = $file; $globals{CONFIGDIR} = $configfile = $file;
@ -2865,9 +2867,9 @@ sub process_shorewall_conf() {
first_entry "Processing $file..."; first_entry "Processing $file...";
# #
# Don't expand shell variables # Don't expand shell variables if $config
# #
while ( read_a_line(0,0) ) { while ( read_a_line( 0,! $update ) ) {
if ( $currentline =~ /^\s*([a-zA-Z]\w*)=(.*?)\s*$/ ) { if ( $currentline =~ /^\s*([a-zA-Z]\w*)=(.*?)\s*$/ ) {
my ($var, $val) = ($1, $2); my ($var, $val) = ($1, $2);
unless ( exists $config{$var} ) { unless ( exists $config{$var} ) {
@ -2875,7 +2877,7 @@ sub process_shorewall_conf() {
next; next;
} }
$rawconfig{$var} = ( $val =~ /\"([^\"]*)\"$/ ? $1 : $val ); $config->{$var} = ( $val =~ /\"([^\"]*)\"$/ ? $1 : $val );
} else { } else {
fatal_error "Unrecognized entry"; fatal_error "Unrecognized entry";
} }
@ -2886,6 +2888,8 @@ sub process_shorewall_conf() {
} else { } else {
fatal_error "$file does not exist!"; fatal_error "$file does not exist!";
} }
if ( $config ) {
# #
# Now that we have the raw values stored, we expand shell variables and store the expanded values # Now that we have the raw values stored, we expand shell variables and store the expanded values
# #
@ -2917,6 +2921,7 @@ sub process_shorewall_conf() {
$config{$opt} = $v; $config{$opt} = $v;
} }
} }
}
# #
# Process the records in the capabilities file # Process the records in the capabilities file
@ -3176,9 +3181,9 @@ sub export_params() {
# - Read the capabilities file, if any # - Read the capabilities file, if any
# - establish global hashes %config , %globals and %capabilities # - establish global hashes %config , %globals and %capabilities
# #
sub get_configuration( $ ) { sub get_configuration( $$ ) {
my $export = $_[0]; my ( $export, $update ) = @_;
$globals{EXPORT} = $export; $globals{EXPORT} = $export;
@ -3190,7 +3195,7 @@ sub get_configuration( $ ) {
get_params; get_params;
process_shorewall_conf; process_shorewall_conf( $update );
ensure_config_path; ensure_config_path;