From 995ed8ce4c203c15f778df38423ee5c5f4b9bf13 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Fri, 6 Nov 2020 08:15:25 +0100 Subject: service: Prevent variables from globbing Resolves: rhbz #1894855 --- usr/sbin/service | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/usr/sbin/service b/usr/sbin/service index b4712002..85f68143 100755 --- a/usr/sbin/service +++ b/usr/sbin/service @@ -74,9 +74,9 @@ if [ -f "${SERVICEDIR}/${SERVICE}" ]; then # LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes # lets reap them before next start if [ "${ACTION}" = "start" ] && \ - systemctl show -p ActiveState ${SERVICE}.service | grep -q '=active$' && \ - systemctl show -p SubState ${SERVICE}.service | grep -q '=exited$' ; then - /bin/systemctl stop ${SERVICE}.service + systemctl show -p ActiveState "${SERVICE}".service | grep -q '=active$' && \ + systemctl show -p SubState "${SERVICE}".service | grep -q '=exited$' ; then + /bin/systemctl stop "${SERVICE}".service fi # Workaround to be able to "stop" network.service when it's in inactive state using service instead of systemctl # Useful for manual testing of network @@ -85,13 +85,13 @@ if [ -f "${SERVICEDIR}/${SERVICE}" ]; then [ "$(systemctl show -p SourcePath network.service --value)" = '/etc/rc.d/init.d/network' ]; then export SYSTEMCTL_SKIP_REDIRECT=1 fi - env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS} + env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES="${SYSTEMCTL_IGNORE_DEPENDENCIES}" SYSTEMCTL_SKIP_REDIRECT="${SYSTEMCTL_SKIP_REDIRECT}" "${SERVICEDIR}/${SERVICE}" "${ACTION}" ${OPTIONS} elif [ -n "${ACTION}" ] && [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" ]; then - env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS} + env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES="${SYSTEMCTL_IGNORE_DEPENDENCIES}" SYSTEMCTL_SKIP_REDIRECT="${SYSTEMCTL_SKIP_REDIRECT}" "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS} elif `echo $ACTION | grep -Eqw "start|stop|restart|try-restart|reload|force-reload|status|condrestart"` ; then - SERVICE_MANGLED=$(/usr/bin/systemd-escape --mangle ${SERVICE}) - echo $"Redirecting to /bin/systemctl ${ACTION}${OPTIONS:+ }${OPTIONS} ${SERVICE_MANGLED}" >&2 - exec /bin/systemctl ${ACTION} ${OPTIONS} ${SERVICE_MANGLED} + SERVICE_MANGLED=$(/usr/bin/systemd-escape --mangle "${SERVICE}") + echo $"Redirecting to /bin/systemctl ${ACTION} ${SERVICE_MANGLED}${OPTIONS:+ }${OPTIONS}" >&2 + exec /bin/systemctl "${ACTION}" "${SERVICE_MANGLED}" ${OPTIONS} else echo $"The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl." >&2 exit 2 -- cgit v1.2.1