From 46a97b0a0a2ab1b23ee3ca63980598f2bdced202 Mon Sep 17 00:00:00 2001 From: teastep Date: Sat, 10 Mar 2007 04:41:29 +0000 Subject: [PATCH] Expand shell variables in macro files; correct export of temp dir name git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5480 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- New/compiler.pl | 17 +++++++++++++---- New/lib.config | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/New/compiler.pl b/New/compiler.pl index 2fcc80297..bfabd9ef7 100755 --- a/New/compiler.pl +++ b/New/compiler.pl @@ -3435,6 +3435,12 @@ sub finish_section ( $ ) { sub process_rule1 ( $$$$$$$$$ ); +sub expand_shell_variables( $ ) { + my $line = $_[0]; + $line = $1 . $ENV{$2} . $3 while $line =~ /^(.*?)\$([a-zA-Z]\w*\b)(.*)$/; + $line; +} + # # Expand a macro rule from the rules file # @@ -3451,7 +3457,8 @@ sub process_macro ( $$$$$$$$$$$ ) { next if $line =~ /^\s*$/; $line =~ s/\s+/ /g; $line =~ s/#.*$//; - + $line = expand_shell_variables $line unless $macrofile =~ /^($env{SHAREDIR})/; + my ( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $mrate, $muser ) = split /\s+/, $line; $mtarget = merge_levels $target, $mtarget; @@ -4188,7 +4195,7 @@ sub process_action( $$$$$$$$$$ ) { $action , '' ); } - + # # Generate chain for non-builtin action invocation # @@ -4207,7 +4214,8 @@ sub process_action3( $$$$$ ) { next if $line =~ /^\s*#/; next if $line =~ /^\s*$/; $line =~ s/\s+/ /g; - $line =~ s/#.*$//; + $line =~ s/#.*$//; + $line = expand_shell_variables $line unless $actionfile =~ /^($env{SHAREDIR})/; my ($target, $source, $dest, $proto, $ports, $sports, $rate, $user , $extra ) = split /\s+/, $line; @@ -4246,7 +4254,8 @@ sub process_action3( $$$$$ ) { next if $line =~ /^\s*$/; $line =~ s/\s+/ /g; $line =~ s/#.*$//; - + $line = expand_shell_variables $line unless $actionfile =~ /^($env{SHAREDIR})/; + my ( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $mrate, $muser ) = split /\s+/, $line; if ( $mtarget =~ /^PARAM:?/ ) { diff --git a/New/lib.config b/New/lib.config index dd5475f9e..cc1d65ab0 100644 --- a/New/lib.config +++ b/New/lib.config @@ -2174,7 +2174,7 @@ do_initialize() { strip_file tos strip_file_and_lib_load tunnels tunnels report_capabilities1 > $TMP_DIR/capabilities - export $TMP_DIR + export TMP_DIR fi # # Clear $FW