From 230ab06e5d1694a456a0742e1f4c5c605951f843 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 28 Jan 2018 13:10:44 -0800 Subject: [PATCH] Reverse order of required-interface and address variable processing Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Compiler.pm | 12 +++++++----- Shorewall/Perl/Shorewall/Providers.pm | 16 +++------------- Shorewall/Perl/Shorewall/Zones.pm | 3 ++- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index cdf1c7611..5b587c6d7 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -313,9 +313,9 @@ sub generate_script_2() { if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) { + verify_required_interfaces(0); set_global_variables(0, 0); - - handle_optional_interfaces(0); + handle_optional_interfaces; } emit ';;'; @@ -327,19 +327,21 @@ sub generate_script_2() { push_indent; } + verify_required_interfaces(1); set_global_variables(1,1); if ( $global_variables & NOT_RESTORE ) { - handle_optional_interfaces(1); + handle_optional_interfaces; emit ';;'; pop_indent; pop_indent; emit ( 'esac' ); } else { - handle_optional_interfaces(1); + handle_optional_interfaces; } } else { - emit( 'true' ) unless handle_optional_interfaces(1); + verify_required_interfaces(1); + emit( 'true' ) unless handle_optional_interfaces; } pop_indent; diff --git a/Shorewall/Perl/Shorewall/Providers.pm b/Shorewall/Perl/Shorewall/Providers.pm index 35a1aae12..1c78c918d 100644 --- a/Shorewall/Perl/Shorewall/Providers.pm +++ b/Shorewall/Perl/Shorewall/Providers.pm @@ -2195,17 +2195,13 @@ sub provider_realm( $ ) { } # -# This function is called by the compiler when it is generating the detect_configuration() function. -# The function calls Shorewall::Zones::verify_required_interfaces then emits code to set the -# ..._IS_USABLE interface variables appropriately for the optional interfaces +# Perform processing related to optional interfaces. Returns true if there are optional interfaces. + # -# Returns true if there were required or optional interfaces -# -sub handle_optional_interfaces( $ ) { +sub handle_optional_interfaces() { my @interfaces; my $wildcards; - # # First do the provider interfacess. Those that are real providers will never have wildcard physical # names but they might derive from wildcard interface entries. Optional interfaces which do not have @@ -2229,10 +2225,6 @@ sub handle_optional_interfaces( $ ) { if ( @interfaces ) { my $require = $config{REQUIRE_INTERFACE}; - my $gencase = shift; - - verify_required_interfaces( $gencase ); - emit '' if $gencase; emit( 'HAVE_INTERFACE=', '' ) if $require; # @@ -2396,8 +2388,6 @@ sub handle_optional_interfaces( $ ) { return 1; } - - verify_required_interfaces( shift ); } # diff --git a/Shorewall/Perl/Shorewall/Zones.pm b/Shorewall/Perl/Shorewall/Zones.pm index 44bd46f2a..fde6876f1 100644 --- a/Shorewall/Perl/Shorewall/Zones.pm +++ b/Shorewall/Perl/Shorewall/Zones.pm @@ -2021,6 +2021,7 @@ sub verify_required_interfaces( $ ) { emit( "esac\n" ); + $returnvalue = 1; } $interfaces = find_interfaces_by_option( 'required' ); @@ -2066,7 +2067,7 @@ sub verify_required_interfaces( $ ) { emit( ';;' ); pop_indent; pop_indent; - emit( 'esac' ); + emit( "esac\n" ); } $returnvalue = 1;