diff --git a/New/Shorewall/Common.pm b/New/Shorewall/Common.pm index c0aba2820..b709df791 100644 --- a/New/Shorewall/Common.pm +++ b/New/Shorewall/Common.pm @@ -56,6 +56,7 @@ our @EXPORT = qw(ALLIPv4 $command $doing $done + $verbose ); our @EXPORT_OK = (); our @VERSION = 1.00; @@ -73,12 +74,18 @@ our $line = ''; # Current config file line our ( $command, $doing, $done ) = qw/ compile Compiling Compiled/; #describe the current command, it's present progressive, and it's completion. +our $verbose; + my $object = 0; # Object file Handle Reference my $lastlineblank = 0; # Avoid extra blank lines in the output my $indent = ''; my ( $dir, $file ); # Object's Directory and File my $tempfile; # Temporary File Name +BEGIN { + $verbose = $ENV{VERBOSE} || 0; +} + # # Fatal Error # @@ -166,28 +173,27 @@ sub save_progress_message_short( $ ) { emit "progress_message $_[0]" if $object; } -sub progress_message { - if ( $ENV{VERBOSE} > 1 ) { - my $ts = ''; - $ts = ( localtime ) . ' ' if $ENV{TIMESTAMP}; - print "${ts}@_\n"; - } -} - sub timestamp() { my ($sec, $min, $hr) = ( localtime ) [0,1,2]; printf '%02d:%02d:%02d ', $hr, $min, $sec; } +sub progress_message { + if ( $verbose > 1 ) { + timestamp if $ENV{TIMESTAMP}; + print "@_\n"; + } +} + sub progress_message2 { - if ( $ENV{VERBOSE} > 0 ) { + if ( $verbose > 0 ) { timestamp if $ENV{TIMESTAMP}; print "@_\n"; } } sub progress_message3 { - if ( $ENV{VERBOSE} >= 0 ) { + if ( $verbose >= 0 ) { timestamp if $ENV{TIMESTAMP}; print "@_\n"; } diff --git a/New/Shorewall/Config.pm b/New/Shorewall/Config.pm index e22f11047..0efd43c43 100644 --- a/New/Shorewall/Config.pm +++ b/New/Shorewall/Config.pm @@ -370,9 +370,10 @@ sub read_a_line { $currentlinenumber++; next if $nextline =~ /^\s*#/; next if $nextline =~ /^\s*$/; + $nextline =~ s/#.*$//; - chomp $nextline; + $nextline =~ s/\s+/ /g if $verbose >= 2; if ( substr( $nextline, -1, 1 ) eq '\\' ) { $line .= substr( $nextline, 0, -1 ); @@ -480,14 +481,14 @@ sub get_configuration() { open_file $file; while ( read_a_line ) { - if ( $line =~ /^([a-zA-Z]\w*)\s*=\s*(.*)$/ ) { + if ( $line =~ /^([a-zA-Z]\w*)=(.*?)\s*$/ ) { my ($var, $val) = ($1, $2); unless ( exists $config{$var} ) { warning_message "Unknown configuration option \"$var\" ignored"; next; } - $config{$var} = $val =~ /\"([^\"]*)\"$/ ? $1 : $val; + $config{$var} = ( $val =~ /\"([^\"]*)\"$/ ? $1 : $val ); } else { fatal_error "Unrecognized entry in $file: $line"; } @@ -510,7 +511,7 @@ sub get_configuration() { next if $line =~ /^\s*#/; next if $line =~ /^\s*$/; - if ( $line =~ /^([a-zA-Z]\w*)\s*=\s*(.*)$/ ) { + if ( $line =~ /^([a-zA-Z]\w*)=(.*)$/ ) { my ($var, $val) = ($1, $2); unless ( exists $capabilities{$var} ) { warning_message "Unknown capability \"$var\" ignored";