mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-25 15:48:56 +01:00
More param handling fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
081cf30447
commit
3873ebe06a
@ -5188,23 +5188,19 @@ sub get_params( $ ) {
|
|||||||
$shell = BASH;
|
$shell = BASH;
|
||||||
|
|
||||||
for ( @params ) {
|
for ( @params ) {
|
||||||
my $var = $1;
|
chomp;
|
||||||
|
if ( /^declare -x (.*?)="(.*[^\\])"$/ ) {
|
||||||
unless ( $var =~ /\(/ ) {
|
$params{$1} = $2 unless $1 eq '_';
|
||||||
if ( /^declare -x (.*?)="(.*[^\\])"$/ ) {
|
} elsif ( /^declare -x (.*?)="(.*)$/ ) {
|
||||||
$params{$var} = $2 unless $1 eq '_';
|
$params{$variable=$1} = $2 eq '"' ? '' : "${2}\n";
|
||||||
} elsif ( /^declare -x (.*?)="(.*)$/ ) {
|
} elsif ( /^declare -x (.*)\s+$/ || /^declare -x (.*)=""$/ ) {
|
||||||
$params{$variable=$var} = $2 eq '"' ? '' : "${2}\n";
|
$params{$1} = '';
|
||||||
} elsif ( /^declare -x (.*)\s+$/ || /^declare -x (.*)=""$/ ) {
|
} else {
|
||||||
$params{$var} = '';
|
if ($variable) {
|
||||||
|
s/"$//;
|
||||||
|
$params{$variable} .= $_;
|
||||||
} else {
|
} else {
|
||||||
chomp;
|
warning_message "Param line ($_) ignored" unless $bug++;
|
||||||
if ($variable) {
|
|
||||||
s/"$//;
|
|
||||||
$params{$variable} .= $_;
|
|
||||||
} else {
|
|
||||||
warning_message "Param line ($_) ignored" unless $bug++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5220,23 +5216,19 @@ sub get_params( $ ) {
|
|||||||
$shell = OLDBASH;
|
$shell = OLDBASH;
|
||||||
|
|
||||||
for ( @params ) {
|
for ( @params ) {
|
||||||
my $var = $1;
|
chomp;
|
||||||
|
if ( /^export (.*?)="(.*[^\\])"$/ ) {
|
||||||
unless ( $var =~ /\(/ ) {
|
$params{$1} = $2 unless $1 eq '_';
|
||||||
if ( /^export (.*?)="(.*[^\\])"$/ ) {
|
} elsif ( /^export (.*?)="(.*)$/ ) {
|
||||||
$params{$var} = $2 unless $1 eq '_';
|
$params{$variable=$1} = $2 eq '"' ? '' : "${2}\n";
|
||||||
} elsif ( /^export (.*?)="(.*)$/ ) {
|
} elsif ( /^export ([^\s=]+)\s*$/ || /^export (.*)=""$/ ) {
|
||||||
$params{$variable=$var} = $2 eq '"' ? '' : "${2}\n";
|
$params{$1} = '';
|
||||||
} elsif ( /^export ([^\s=]+)\s*$/ || /^export (.*)=""$/ ) {
|
} else {
|
||||||
$params{$var} = '';
|
if ($variable) {
|
||||||
|
s/"$//;
|
||||||
|
$params{$variable} .= $_;
|
||||||
} else {
|
} else {
|
||||||
chomp;
|
warning_message "Param line ($_) ignored" unless $bug++;
|
||||||
if ($variable) {
|
|
||||||
s/"$//;
|
|
||||||
$params{$variable} .= $_;
|
|
||||||
} else {
|
|
||||||
warning_message "Param line ($_) ignored" unless $bug++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5251,6 +5243,7 @@ sub get_params( $ ) {
|
|||||||
$shell = ASH;
|
$shell = ASH;
|
||||||
|
|
||||||
for ( @params ) {
|
for ( @params ) {
|
||||||
|
chomp;
|
||||||
if ( /^export (.*?)='(.*'"'"')$/ ) {
|
if ( /^export (.*?)='(.*'"'"')$/ ) {
|
||||||
$params{$variable=$1}="${2}\n";
|
$params{$variable=$1}="${2}\n";
|
||||||
} elsif ( /^export (.*?)='(.*)'$/ ) {
|
} elsif ( /^export (.*?)='(.*)'$/ ) {
|
||||||
@ -5258,7 +5251,6 @@ sub get_params( $ ) {
|
|||||||
} elsif ( /^export (.*?)='(.*)$/ ) {
|
} elsif ( /^export (.*?)='(.*)$/ ) {
|
||||||
$params{$variable=$1}="${2}\n";
|
$params{$variable=$1}="${2}\n";
|
||||||
} else {
|
} else {
|
||||||
chomp;
|
|
||||||
if ($variable) {
|
if ($variable) {
|
||||||
s/'$//;
|
s/'$//;
|
||||||
$params{$variable} .= $_;
|
$params{$variable} .= $_;
|
||||||
@ -5270,9 +5262,13 @@ sub get_params( $ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for ( keys %params ) {
|
for ( keys %params ) {
|
||||||
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' ) {
|
if ( /[^\w]/ ) {
|
||||||
fatal_error "The variable name $_ is reserved and may not be set in the params file"
|
delete $params{$_}
|
||||||
if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_};
|
} else {
|
||||||
|
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' ) {
|
||||||
|
fatal_error "The variable name $_ is reserved and may not be set in the params file"
|
||||||
|
if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5322,6 +5318,8 @@ sub export_params() {
|
|||||||
next if exists $compiler_params{$param};
|
next if exists $compiler_params{$param};
|
||||||
|
|
||||||
my $value = $params{$param};
|
my $value = $params{$param};
|
||||||
|
|
||||||
|
chomp $value;
|
||||||
#
|
#
|
||||||
# Values in %params are generated from the output of 'export -p'.
|
# Values in %params are generated from the output of 'export -p'.
|
||||||
# The different shells have different conventions for delimiting
|
# The different shells have different conventions for delimiting
|
||||||
@ -5332,6 +5330,8 @@ sub export_params() {
|
|||||||
$value =~ s/\\"/"/g;
|
$value =~ s/\\"/"/g;
|
||||||
} elsif ( $shell == OLDBASH ) {
|
} elsif ( $shell == OLDBASH ) {
|
||||||
$value =~ s/\\'/'/g;
|
$value =~ s/\\'/'/g;
|
||||||
|
$value =~ s/\\"/"/g;
|
||||||
|
$value =~ s/\\\\/\\/g;
|
||||||
} else {
|
} else {
|
||||||
$value =~ s/'"'"'/'/g;
|
$value =~ s/'"'"'/'/g;
|
||||||
}
|
}
|
||||||
@ -5344,7 +5344,9 @@ sub export_params() {
|
|||||||
#
|
#
|
||||||
# We will use double quotes and escape embedded quotes with \.
|
# We will use double quotes and escape embedded quotes with \.
|
||||||
#
|
#
|
||||||
if ( $value =~ /[\s()['"]/ ) {
|
if ( $value =~ /^"[^"]*"$/ ) {
|
||||||
|
emit "$param=$value";
|
||||||
|
} elsif ( $value =~ /[\s()['"]/ ) {
|
||||||
$value =~ s/"/\\"/g;
|
$value =~ s/"/\\"/g;
|
||||||
emit "$param='$value'";
|
emit "$param='$value'";
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user