From 3bd9d31c051b7783b676df49a4c6bc21c2785500 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Wed, 15 Jul 2009 12:32:26 -0700 Subject: [PATCH] Correct NOROUTE logic when no providers --- Shorewall/Perl/Shorewall/Providers.pm | 30 +++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Providers.pm b/Shorewall/Perl/Shorewall/Providers.pm index 543c68f4a..b4ef55daf 100644 --- a/Shorewall/Perl/Shorewall/Providers.pm +++ b/Shorewall/Perl/Shorewall/Providers.pm @@ -608,10 +608,6 @@ sub setup_null_routing() { sub start_providers() { require_capability( 'MANGLE_ENABLED' , 'a non-empty providers file' , 's' ); - emit "\nif [ -z \"\$NOROUTES\" ]; then"; - - push_indent; - emit ( '#', '# Undo any changes made since the last time that we [re]started -- this will not restore the default route', '#', @@ -713,7 +709,11 @@ sub setup_providers() { my $fn = open_file 'providers'; - first_entry sub() { progress_message2 "$doing $fn..."; start_providers; }; + first_entry sub() { + emit "\nif [ -z \"\$NOROUTES\" ]; then"; + push_indent; + progress_message2 "$doing $fn..."; + start_providers; }; add_a_provider, $providers++ while read_a_line; @@ -733,29 +733,33 @@ sub setup_providers() { setup_null_routing if $config{NULL_ROUTE_RFC1918}; emit "\nrun_ip route flush cache"; + # + # This completes the if block begun in the first_entry closure + # pop_indent; emit "fi\n"; setup_route_marking if @routemarked_interfaces; } else { + emit "\nif [ -z \"\$NOROUTES\" ]; then"; + + push_indent; + emit "\nundo_routing"; emit 'restore_default_route'; + if ( $config{NULL_ROUTE_RFC1918} ) { - emit "\nif [ -z \"\$NOROUTES\" ]; then"; - - push_indent; - emit ( '#', '# Initialize the file that holds \'undo\' commands', '#', '> ${VARDIR}/undo_routing' ); setup_null_routing; emit "\nrun_ip route flush cache"; - - pop_indent; - - emit "fi\n"; } + + pop_indent; + + emit "fi\n"; } }