Remove locking from /usr/share/shorewall/firewall

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@7007 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-07-30 17:50:30 +00:00
parent a0f443df38
commit d133c44162
2 changed files with 6 additions and 34 deletions

View File

@ -34,19 +34,6 @@
# firewall add <iface>[:<host>] zone Adds a host or subnet to a zone # firewall add <iface>[:<host>] zone Adds a host or subnet to a zone
# firewall delete <iface>[:<host>] zone Deletes a host or subnet from a zone # firewall delete <iface>[:<host>] zone Deletes a host or subnet from a zone
# #
# Mutual exclusion -- These functions are jackets for the mutual exclusion
# routines in $FUNCTIONS. They invoke
# the corresponding function in that file if the user did
# not specify "nolock" on the runline.
#
my_mutex_on() {
[ -n "$NOLOCK" ] || { mutex_on; HAVE_MUTEX=Yes; }
}
my_mutex_off() {
[ -n "$HAVE_MUTEX" ] && { mutex_off; HAVE_MUTEX=; }
}
# #
# Fatal error -- stops the firewall after issuing the error message # Fatal error -- stops the firewall after issuing the error message
# #
@ -64,7 +51,6 @@ fatal_error() # $* = Error Message
startup_error() # $* = Error Message startup_error() # $* = Error Message
{ {
echo " ERROR: $@" >&2 echo " ERROR: $@" >&2
my_mutex_off
[ -n "$TMP_DIR" ] && rm -rf $TMP_DIR [ -n "$TMP_DIR" ] && rm -rf $TMP_DIR
[ -n "$RESTOREBASE" ] && rm -f $RESTOREBASE [ -n "$RESTOREBASE" ] && rm -f $RESTOREBASE
kill $$ kill $$
@ -253,7 +239,6 @@ stop_firewall() {
set_state "Unknown" set_state "Unknown"
fi fi
my_mutex_off
kill $$ kill $$
exit 2 exit 2
fi fi
@ -399,7 +384,6 @@ stop_firewall() {
# else. Remove the lock file and Kill the shell in case we're in a # else. Remove the lock file and Kill the shell in case we're in a
# subshell # subshell
# #
my_mutex_off
kill $$ kill $$
;; ;;
esac esac
@ -512,7 +496,6 @@ check_disabled_startup() {
echo " ${CONFDIR}/shorewall.conf" echo " ${CONFDIR}/shorewall.conf"
[ -n "$TMP_DIR" ] && rm -rf $TMP_DIR [ -n "$TMP_DIR" ] && rm -rf $TMP_DIR
my_mutex_off
exit 2 exit 2
fi fi
} }
@ -537,8 +520,6 @@ NOLOCK=
[ $# -gt 1 ] && [ "$1" = "nolock" ] && { NOLOCK=Yes; shift ; } [ $# -gt 1 ] && [ "$1" = "nolock" ] && { NOLOCK=Yes; shift ; }
trap "my_mutex_off; exit 2" 1 2 3 4 5 6 9
SHAREDIR=/usr/share/shorewall SHAREDIR=/usr/share/shorewall
VARDIR=/var/lib/shorewall VARDIR=/var/lib/shorewall
CONFDIR=/etc/shorewall CONFDIR=/etc/shorewall
@ -562,7 +543,6 @@ case "$COMMAND" in
stop) stop)
[ $# -ne 1 ] && usage [ $# -ne 1 ] && usage
do_initialize do_initialize
my_mutex_on
# #
# Don't want to do a 'stop' when startup is disabled # Don't want to do a 'stop' when startup is disabled
# #
@ -571,17 +551,14 @@ case "$COMMAND" in
stop_firewall stop_firewall
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK [ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
progress_message3 "done." progress_message3 "done."
my_mutex_off
;; ;;
reset) reset)
[ $# -ne 1 ] && usage [ $# -ne 1 ] && usage
do_initialize do_initialize
my_mutex_on
if ! shorewall_is_started ; then if ! shorewall_is_started ; then
echo "Shorewall Not Started" echo "Shorewall Not Started"
[ -n "$TMP_DIR" ] && rm -rf $TMP_DIR [ -n "$TMP_DIR" ] && rm -rf $TMP_DIR
my_mutex_off
exit 2; exit 2;
fi fi
$IPTABLES -Z $IPTABLES -Z
@ -589,50 +566,41 @@ case "$COMMAND" in
$IPTABLES -t mangle -Z $IPTABLES -t mangle -Z
report "Shorewall Counters Reset" report "Shorewall Counters Reset"
date > ${VARDIR}/restarted date > ${VARDIR}/restarted
my_mutex_off
;; ;;
clear) clear)
[ $# -ne 1 ] && usage [ $# -ne 1 ] && usage
do_initialize do_initialize
my_mutex_on
progress_message3 "Clearing Shorewall..." progress_message3 "Clearing Shorewall..."
clear_firewall clear_firewall
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK [ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
progress_message3 "done." progress_message3 "done."
my_mutex_off
;; ;;
add) add)
[ $# -lt 3 ] && usage [ $# -lt 3 ] && usage
do_initialize do_initialize
lib_load dynamiczones "The add command" lib_load dynamiczones "The add command"
my_mutex_on
if ! shorewall_is_started ; then if ! shorewall_is_started ; then
echo "Shorewall Not Started" echo "Shorewall Not Started"
[ -n "$TMP_DIR" ] && rm -rf $TMP_DIR [ -n "$TMP_DIR" ] && rm -rf $TMP_DIR
my_mutex_off
exit 2; exit 2;
fi fi
shift shift
add_to_zone $@ add_to_zone $@
my_mutex_off
;; ;;
delete) delete)
[ $# -lt 3 ] && usage [ $# -lt 3 ] && usage
lib_load dynamiczones "The delete command" lib_load dynamiczones "The delete command"
do_initialize do_initialize
my_mutex_on
if ! shorewall_is_started ; then if ! shorewall_is_started ; then
echo "Shorewall Not Started" echo "Shorewall Not Started"
[ -n "$TMP_DIR" ] && rm -rf $TMP_DIR [ -n "$TMP_DIR" ] && rm -rf $TMP_DIR
my_mutex_off
exit 2; exit 2;
fi fi
shift shift
delete_from_zone $@ delete_from_zone $@
my_mutex_off
;; ;;
call) call)

View File

@ -1547,7 +1547,9 @@ case "$COMMAND" in
get_config get_config
export NOROUTES export NOROUTES
[ -x ${VARDIR}/.restore ] && FIREWALL=${VARDIR}/.restore [ -x ${VARDIR}/.restore ] && FIREWALL=${VARDIR}/.restore
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock $COMMAND mutex_on
$SHOREWALL_SHELL $FIREWALL $debugging $nolock $COMMAND
mutex_off
;; ;;
compile) compile)
get_config Yes get_config Yes
@ -1572,7 +1574,9 @@ case "$COMMAND" in
add|delete) add|delete)
[ $# -lt 3 ] && usage 1 [ $# -lt 3 ] && usage 1
get_config get_config
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock $@ mutex_on
$SHOREWALL_SHELL $FIREWALL $debugging $nolock $@
mutex_off
;; ;;
show|list) show|list)
get_config Yes No Yes get_config Yes No Yes