aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Macku <jamacku@redhat.com>2020-11-06 08:15:25 +0100
committerGitHub <noreply@github.com>2020-11-06 08:15:25 +0100
commit995ed8ce4c203c15f778df38423ee5c5f4b9bf13 (patch)
tree772c4b63b2d45fcc8b331ea26b56d3501b4afc5d
parent8f0cf7d7d872709bbdcdb92d68dc423a64263ffc (diff)
downloadinitscripts-995ed8ce4c203c15f778df38423ee5c5f4b9bf13.tar
initscripts-995ed8ce4c203c15f778df38423ee5c5f4b9bf13.tar.gz
initscripts-995ed8ce4c203c15f778df38423ee5c5f4b9bf13.tar.bz2
initscripts-995ed8ce4c203c15f778df38423ee5c5f4b9bf13.tar.xz
initscripts-995ed8ce4c203c15f778df38423ee5c5f4b9bf13.zip
service: Prevent variables from globbing
Resolves: rhbz #1894855
-rwxr-xr-xusr/sbin/service16
1 files 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