From 9253f90ac51c123d6e43b027fa7953fe9800a1f5 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 28 Jan 2018 10:53:20 -0800 Subject: [PATCH 1/3] Correct order of optional interface and address variable handling Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Compiler.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index cdf1c7611..eb1ff20c6 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -312,10 +312,8 @@ sub generate_script_2() { push_indent; if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) { - - set_global_variables(0, 0); - handle_optional_interfaces(0); + set_global_variables(0, 0); } emit ';;'; @@ -327,16 +325,14 @@ sub generate_script_2() { push_indent; } + handle_optional_interfaces(1); set_global_variables(1,1); if ( $global_variables & NOT_RESTORE ) { - handle_optional_interfaces(1); emit ';;'; pop_indent; pop_indent; emit ( 'esac' ); - } else { - handle_optional_interfaces(1); } } else { emit( 'true' ) unless handle_optional_interfaces(1); From 09cda21dd4cfddfa70cecdad5a865e410f51cb49 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 28 Jan 2018 12:29:38 -0800 Subject: [PATCH 2/3] Revert "Correct order of optional interface and address variable handling" This reverts commit 9253f90ac51c123d6e43b027fa7953fe9800a1f5. --- Shorewall/Perl/Shorewall/Compiler.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index eb1ff20c6..cdf1c7611 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -312,8 +312,10 @@ sub generate_script_2() { push_indent; if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) { - handle_optional_interfaces(0); + set_global_variables(0, 0); + + handle_optional_interfaces(0); } emit ';;'; @@ -325,14 +327,16 @@ sub generate_script_2() { push_indent; } - handle_optional_interfaces(1); set_global_variables(1,1); if ( $global_variables & NOT_RESTORE ) { + handle_optional_interfaces(1); emit ';;'; pop_indent; pop_indent; emit ( 'esac' ); + } else { + handle_optional_interfaces(1); } } else { emit( 'true' ) unless handle_optional_interfaces(1); From 230ab06e5d1694a456a0742e1f4c5c605951f843 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 28 Jan 2018 13:10:44 -0800 Subject: [PATCH 3/3] 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;