Bug#629902: dh_installinit: should support LSB compliant scripts
Dmitry Bogatov
KAction at debian.org
Thu Feb 28 12:06:12 GMT 2019
[2019-02-26 20:56] Felipe Sateler <fsateler at debian.org>
> Sorry for the delayed answer
No problem. Better late then never.
> [ patch suggestions ]
Fixed.
> This only works if invoking the init scripts directly. systemctl will hide
> the exit status of the init script (the default behavior of systemd is to
> accept exit code 5 and 6 for LSB scripts though).
Added code 5 too.
> No idea what rc-service does. This should probably be documented in the manpage.
Documented.
From 407444439dbc42398a0736915e3678684f7564f7 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <KAction at debian.org>
Date: Thu, 10 Jan 2019 16:31:32 +0000
Subject: [PATCH] invoke-rc.d: exit value 5 or 6 from init script is fine
Add new option `--lsb' to `invoke-rc.d' script. When this option is
specified, exit value 5 (program not installed) or 6 (service not configured)
from init script is considered successful invocation (Closes: #629902)
---
man8/invoke-rc.d.rst | 8 +++++++-
script/invoke-rc.d | 12 +++++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/man8/invoke-rc.d.rst b/man8/invoke-rc.d.rst
index e5aaeee..27b2ae5 100644
--- a/man8/invoke-rc.d.rst
+++ b/man8/invoke-rc.d.rst
@@ -88,6 +88,11 @@ OPTIONS
Return status code 101 instead of status code 0 if
the init script action is denied by the policy layer.
+*--lsb*
+ Consider exit status 5 (program not installed) and 6 (not configured)
+ of init script as success. **Note:** If init system is systemd,
+ this option is no-op and this behavior is always in effect.
+
*--query*
Returns one of the status codes 100-106. Does not
run the init script, and implies *--disclose-deny*
@@ -119,7 +124,8 @@ returned by invoke-rc.d proper are:
*Success*.
Either the init script was run and returned exit status 0 (note
that a fallback action may have been run instead of the one given in the
- command line), or it was not run because of runlevel/local policy constrains
+ command line), either returned exit status of script was 5 or 6 and ``--lsb``
+ is in effect, or it was not run because of runlevel/local policy constrains
and ``--disclose-deny`` is not in effect.
1 - 99
diff --git a/script/invoke-rc.d b/script/invoke-rc.d
index 27c045e..4c9c432 100755
--- a/script/invoke-rc.d
+++ b/script/invoke-rc.d
@@ -34,6 +34,7 @@ ACTION=
FALLBACK=
NOFALLBACK=
FORCE=
+LSB=
RETRY=
RETURNFAILURE=
RC=
@@ -77,6 +78,8 @@ Options:
Return status code 101 instead of status code 0 if
initscript action is denied by local policy rules or
runlevel constrains.
+ --lsb
+ Consider exit status 6 (not configured) of init script as success.
--query
Returns one of status codes 100-106, does not run
the initscript. Implies --disclose-deny and --no-fallback.
@@ -238,6 +241,9 @@ while test $# -gt 0 && test ${state} != III ; do
--try-anyway)
RETRY=yes
;;
+ --lsb)
+ LSB=yes
+ ;;
--disclose-deny)
RETURNFAILURE=yes
;;
@@ -550,9 +556,13 @@ if test x${FORCE} != x || test ${RC} -eq 104 ; then
elif [ -n "$is_openrc" ]; then
rc-service "${INITSCRIPTID}" "${saction}" && exit 0
else
- "${INITDPREFIX}${INITSCRIPTID}" "${saction}" "$@" && exit 0
+ "${INITDPREFIX}${INITSCRIPTID}" "${saction}" "$@"
fi
RC=$?
+ [ "${RC}" = 0 ] && exit 0
+ # service not configured (6) or installed (5). See #629902
+ [ x"${LSB}" = xyes ] && [ "${RC}" = 6 ] && exit 0
+ [ x"${LSB}" = xyes ] && [ "${RC}" = 5 ] && exit 0
if test ! -z "${ACTION}" ; then
printerror action \"${saction}\" failed, trying next action...
--
Note, that I send and fetch email in batch, once every 24 hours.
If matter is urgent, try https://t.me/kaction
--
More information about the Pkg-systemd-maintainers
mailing list