From 7281c9166e76511f3c47f2c5de026adf81f4a921 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 12 Aug 2010 17:54:07 -0700 Subject: [PATCH] Record the config directory in the state file --- Shorewall/Perl/Shorewall/Compiler.pm | 19 ++++++++++++------- Shorewall/Perl/Shorewall/Config.pm | 4 ++++ Shorewall/lib.common | 8 ++++++-- Shorewall6/lib.common | 6 +++++- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index 0a5612dff..ed095fc18 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -442,32 +442,37 @@ EOF setup_forwarding( $family , 1 ); push_indent; - emit<<'EOF'; - set_state "Started" + my $config_dir = $globals{CONFIGDIR}; + + emit<<"EOF"; + set_state Started $config_dir run_restored_exit else - if [ $COMMAND = refresh ]; then + if [ \$COMMAND = refresh ]; then chainlist_reload EOF setup_forwarding( $family , 0 ); - emit<<'EOF'; + emit<<"EOF"; run_refreshed_exit do_iptables -N shorewall - set_state "Started" + set_state Started $config_dir else setup_netfilter conditionally_flush_conntrack EOF setup_forwarding( $family , 0 ); - emit<<'EOF'; + emit<<"EOF"; run_start_exit do_iptables -N shorewall - set_state "Started" + set_state Started $config_dir run_started_exit fi +EOF + + emit<<'EOF'; [ $0 = ${VARDIR}/firewall ] || cp -f $(my_pathname) ${VARDIR}/firewall fi diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index ae3583751..ea26c99e5 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -339,6 +339,7 @@ sub initialize( $ ) { %globals = ( SHAREDIR => '/usr/share/shorewall' , SHAREDIRPL => '/usr/share/shorewall/' , CONFDIR => '/etc/shorewall', + CONFIGDIR => '', LOGPARMS => '', TC_SCRIPT => '', EXPORT => 0, @@ -2719,6 +2720,9 @@ sub process_shorewall_conf() { my $file = find_file "$product.conf"; if ( -f $file ) { + $globals{CONFIGDIR} = $file; + $globals{CONFIGDIR} =~ s/$product.conf//; + if ( -r _ ) { open_file $file; diff --git a/Shorewall/lib.common b/Shorewall/lib.common index 208ed8a22..0fa629282 100644 --- a/Shorewall/lib.common +++ b/Shorewall/lib.common @@ -514,9 +514,13 @@ find_file() # # Set the Shorewall state # -set_state () # $1 = state +set_state () # $1 = state $2 { - echo "$1 ($(date))" > ${VARDIR}/state + if [ $# -gt 1 ]; then + echo "$1 ($(date)) from $2" > ${VARDIR}/state + else + echo "$1 ($(date))" > ${VARDIR}/state + fi } # diff --git a/Shorewall6/lib.common b/Shorewall6/lib.common index 1b2d6f13e..e826f24d0 100644 --- a/Shorewall6/lib.common +++ b/Shorewall6/lib.common @@ -452,7 +452,11 @@ find_file() # set_state () # $1 = state { - echo "$1 ($(date))" > ${VARDIR}/state + if [ $# -gt 1 ]; then + echo "$1 ($(date)) from $2" > ${VARDIR}/state + else + echo "$1 ($(date))" > ${VARDIR}/state + fi } #