From 7f0f4516d729f1b3688f20881d418fa8c0228fa8 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 30 Aug 2010 12:29:39 -0700 Subject: [PATCH] Rework handle_optional_interfaces() somewhat Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Providers.pm | 16 ++++++++-------- Shorewall/Perl/Shorewall/Zones.pm | 11 ++++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Providers.pm b/Shorewall/Perl/Shorewall/Providers.pm index 15a9ac53b..d39ded76d 100644 --- a/Shorewall/Perl/Shorewall/Providers.pm +++ b/Shorewall/Perl/Shorewall/Providers.pm @@ -845,14 +845,14 @@ sub lookup_provider( $ ) { # sub handle_optional_interfaces( $ ) { - my $returnvalue = verify_required_interfaces( shift ); - my $require = $config{REQUIRE_INTERFACE}; - my $wildcards = 0; - my $interfaces = find_interfaces_by_option1 'optional', $wildcards; - - emit( 'HAVE_INTERFACE=', '' ) if $require; + my ( $interfaces, $wildcards ) = find_interfaces_by_option1 'optional'; if ( @$interfaces ) { + my $require = $config{REQUIRE_INTERFACE}; + + verify_required_interfaces( shift ); + + emit( 'HAVE_INTERFACE=', '' ) if $require; # # Clear the '_IS_USABLE' variables # @@ -960,10 +960,10 @@ sub handle_optional_interfaces( $ ) { ); } - $returnvalue = 1; + return 1; } - $returnvalue; + verify_required_interfaces( shift ); } # diff --git a/Shorewall/Perl/Shorewall/Zones.pm b/Shorewall/Perl/Shorewall/Zones.pm index 24f33df9b..8296d46ee 100644 --- a/Shorewall/Perl/Shorewall/Zones.pm +++ b/Shorewall/Perl/Shorewall/Zones.pm @@ -1292,10 +1292,10 @@ sub find_interfaces_by_option( $ ) { # Returns reference to array of interfaces with the passed option. Unlike the preceding function, this one: # # - All entries in %interfaces are searched. -# - The second argument is used to return an indication of the presents of wildcard interfaces +# - Returns a two-element list; the second element indicates whether any members of the list have wildcard physical names # -sub find_interfaces_by_option1( $\$ ) { - my ( $option, $wildref) = @_; +sub find_interfaces_by_option1( $ ) { + my $option = $_[0]; my @ints = (); my $wild = 0; @@ -1313,8 +1313,9 @@ sub find_interfaces_by_option1( $\$ ) { } } - $$wildref = $wild; - \@ints; + return unless defined wantarray; + + wantarray ? ( \@ints, $wild ) : \@ints; } #