More cleanup of hosts file exclusion

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6118 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-04-25 16:45:46 +00:00
parent e8934d79c9
commit b27cc81582
2 changed files with 11 additions and 4 deletions

View File

@ -105,8 +105,15 @@ sub validate_hosts_file()
$optionsref = \%options;
}
#
# Looking for the '!' at the beginning of a list element is more straight-foward than looking for it in the middle.
#
# Be sure we don't have a ',!' in the original
#
fatal_error "Invalid hosts list" if $hosts =~ /,!/;
#
# Now add a comma before '!'. Do it globally - add_group_to_zone() correctly checks for multiple exclusions
#
$hosts =~ s/!/,!/g;
add_group_to_zone( $zone, $type , $interface, [ split ',', $hosts ] , $optionsref);

View File

@ -81,10 +81,10 @@ sub add_group_to_zone($$$$$)
$ifacezone = '' unless defined $ifacezone;
for my $host ( @$networks ) {
if ( $host =~ /^!.*/ ) {
fatal_error "Invalid host group: @$networks" if $switched;
if ( substr( $host, 0, 1 ) eq '!' ) {
fatal_error "Only one exclusion allowed in a host list" if $switched;
$switched = 1;
$host =~ s/^!//;
$host = substr( $host, 1 );
$new = \@exclusions;
}