Commit 28002a9c authored by Ansgar Burchardt's avatar Ansgar Burchardt Committed by Michael Biebl
Browse files

Don't change behavior of SysV init scripts using "set -e" or "set -u"

/lib/lsb/init-functions.d/40-systemd unconditionally uses "set +e; set
+u". This can change the behavior of init scripts that use "set -e"
and/or "set -u".

Change the systemd integration to not rely on "set +e" or "set +u" but
instead work correctly in all cases by catching all commands that might
fail.

Closes: #751472
parent 189af617
......@@ -39,6 +39,11 @@ systemd (204-11) UNRELEASED; urgency=medium
* Clarify that systemd does not influence init whereas systemd-sysv does
(Closes: #747741)
[ Ansgar Burchardt ]
* Don't use "set +e; set +u" unconditionally in the lsb init-functions hook
as this might change the behaviour of existing SysV init scripts.
(Closes: #751472)
-- Martin Pitt <mpitt@debian.org> Sun, 27 Apr 2014 12:51:55 +0200
systemd (204-10) unstable; urgency=medium
......
# -*-Shell-script-*-
# /lib/lsb/init-functions
_use_systemctl=0
if [ -d /run/systemd/system ]; then
# Some init scripts use "set -e" and "set -u", we don't want that
# here
set +e
set +u
if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
if [ -n "${DPKG_MAINTSCRIPT_PACKAGE:-}" ]; then
# If we are called by a maintainer script, chances are good that a
# new or updated sysv init script was installed. Reload daemon to
# pick up any changes.
systemctl daemon-reload
systemctl daemon-reload || true
fi
# Redirect SysV init scripts when executed by the user
if [ $PPID -ne 1 ] && [ -z "$init" ] && [ -z "$_SYSTEMCTL_SKIP_REDIRECT" ]; then
if [ $PPID -ne 1 ] && [ -z "${init:-}" ] && [ -z "${_SYSTEMCTL_SKIP_REDIRECT:-}" ]; then
case $(readlink -f "$0") in
/etc/init.d/*)
_use_systemctl=1
......@@ -23,7 +20,7 @@ if [ -d /run/systemd/system ]; then
# but can through the init script.
prog=${0##*/}
service="${prog%.sh}.service"
if [ "$(systemctl -p CanReload show $service 2>/dev/null)" = "CanReload=no" ] && [ "$1" = "reload" ]; then
if [ "$(systemctl -p CanReload show $service 2>/dev/null)" = "CanReload=no" ] && [ "${1:-}" = "reload" ]; then
_use_systemctl=0
fi
;;
......@@ -31,8 +28,6 @@ if [ -d /run/systemd/system ]; then
else
export _SYSTEMCTL_SKIP_REDIRECT="true"
fi
else
_use_systemctl=0
fi
systemctl_redirect () {
......@@ -73,6 +68,11 @@ systemctl_redirect () {
}
if [ "$_use_systemctl" = "1" ]; then
# Some init scripts use "set -e" and "set -u", we don't want that
# here
set +e
set +u
if [ "x$1" = xstart -o \
"x$1" = xstop -o \
"x$1" = xrestart -o \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment