Implement $SW_LOGGERTAG

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2016-04-15 14:29:51 -07:00
parent 549af8b402
commit 524838ae47
6 changed files with 33 additions and 17 deletions

View File

@ -3882,7 +3882,7 @@ start_command() {
rc=$?
else
error_message "${VARDIR}/firewall is missing or is not executable"
logger -p kern.err "ERROR:$g_product start failed"
mylogger kern.err "ERROR:$g_product start failed"
rc=6
fi
@ -4015,7 +4015,7 @@ restart_command() {
rc=$?
else
error_message "${VARDIR}/firewall is missing or is not executable"
logger -p kern.err "ERROR:$g_product $COMMAND failed"
mylogger kern.err "ERROR:$g_product $COMMAND failed"
rc=6
fi

View File

@ -25,6 +25,22 @@
# scripts rather than loaded at run-time.
#
#########################################################################################
#
# Wrapper around logger that sets the tag according to $SW_LOGGERTAG
#
mylogger() {
local level
level=$1
shift
if [ -n "$SW_LOGGERTAG" ]; then
logger -p $level -t "$SW_LOGGERTAG" $*
else
logger -p $level $*
fi
}
#
# Issue a message and stop
#
@ -39,13 +55,13 @@ startup_error() # $* = Error Message
case $COMMAND in
start)
logger -p kern.err "ERROR:$g_product start failed:Firewall state not changed"
mylogger kern.err "ERROR:$g_product start failed:Firewall state not changed"
;;
restart)
logger -p kern.err "ERROR:$g_product restart failed:Firewall state not changed"
mylogger kern.err "ERROR:$g_product restart failed:Firewall state not changed"
;;
restore)
logger -p kern.err "ERROR:$g_product restore failed:Firewall state not changed"
mylogger kern.err "ERROR:$g_product restore failed:Firewall state not changed"
;;
esac

View File

@ -576,16 +576,16 @@ date > ${VARDIR}/restarted
case $COMMAND in
start)
logger -p kern.info "$g_product started"
mylogger kern.info "$g_product started"
;;
reloaded)
logger -p kern.info "$g_product reloaded"
mylogger kern.info "$g_product reloaded"
;;
refresh)
logger -p kern.info "$g_product refreshed"
mylogger kern.info "$g_product refreshed"
;;
restore)
logger -p kern.info "$g_product restored"
mylogger kern.info "$g_product restored"
;;
esac
EOF

View File

@ -5431,7 +5431,7 @@ sub get_params( $ ) {
#
delete $params{$_};
} else {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' ) {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' || $_ eq 'SW_LOGGERTAG' ) {
fatal_error "The variable name $_ is reserved and may not be set in the params file"
if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_};
}

View File

@ -2472,16 +2472,16 @@ EOF
emit <<'EOF';
case $COMMAND in
start)
logger -p kern.err "ERROR:$g_product start failed"
mylogger kern.err "ERROR:$g_product start failed"
;;
reload)
logger -p kern.err "ERROR:$g_product reload failed"
mylogger kern.err "ERROR:$g_product reload failed"
;;
refresh)
logger -p kern.err "ERROR:$g_product refresh failed"
mylogger kern.err "ERROR:$g_product refresh failed"
;;
enable)
logger -p kern.err "ERROR:$g_product 'enable $g_interface' failed"
mylogger kern.err "ERROR:$g_product 'enable $g_interface' failed"
;;
esac
@ -2690,7 +2690,7 @@ EOF
emit '
set_state "Stopped"
logger -p kern.info "$g_product Stopped"
mylogger kern.info "$g_product Stopped"
case $COMMAND in
stop|clear)

View File

@ -548,7 +548,7 @@ start_command() {
[ -n "$nolock" ] || mutex_off
else
rc=$?
logger -p kern.err "ERROR:$g_product start failed"
mylogger kern.err "ERROR:$g_product start failed"
fi
fi
@ -1028,7 +1028,7 @@ restart_command() {
[ -n "$nolock" ] || mutex_off
else
rc=$?
logger -p kern.err "ERROR:$g_product ${COMMAND} failed"
mylogger kern.err "ERROR:$g_product ${COMMAND} failed"
fi
else
[ -x ${VARDIR}/firewall ] || fatal_error "No ${VARDIR}/firewall file found"