Add quotes on deprecated and obsolete options if appropriate

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2011-06-24 11:47:34 -07:00
parent 129d1739d1
commit ca9276fd7e

View File

@ -2875,6 +2875,20 @@ sub set_shorewall_dir( $ ) {
# #
# Update the configuration file # Update the configuration file
# #
sub conditional_quote( $ ) {
my $val = shift;
unless ( $val =~ /^[-\w\/\.]*$/ ) {
#
# Funny characters (including whitespace) -- use double quotes unless the thing is single-quoted
#
$val = qq("$val") unless $val =~ /^'.+'$/;
}
$val;
}
sub update_config_file( $ ) { sub update_config_file( $ ) {
my $annotate = shift; my $annotate = shift;
@ -2926,12 +2940,7 @@ sub update_config_file( $ ) {
} }
unless ( $val =~ /^[-\w\/\.]*$/ ) { $val = conditional_quote $val;
#
# Funny characters (including whitespace) -- use double quotes unless the thing is single-quoted
#
$val = qq("$val") unless $val =~ /^'.+'$/;
}
$_ = "$var=$val\n"; $_ = "$var=$val\n";
} }
@ -2944,7 +2953,7 @@ sub update_config_file( $ ) {
my $heading_printed; my $heading_printed;
for ( @undocumented ) { for ( @undocumented ) {
if ( defined $rawconfig{$_} ) { if ( defined ( my $val = $rawconfig{$_} ) ) {
unless ( $heading_printed ) { unless ( $heading_printed ) {
print $output <<'EOF'; print $output <<'EOF';
@ -2958,15 +2967,17 @@ EOF
$heading_printed = 1; $heading_printed = 1;
} }
print $output "$_=$rawconfig{$_}\n\n"; $val = conditional_quote $val;
print $output "$_=$val\n\n";
} }
} }
$heading_printed = 0; $heading_printed = 0;
for ( keys %deprecated ) { for ( keys %deprecated ) {
if ( supplied $rawconfig{$_} ) { if ( supplied( my $val = $rawconfig{$_} ) ) {
if ( lc $rawconfig{$_} ne $deprecated{$_} ) { if ( lc $val ne $deprecated{$_} ) {
unless ( $heading_printed ) { unless ( $heading_printed ) {
print $output <<'EOF'; print $output <<'EOF';
@ -2979,7 +2990,9 @@ EOF
$heading_printed = 1; $heading_printed = 1;
} }
print $output "$_=$rawconfig{$_}\n\n"; $val = conditional_quote $val;
print $output "$_=$val\n\n";
warning_message "Deprecated option $_ is being set in your $product.conf file"; warning_message "Deprecated option $_ is being set in your $product.conf file";
} }