From 2e35ad0a1bce0d429797137d9441622a5966bcab Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Fri, 3 Dec 2010 13:40:11 -0800 Subject: [PATCH] Fix params parsing on older distros --- Shorewall/Perl/Shorewall/Config.pm | 45 +++++++++++++++++++++--------- Shorewall/releasenotes.txt | 12 +++++++- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index c9c980000..6ff6df9cc 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -2888,16 +2888,6 @@ sub unsupported_yes_no_warning( $ ) { # # Process the params file # -sub get_params_bug( \@$ ) { - my ( $params, $element ) = @_; - - warning_message "Bug in get_params()"; - print STDERR "Params\n"; - print STDERR $_ for @$params; - print STDERR "\nElement in error:\n"; - print STDERR "$element\n"; -} - sub get_params() { my $fn = find_file 'params'; @@ -2912,6 +2902,11 @@ sub get_params() { fatal_error "Processing of $fn failed" if $?; + if ( $debug ) { + print "Params:\n"; + print $_ for @params; + } + my ( $variable , $bug ); if ( $params[0] =~ /^declare/ ) { @@ -2932,10 +2927,34 @@ sub get_params() { $params{$1} = ''; } else { if ($variable) { - s/'$//; + s/"$//; $params{$variable} .= $_; } else { - get_params_bug( @params, $_ ) unless $bug++; + warning_message "Param line ($_) ignored" unless $bug++; + } + } + } + } elsif ( $params[0] =~ /^export (.*?)="/ ) { + # + # getparams interpreted by older (e.g., RHEL 5) Bash + # + # - Variable names preceded by 'export ' + # - Variable values are delimited by double quotes + # - Embedded single quotes are escaped with '\' + # + for ( @params ) { + if ( /^export (.*?)="(.*[^\\])"$/ ) { + $params{$1} = $2 unless $1 eq '_'; + } elsif ( /^export (.*?)="(.*)$/ ) { + $params{$variable=$1}="${2}\n"; + } elsif ( /^export (.*)\s+$/ || /^export (.*)=""$/ ) { + $params{$1} = ''; + } else { + if ($variable) { + s/"$//; + $params{$variable} .= $_; + } else { + warning_message "Param line ($_) ignored" unless $bug++; } } } @@ -2959,7 +2978,7 @@ sub get_params() { s/'$//; $params{$variable} .= $_; } else { - get_params_bug( @params , $_ ) unless $bug++; + warning_message "Param line ($_) ignored" unless $bug++; } } } diff --git a/Shorewall/releasenotes.txt b/Shorewall/releasenotes.txt index b69c04fe0..4ef7dc781 100644 --- a/Shorewall/releasenotes.txt +++ b/Shorewall/releasenotes.txt @@ -41,7 +41,17 @@ VI. PROBLEMS CORRECTED AND NEW FEATURES IN PRIOR RELEASES ---------------------------------------------------------------------------- 1) A bug catcher has been installed in the params file processing - logic to help determine why parameter processing is failing. + logic to help determine why parameter processing is failing. + + If you see this: + + BUG: get_params() + + then please copy/paste the displayed information and send it to the + user's or developer's mailing list. + + Note: Your firewall should still start/restart okay when the above + message appears. ---------------------------------------------------------------------------- I V. R E L E A S E 4 . 4 H I G H L I G H T S