diff options
author | Jan Macku <jamacku@redhat.com> | 2020-11-06 08:03:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-06 08:03:24 +0100 |
commit | f3d9b35826938476fb45f5ca80b884d96448a53e (patch) | |
tree | 0bafb5c6eee4237b2cafb2fd6a1f7ab4b3b5a313 | |
parent | ebad1346df3ff9d32cbf2dc9b02d20e1d734f1e0 (diff) | |
download | initscripts-f3d9b35826938476fb45f5ca80b884d96448a53e.tar initscripts-f3d9b35826938476fb45f5ca80b884d96448a53e.tar.gz initscripts-f3d9b35826938476fb45f5ca80b884d96448a53e.tar.bz2 initscripts-f3d9b35826938476fb45f5ca80b884d96448a53e.tar.xz initscripts-f3d9b35826938476fb45f5ca80b884d96448a53e.zip |
service: Prevent variables from globbing
-rwxr-xr-x | usr/sbin/service | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/usr/sbin/service b/usr/sbin/service index b178d915..36d7083d 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 --value)" = 'active' ] && \ - [ "$(systemctl show -p SubState ${SERVICE}.service --value)" = 'exited' ]; then - /bin/systemctl stop ${SERVICE}.service + [ "$(systemctl show -p ActiveState "${SERVICE}".service --value)" = 'active' ] && \ + [ "$(systemctl show -p SubState "${SERVICE}".service --value)" = '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 @@ -87,13 +87,13 @@ if [ -f "${SERVICEDIR}/${SERVICE}" ]; 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 [[ $ACTION =~ 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 |