From dffe6b47e7f1079b1092ee16838e252400409097 Mon Sep 17 00:00:00 2001 From: teastep Date: Fri, 16 Jun 2006 21:43:55 +0000 Subject: [PATCH] Avoid most /etc/shorewall/shorewall.conf verification for 'compile -e' git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@4122 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall/shorewall | 121 +++++++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 59 deletions(-) diff --git a/Shorewall/shorewall b/Shorewall/shorewall index 2cd910a94..c57e89138 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -110,7 +110,7 @@ # confirmation to accept or reject the new # configuration # -# shorewall compile [ ] ] +# shorewall compile [ -e ] [ ] # Compile a firewall program file. # # Fatal Error @@ -192,45 +192,75 @@ validate_restorefile() # $* = label # get_config() { - [ -z "$LOGFILE" ] && LOGFILE=/var/log/messages + if [ -z "$EXPORT" -a "$(whoami)" = root ]; then - if [ ! -f $LOGFILE ]; then - echo "LOGFILE ($LOGFILE) does not exist!" >&2 - exit 2 - fi - # - # See if we have a real version of "tail" -- use separate redirection so - # that ash (aka /bin/sh on LRP) doesn't crap - # - if ( tail -n5 $LOGFILE > /dev/null 2> /dev/null ) ; then - realtail="Yes" - else - realtail="" - fi + [ -z "$LOGFILE" ] && LOGFILE=/var/log/messages - [ -n "$FW" ] || FW=fw + if [ ! -f $LOGFILE ]; then + echo "LOGFILE ($LOGFILE) does not exist!" >&2 + exit 2 + fi + + if [ -n "$IPTABLES" ]; then + if [ ! -e "$IPTABLES" ]; then + echo " ERROR: The program specified in IPTABLES does not exist or is not executable" >&2 + exit 2 + fi + else + IPTABLES=$(mywhich iptables 2> /dev/null) + if [ -z "$IPTABLES" ] ; then + echo " ERROR: Can't find iptables executable" >&2 + exit 2 + fi + fi + + export IPTABLES + + # + # See if we have a real version of "tail" -- use separate redirection so + # that ash (aka /bin/sh on LRP) doesn't crap + # + if ( tail -n5 $LOGFILE > /dev/null 2> /dev/null ) ; then + realtail="Yes" + else + realtail="" + fi + + [ -n "$RESTOREFILE" ] || RESTOREFILE=restore + + validate_restorefile RESTOREFILE + + export RESTOREFILE + + case $STARTUP_ENABLED in + No|no|NO) + echo " WARNING: Shorewall startup is disabled. To enable startup, set STARTUP_ENABLED=Yes in ${CONFDIR}/shorewall.conf" >&2 + STARTUP_ENABLED= + ;; + Yes|yes|YES) + ;; + *) + if [ -n "$STARTUP_ENABLED" ]; then + echo " ERROR: Invalid Value for STARTUP_ENABLE: $STARTUP_ENABLED" >&2 + exit 2 + fi + ;; + esac + + case ${TC_ENABLED:=Internal} in + No|NO|no) + TC_ENABLED= + ;; + esac + + fi [ -n "LOGFORMAT" ] && LOGFORMAT="${LOGFORMAT%%%*}" - + [ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:" export LOGFORMAT - if [ -n "$IPTABLES" ]; then - if [ ! -e "$IPTABLES" ]; then - echo " ERROR: The program specified in IPTABLES does not exist or is not executable" >&2 - exit 2 - fi - else - IPTABLES=$(mywhich iptables 2> /dev/null) - if [ -z "$IPTABLES" ] ; then - echo " ERROR: Can't find iptables executable" >&2 - exit 2 - fi - fi - - export IPTABLES - if [ -n "$SHOREWALL_SHELL" ]; then if [ ! -e "$SHOREWALL_SHELL" ]; then echo " ERROR: The program specified in SHOREWALL_SHELL does not exist or is not executable" >&2 @@ -238,33 +268,6 @@ get_config() { fi fi - [ -n "$RESTOREFILE" ] || RESTOREFILE=restore - - validate_restorefile RESTOREFILE - - export RESTOREFILE - - case $STARTUP_ENABLED in - [Nn][Oo]) - echo " WARNING: Shorewall startup is disabled. To enable startup, set STARTUP_ENABLED=Yes in ${CONFDIR}/shorewall.conf" >&2 - STARTUP_ENABLED= - ;; - [Yy][Ee][Ss]) - ;; - *) - if [ -n "$STARTUP_ENABLED" ]; then - echo " ERROR: Invalid Value for STARTUP_ENABLE: $STARTUP_ENABLED" >&2 - exit 2 - fi - ;; - esac - - case ${TC_ENABLED:=Internal} in - [Nn][Oo]) - TC_ENABLED= - ;; - esac - [ -n "${VERBOSITY:=2}" ] VERBOSE=$(($VERBOSE_OFFSET + $VERBOSITY))