<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,<div><br></div><div>Sorry for the delayed answer</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 19, 2019 at 4:36 PM Dmitry Bogatov <<a href="mailto:KAction@debian.org">KAction@debian.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">[2019-01-16 06:32] Niels Thykier <<a href="mailto:niels@thykier.net" target="_blank">niels@thykier.net</a>><br>
> Felipe Sateler:<br>
> > Bringing in the debhelper maintainers into the loop again.<br>
> > <br>
> > [...]<br>
> >> Should an init script be executed, invoke-rc.d always returns the status<br>
> > code returned by the init script.<br>
> > <br>
> > So it looks like this would be quite the change in behavior.<br>
> > <br>
> > I wonder what the best approach it. OTOneH, I sympathize with Joey's<br>
> > argument that these checks should be centralized. OTOtherH, I'm not sure we<br>
> > can consider invoke-rc.d a debhelper implementation detail and change<br>
> > behaviour like this.<br>
> > <br>
> > Maybe a new flag to invoke-rc.d could be used for this? I'm not sure.<br>
><br>
> I am fine with using a new flag in a new compat level provided it is<br>
> available in stable at the time. I.e. it would help a lot that the flag<br>
> is available in buster, so we can add it in the first compat level<br>
> released in bullseye.<br>
<br>
Wonderful. What about this patch:<br>
<br>
>From 6c856e13dfd496b25652a202f210177dd0f86c19 Mon Sep 17 00:00:00 2001<br>
From: Dmitry Bogatov <<a href="mailto:KAction@debian.org" target="_blank">KAction@debian.org</a>><br>
Date: Thu, 10 Jan 2019 16:31:32 +0000<br>
Subject: [PATCH] invoke-rc.d: exit value 6 from init script is fine<br>
<br>
Add new option `--lsb' to `invoke-rc.d' script. When this option is<br>
specified, exit value 6 from init script (service not configured) is<br>
considered successful invocation (Closes: #629902)<br>
---<br>
man8/invoke-rc.d.rst | 3 +++<br>
script/invoke-rc.d | 11 ++++++++++-<br>
2 files changed, 13 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/man8/invoke-rc.d.rst b/man8/invoke-rc.d.rst<br>
index e5aaeee..53dd435 100644<br>
--- a/man8/invoke-rc.d.rst<br>
+++ b/man8/invoke-rc.d.rst<br>
@@ -88,6 +88,9 @@ OPTIONS<br>
Return status code 101 instead of status code 0 if<br>
the init script action is denied by the policy layer.<br>
<br>
+*--lsb*<br>
+ Consider exit status 6 (not configured) of init script as success.<br>
+<br>
*--query*<br>
Returns one of the status codes 100-106. Does not<br>
run the init script, and implies *--disclose-deny*<br></blockquote><div><br></div><div>This should also be documented in the STATUS CODES section.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
diff --git a/script/invoke-rc.d b/script/invoke-rc.d<br>
index 27c045e..6b11fdf 100755<br>
--- a/script/invoke-rc.d<br>
+++ b/script/invoke-rc.d<br>
@@ -34,6 +34,7 @@ ACTION=<br>
FALLBACK=<br>
NOFALLBACK=<br>
FORCE=<br>
+LSB=<br>
RETRY=<br>
RETURNFAILURE=<br>
RC=<br>
@@ -77,6 +78,8 @@ Options:<br>
Return status code 101 instead of status code 0 if<br>
initscript action is denied by local policy rules or<br>
runlevel constrains.<br>
+ --lsb<br>
+ Consider exit status 6 (not configured) of init script as success.<br>
--query<br>
Returns one of status codes 100-106, does not run<br>
the initscript. Implies --disclose-deny and --no-fallback.<br>
@@ -238,6 +241,9 @@ while test $# -gt 0 && test ${state} != III ; do<br>
--try-anyway)<br>
RETRY=yes<br>
;;<br>
+ --lsb)<br>
+ LSB=yes<br>
+ ;;<br>
--disclose-deny)<br>
RETURNFAILURE=yes<br>
;;<br>
@@ -550,9 +556,12 @@ if test x${FORCE} != x || test ${RC} -eq 104 ; then<br>
elif [ -n "$is_openrc" ]; then<br>
rc-service "${INITSCRIPTID}" "${saction}" && exit 0<br>
else<br>
- "${INITDPREFIX}${INITSCRIPTID}" "${saction}" "$@" && exit 0<br>
+ "${INITDPREFIX}${INITSCRIPTID}" "${saction}" "$@"<br>
fi<br>
RC=$?<br>
+ [ "${RC}" = 0 ] && exit 0<br>
+ # service not configured. See #629902<br>
+ [ x"${LSB}" != x ] && [ "${RC}" = 6 ] && exit 0<br></blockquote><div><br></div><div>Lets go the other way around: [ x${LSB} = xyes ] , I find that easier to read. Also, we should probably also allow exit code 5 <a href="http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html">http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html</a></div><div><br></div><div>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). No idea what rc-service does. This should probably be documented in the manpage.</div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature"><br>Saludos,<br>Felipe Sateler</div></div></div>