Bug#629902: dh_installinit: should support LSB compliant scripts

Dmitry Bogatov KAction at debian.org
Sat Jan 19 19:34:31 GMT 2019


[2019-01-16 06:32] Niels Thykier <niels at thykier.net>
> Felipe Sateler:
> > Bringing in the debhelper maintainers into the loop again.
> > 
> > [...]
> >> Should  an init script be executed, invoke-rc.d always returns the status
> > code returned by the init script.
> > 
> > So it looks like this would be quite the change in behavior.
> > 
> > I wonder what the best approach it. OTOneH, I sympathize with Joey's
> > argument that these checks should be centralized. OTOtherH, I'm not sure we
> > can consider invoke-rc.d a debhelper implementation detail and change
> > behaviour like this.
> > 
> > Maybe a new flag to invoke-rc.d could be used for this? I'm not sure.
>
> I am fine with using a new flag in a new compat level provided it is
> available in stable at the time.  I.e. it would help a lot that the flag
> is available in buster, so we can add it in the first compat level
> released in bullseye.

Wonderful. What about this patch:

From 6c856e13dfd496b25652a202f210177dd0f86c19 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 6 from init script is fine

Add new option `--lsb' to `invoke-rc.d' script. When this option is
specified, exit value 6 from init script (service not configured) is
considered successful invocation (Closes: #629902)
---
 man8/invoke-rc.d.rst |  3 +++
 script/invoke-rc.d   | 11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/man8/invoke-rc.d.rst b/man8/invoke-rc.d.rst
index e5aaeee..53dd435 100644
--- a/man8/invoke-rc.d.rst
+++ b/man8/invoke-rc.d.rst
@@ -88,6 +88,9 @@ 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 6 (not configured) of init script as success.
+
 *--query*
     Returns one of the status codes 100-106. Does not
     run the init script, and implies *--disclose-deny*
diff --git a/script/invoke-rc.d b/script/invoke-rc.d
index 27c045e..6b11fdf 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,12 @@ 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. See #629902
+	    [ x"${LSB}" != x ] && [ "${RC}" = 6 ] && exit 0
 
 	    if test ! -z "${ACTION}" ; then
 		printerror action \"${saction}\" failed, trying next action...



More information about the Pkg-systemd-maintainers mailing list