From e60369728a91bc63b0dceea7b219e71c8f7fb416 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 29 Nov 2012 15:25:28 -0800 Subject: [PATCH] Only initialize switches that survived optimization - Also use push_indent to make things more readable Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Chains.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Chains.pm b/Shorewall/Perl/Shorewall/Chains.pm index 98233ec9b..ae06af720 100644 --- a/Shorewall/Perl/Shorewall/Chains.pm +++ b/Shorewall/Perl/Shorewall/Chains.pm @@ -7488,13 +7488,16 @@ sub create_stop_load( $ ) { sub initialize_switches() { unless ( have_capability 'CONDITION_INIT' ) { if ( keys %switches ) { - emit( ' if [ $COMMAND = start ]; then' ); + push_indent; push_indent; + emit( 'if [ $COMMAND = start ]; then' ); push_indent; while ( my ( $switch, $setting ) = each %switches ) { - emit " echo $setting->{setting} > /proc/net/nf_condition/$switch"; + my $file = "/proc/net/nf_condition/$switch"; + emit "[ -f $file ] && echo $setting->{setting} > $file"; } pop_indent; - emit " fi\n"; + emit "fi\n"; + pop_indent; pop_indent; } } }