forked from extern/shorewall_code
Clean up error message generation in /sbin/shorewall
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5923 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
77a920a87f
commit
00138eaab5
@ -225,11 +225,6 @@ compiler() {
|
|||||||
|
|
||||||
local command=$1
|
local command=$1
|
||||||
|
|
||||||
fatal_error() {
|
|
||||||
echo " ERROR: $@" >&2
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
|
|
||||||
shift
|
shift
|
||||||
#
|
#
|
||||||
# We've now set SHOREWALL_DIR so recalculate CONFIG_PATH
|
# We've now set SHOREWALL_DIR so recalculate CONFIG_PATH
|
||||||
@ -333,10 +328,7 @@ start_command() {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$STARTUP_ENABLED" ]; then
|
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled"
|
||||||
error_message "ERROR: Startup is disabled"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||||
option=$1
|
option=$1
|
||||||
@ -351,7 +343,7 @@ start_command() {
|
|||||||
option=
|
option=
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
[ $# -gt 1 ] || { error_message "ERROR: -C must be followed by a compiler name"; exit 1; }
|
[ $# -gt 1 ] || fatal_error "-C must be followed by a compiler name"
|
||||||
SHOREWALL_COMPILER=$2
|
SHOREWALL_COMPILER=$2
|
||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
@ -463,7 +455,7 @@ compile_command() {
|
|||||||
option=${option#p}
|
option=${option#p}
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
[ $# -gt 0 ] || { error_message "ERROR: -C must be followed by a compiler name"; exit 1; }
|
[ $# -gt 0 ] || fatal_error "-C must be followed by a compiler name"
|
||||||
SHOREWALL_COMPILER=$1
|
SHOREWALL_COMPILER=$1
|
||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
@ -616,7 +608,7 @@ restart_command() {
|
|||||||
option=${option#n}
|
option=${option#n}
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
[ $# -gt 1 ] || { error_message "ERROR: -C must be followed by a compiler name"; exit 1; }
|
[ $# -gt 1 ] || fatal_error "-C must be followed by a compiler name"
|
||||||
SHOREWALL_COMPILER=$2
|
SHOREWALL_COMPILER=$2
|
||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
@ -656,10 +648,7 @@ restart_command() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "$STARTUP_ENABLED" ]; then
|
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled"
|
||||||
error_message "ERROR: Startup is disabled"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
export NOROUTES
|
export NOROUTES
|
||||||
|
|
||||||
@ -699,7 +688,7 @@ refresh_command() {
|
|||||||
option=
|
option=
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
[ $# -gt 1 ] || { error_message "ERROR: -C must be followed by a compiler name"; exit 1; }
|
[ $# -gt 1 ] || fatal_error "-C must be followed by a compiler name"
|
||||||
SHOREWALL_COMPILER=$2
|
SHOREWALL_COMPILER=$2
|
||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
@ -725,15 +714,9 @@ refresh_command() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if ! shorewall_is_started ; then
|
shorewall_is_started || fatal_error "Shorewall is not running"
|
||||||
error_message "ERROR: Shorewall is not running"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$STARTUP_ENABLED" ]; then
|
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled"
|
||||||
error_message "ERROR: Startup is disabled"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
export NOROUTES
|
export NOROUTES
|
||||||
|
|
||||||
@ -782,7 +765,7 @@ safe_commands() {
|
|||||||
option=${option#n}
|
option=${option#n}
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
[ $# -gt 1 ] || { error_message "ERROR: -C must be followed by a compiler name"; exit 1; }
|
[ $# -gt 1 ] || fatal_error "-C must be followed by a compiler name"
|
||||||
SHOREWALL_COMPILER=$2
|
SHOREWALL_COMPILER=$2
|
||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
@ -822,10 +805,7 @@ safe_commands() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "$STARTUP_ENABLED" ]; then
|
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled"
|
||||||
error_message "ERROR: Startup is disabled"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
mutex_on
|
mutex_on
|
||||||
|
|
||||||
@ -932,7 +912,7 @@ try_command() {
|
|||||||
option=${option#n}
|
option=${option#n}
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
[ $# -gt 1 ] || { error_message "ERROR: -C must be followed by a compiler name"; exit 1; }
|
[ $# -gt 1 ] || fatal_error "-C must be followed by a compiler name"
|
||||||
SHOREWALL_COMPILER=$2
|
SHOREWALL_COMPILER=$2
|
||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
@ -966,10 +946,7 @@ try_command() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "$STARTUP_ENABLED" ]; then
|
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled"
|
||||||
error_message "ERROR: Startup is disabled"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
mutex_on
|
mutex_on
|
||||||
|
|
||||||
@ -1059,7 +1036,7 @@ reload_command() # $* = original arguments less the command.
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
[ $# -gt 1 ] || { error_message "ERROR: -C must be followed by a compiler name"; exit 1; }
|
[ $# -gt 1 ] || fatal_error "-C must be followed by a compiler name"
|
||||||
SHOREWALL_COMPILER=$2
|
SHOREWALL_COMPILER=$2
|
||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
@ -1105,6 +1082,7 @@ reload_command() # $* = original arguments less the command.
|
|||||||
if [ -n "$getcaps" ]; then
|
if [ -n "$getcaps" ]; then
|
||||||
if [ -f $directory/shorewall.conf ]; then
|
if [ -f $directory/shorewall.conf ]; then
|
||||||
. $directory/shorewall.conf
|
. $directory/shorewall.conf
|
||||||
|
ensure_config_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
progress_message "Getting Capabilities on system $system..."
|
progress_message "Getting Capabilities on system $system..."
|
||||||
@ -1156,7 +1134,7 @@ export_command() # $* = original arguments less the command.
|
|||||||
option=
|
option=
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
[ $# -gt 1 ] || { error_message "ERROR: -C must be followed by a compiler name"; exit 1; }
|
[ $# -gt 1 ] || fatal_error "-C must be followed by a compiler name"
|
||||||
SHOREWALL_COMPILER=$2
|
SHOREWALL_COMPILER=$2
|
||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
@ -1535,8 +1513,7 @@ case "$COMMAND" in
|
|||||||
block DROP Dropped $*
|
block DROP Dropped $*
|
||||||
mutex_off
|
mutex_off
|
||||||
else
|
else
|
||||||
error_message "ERROR: Shorewall is not started"
|
fatal_error "Shorewall is not started"
|
||||||
exit 2
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
logdrop)
|
logdrop)
|
||||||
@ -1547,8 +1524,7 @@ case "$COMMAND" in
|
|||||||
block logdrop Dropped $*
|
block logdrop Dropped $*
|
||||||
mutex_off
|
mutex_off
|
||||||
else
|
else
|
||||||
error_message "ERROR: Shorewall is not started"
|
fatal_error "Shorewall is not started"
|
||||||
exit 2
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
reject|logreject)
|
reject|logreject)
|
||||||
@ -1559,8 +1535,7 @@ case "$COMMAND" in
|
|||||||
block $COMMAND Rejected $*
|
block $COMMAND Rejected $*
|
||||||
mutex_off
|
mutex_off
|
||||||
else
|
else
|
||||||
error_message "ERROR: Shorewall is not started"
|
fatal_error "Shorewall is not started"
|
||||||
exit 2
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
allow)
|
allow)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user