diff --git a/New/Shorewall/Config.pm b/New/Shorewall/Config.pm index a5156b8f6..08ec95811 100644 --- a/New/Shorewall/Config.pm +++ b/New/Shorewall/Config.pm @@ -28,7 +28,7 @@ use warnings; use Shorewall::Common; our @ISA = qw(Exporter); -our @EXPORT = qw(find_file get_configuration report_capabilities propagateconfig append_file run_user_exit generate_aux_config %config %env %capabilities ); +our @EXPORT = qw(find_file expand_shell_variables get_configuration report_capabilities propagateconfig append_file run_user_exit generate_aux_config %config %env %capabilities ); our @EXPORT_OK = (); our @VERSION = 1.00; @@ -251,6 +251,13 @@ sub report_capabilities() { } } +# +# Some files can have shell variables embedded. This function expands them from %ENV. +# +sub expand_shell_variables( $ ) { + my $line = $_[0]; $line = $1 . ( $ENV{$2} || '' ) . $3 while $line =~ /^(.*?)\$([a-zA-Z]\w*)(.*)$/; $line; +} + # # Read the shorewall.conf file and establish global hashes %config and %env. # @@ -265,7 +272,8 @@ sub get_configuration() { chomp $line; next if $line =~ /^\s*#/; next if $line =~ /^\s*$/; - $line = $1 . ( $ENV{$2} || '' ) . $3 while $line =~ /^(.*?)\$([a-zA-Z]\w*)(.*)$/; + + expand_shell_variables( $line ); if ( $line =~ /^([a-zA-Z]\w*)\s*=\s*(.*)$/ ) { my ($var, $val) = ($1, $2); diff --git a/New/Shorewall/Macros.pm b/New/Shorewall/Macros.pm index a1b80a575..d16fa341b 100644 --- a/New/Shorewall/Macros.pm +++ b/New/Shorewall/Macros.pm @@ -32,7 +32,6 @@ use strict; our @ISA = qw(Exporter); our @EXPORT = qw( find_macro - expand_shell_variables split_action substitute_action merge_macro_source_dest @@ -61,13 +60,6 @@ sub find_macro( $ ) } } -# -# Macro and action files can have shell variables embedded. This function expands them from %ENV. -# -sub expand_shell_variables( $ ) { - my $line = $_[0]; $line = $1 . ( $ENV{$2} || '' ) . $3 while $line =~ /^(.*?)\$([a-zA-Z]\w*)(.*)$/; $line; -} - # # Return ( action, level[:tag] ) from passed full action # diff --git a/New/compiler.pl b/New/compiler.pl index e84341fd3..22e550897 100755 --- a/New/compiler.pl +++ b/New/compiler.pl @@ -80,10 +80,6 @@ use Shorewall::Proxyarp; # It's color theme drives my eyes crazy. # It's indentation scheme is unfathomable. # -# Now I could spend my time trying to configure cperl-mode to do what I want; but why? -# Like most Open Source Software, it's documentation is pathetic. I would rather spend -# my time making Shorewall better as opposed to working around braindead editing modes. -# # Bottom line. I use quoting techinques other than 'here documents'. # @@ -92,7 +88,7 @@ sub generate_script_1 { my $date = localtime; - emit join ( '', "#\n# Compiled firewall script generated by Shorewall-pl ", $env{VERSION}, " - $date\n#" ); + emit "#\n# Compiled firewall script generated by Shorewall-pl $env{VERSION} - $date\n#"; if ( $ENV{EXPORT} ) { emitj ( 'SHAREDIR=/usr/share/shorewall-lite',