Allow default value for trivalued options

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6066 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-04-22 19:30:42 +00:00
parent ac619bdc05
commit 52f201b6b8

View File

@ -477,20 +477,24 @@ sub default_yes_no ( $$ ) {
# #
# Check a tri-valued variable # Check a tri-valued variable
# #
sub check_trivalue( $ ) { sub check_trivalue( $$ ) {
my $var = $_[0]; my ( $var, $default) = @_;
my $val = "\L$config{$var}"; my $val = "\L$config{$var}";
if ( defined $val ) { if ( defined $val ) {
if ( $val eq 'yes' ) { if ( $val eq 'yes' || $val eq 'on' ) {
$config{$var} = 'yes'; $config{$var} = 'yes';
} elsif ( $val eq 'no' ) { } elsif ( $val eq 'no' || $val eq 'off' ) {
$config{$var} = 'no'; $config{$var} = 'no';
} elsif ( $val eq 'keep' ) { } elsif ( $val eq 'keep' ) {
$config{$var} = ''; $config{$var} = '';
} elsif ( $val ne '' ) { } elsif ( $val eq '' ) {
$config{var} = $default
} else {
fatal_error "Invalid value ( $val ) for $var"; fatal_error "Invalid value ( $val ) for $var";
} }
} else {
$config{var} = $default
} }
} }
@ -811,8 +815,8 @@ sub get_configuration( $ ) {
$config{IP_FORWARDING} = 'On'; $config{IP_FORWARDING} = 'On';
} }
check_trivalue ( 'ROUTE_FILTER' ); check_trivalue ( 'ROUTE_FILTER', '' );
check_trivalue ( 'LOG_MARTIANS' ); check_trivalue ( 'LOG_MARTIANS', '' );
default_yes_no 'ADD_IP_ALIASES' , 'Yes'; default_yes_no 'ADD_IP_ALIASES' , 'Yes';
default_yes_no 'ADD_SNAT_ALIASES' , ''; default_yes_no 'ADD_SNAT_ALIASES' , '';