Your message dated Tue, 23 Sep 2025 10:15:45 +0000
with message-id <[email protected]>
and subject line Bug#1108969: fixed in sysvinit 3.15-2
has caused the Debian Bug report #1108969,
regarding sysvinit-utils: add common support for oneshot services in 
init-d-script helper
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1108969: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1108969
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: sysvinit-utils
Version: 3.14-4
Severity: wishlist

Dear Maintainer,

Mark outlined an approach for implementing single-shot services in
https://www.chiark.greenend.org.uk/pipermail/debian-init-diversity/2025-March/007475.html
and suggested that this could be incorporated as common functionality
in the init-d-script(5) helper script.

I support this idea. In the case of services that occur strictly at boot
time and shutdown, I think the traditional pattern of detecting the
runlevel transition [1] is sufficient but for services in the multi-user
runlevels, the flag file seems more appropriate.

I have applied this pattern to my reworking of the initscript for the
'acct' package [2] and as a result have some feedback potentially to
improve the solution.

I attach the proposed final state of the script and quote snippets here
as context for suggestions about the common solution.

> DAEMON=/usr/sbin/accton

init-d-script(5) says not to set DAEMON unless you are actually starting
a daemon but I don't see a problem with using it for a command related
to the one-shot operation as it then doubles as the 'installed' check,
allows repeated use of the variable within the script while benefiting
from the logic that prevents it being overriden by the 'defaults' file
and avoids finding another variable name to use for a near-identical
purpose. So I used it.

> run_accton() {
>   # Borrowed from init-d-script:
>   if [ "$SETPRIV_ARGS" ] ; then
>     PATH=/bin:/usr/bin command -v setpriv  > /dev/null 2>&1 || unset 
> SETPRIV_ARGS
>   fi
> 
>   ${SETPRIV_ARGS:+setpriv $SETPRIV_ARGS} $DAEMON "$@" >/dev/null 2>/dev/null
> }

It would be helpful if this logic could be available for 'oneshot'
services rather than being defined in the built-in do_start_cmd().

> do_start_prepare() {
>   [ -f /run/$NAME.oneshot ] && exit
> }
> 
> do_stop_prepare() {
>   [ -f /run/$NAME.oneshot ] || exit
> }
> 
> do_stop_cleanup() {
>   rm -f /run/$NAME.oneshot

I removed the '-v' - I don't think we want that console noise.

> }
> 
> do_status_override() {
>   if [ -f /run/$NAME.oneshot ]; then
>     log_success_msg "$NAME is running"
>   else
>     log_failure_msg "$NAME is not running"
>     return 4
>   fi
> }

We could do with a default status operation. This supports compound
operations like 'try-restart' that are needed in logrotate post-rotation
scripts, etc.

> do_start_cmd_override() {
> 
>   # Allow the log file preparation commands to fail - defer errors to accton
>   file="/var/log/account/pacct"
>   mkdir -p "$(dirname $file)"
>   touch "$file"
>   chmod 640 "$file"
>   chown root:adm "$file"

This is acct-specific, of course. Hopefully we'll be able to use the
'do_start_prepare()' override once that isn't needed for the oneshot
preparation.

> 
>   run_accton "$file"

The run operation was factored out to a common function to avoid code
duplication invoking 'setpriv' but would be clearer and more succinct if
the key command was simply invoked here in full, perhaps preceded with a
setpriv-related variable that has been set up by the helper code for us.

>   rv=$?
>   if [ $rv -eq 38 ]; then #ENOSYS
>     log_warning_msg "Process accounting not available with this kernel."
>   elif [ $rv -eq 16 ]; then #EBUSY
>     log_warning_msg "Process accounting already enabled on this system."
>   elif [ $rv -eq 1 ]; then #EPERM
>     log_warning_msg "Insufficient privileges."
>   elif [ $rv -eq 0 ]; then
>     touch /run/$NAME.oneshot

I moved this here instead of in do_start_cleanup() because touching the
flag file needs to be conditional on a successful return code, but the
cleanup function doesn't have access to the return code, except by
cheating and inspecting the $retval global which is an implementation
detail of the library functions. It would be nice to shape the helper
code so that this can be done automatically on a successful return code
from do_start_cmd_override().

>     return 0
>   fi
>   return 2

We could do with translating the return code. If 1 is returned on error,
for example, the service is reported as already running instead of as
having failed to be started, hence returning 2.

> }
> 
> do_stop_cmd_override() {
>   run_accton off
> }

I hope these thoughts help with any future implementation of common
single shot init script support.

Many thanks again for the initial proposal, Mark!

Andrew

[1] 
https://sources.debian.org/src/wtmpdb/0.73.0-3/debian/wtmpdb.wtmpdb-update-boot.init/
[2] https://salsa.debian.org/pkg-security-team/acct/-/merge_requests/8

#!/bin/sh
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
  set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          acct
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: process and login accounting
# Description:       GNU Accounting Utilities is a set of utilities which
#                    reports and summarizes data about user connect times and
#                    process execution statistics.
### END INIT INFO

DAEMON=/usr/sbin/accton
NAME=acct
DESC="process accounting"

caps="-all,+sys_pacct"
SETPRIV_ARGS="--inh-caps $caps --ambient-caps $caps --bounding-set $caps --no-new-privs"

# Thanks: oneshot pattern for init-d-script devised by Mark Hindley and
# and adapted for acct by Andrew Bower.

run_accton() {
  # Borrowed from init-d-script:
  if [ "$SETPRIV_ARGS" ] ; then
    PATH=/bin:/usr/bin command -v setpriv  > /dev/null 2>&1 || unset SETPRIV_ARGS
  fi

  ${SETPRIV_ARGS:+setpriv $SETPRIV_ARGS} $DAEMON "$@" >/dev/null 2>/dev/null
}

do_start_prepare() {
  [ -f /run/$NAME.oneshot ] && exit
}

do_stop_prepare() {
  [ -f /run/$NAME.oneshot ] || exit
}

do_stop_cleanup() {
  rm -f /run/$NAME.oneshot
}

do_status_override() {
  if [ -f /run/$NAME.oneshot ]; then
    log_success_msg "$NAME is running"
  else
    log_failure_msg "$NAME is not running"
    return 4
  fi
}

do_start_cmd_override() {

  # Allow the log file preparation commands to fail - defer errors to accton
  file="/var/log/account/pacct"
  mkdir -p "$(dirname $file)"
  touch "$file"
  chmod 640 "$file"
  chown root:adm "$file"

  run_accton "$file"
  rv=$?
  if [ $rv -eq 38 ]; then #ENOSYS
    log_warning_msg "Process accounting not available with this kernel."
  elif [ $rv -eq 16 ]; then #EBUSY
    log_warning_msg "Process accounting already enabled on this system."
  elif [ $rv -eq 1 ]; then #EPERM
    log_warning_msg "Insufficient privileges."
  elif [ $rv -eq 0 ]; then
    touch /run/$NAME.oneshot
    return 0
  fi
  return 2
}

do_stop_cmd_override() {
  run_accton off
}

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Source: sysvinit
Source-Version: 3.15-2
Done: Mark Hindley <[email protected]>

We believe that the bug you reported is fixed in the latest version of
sysvinit, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Mark Hindley <[email protected]> (supplier of updated sysvinit package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Tue, 23 Sep 2025 08:29:46 +0100
Source: sysvinit
Architecture: source
Version: 3.15-2
Distribution: experimental
Urgency: medium
Maintainer: Debian sysvinit maintainers 
<[email protected]>
Changed-By: Mark Hindley <[email protected]>
Closes: 435287 539352 688412 1108969
Changes:
 sysvinit (3.15-2) experimental; urgency=medium
 .
   * Update inittab on new installations to assume 8bit clean environment.
     (Closes: #435287)
   * Emphasise that /etc/fstab overrides /etc/default/tmpfs. (Closes: #688412)
   * init-d-script:
     - Support TYPE=oneshot. (Closes: #1108969)
     - comply with style guidelines.
   * Add rcS option EXTRAKERNELFS and framework to support mounting
     additional kernel filesystems. Currently supported options are debugfs
     and cgroupfs2. (Closes: #539352)
Checksums-Sha1:
 9ee30fcde105a8e549516a2ccac19e304ef9a4c2 2382 sysvinit_3.15-2.dsc
 30e51c702c64d04686d81b1682896cde99fc908a 122696 sysvinit_3.15-2.debian.tar.xz
 a813609ca5d4f60f392fbadf059178e097a03916 8075 sysvinit_3.15-2_amd64.buildinfo
Checksums-Sha256:
 f21749720c760cfc7ca0db7efbbf5ace013d8b52c2de03b8ae32d85cbf69b9b8 2382 
sysvinit_3.15-2.dsc
 86b2a6c60c33254196d8fab6f9619dfe3b9b0e84fd846f29e299f8c312611ecc 122696 
sysvinit_3.15-2.debian.tar.xz
 662f0941e141738bc0fd9c231bdc38c8c2e0da77d49546be03f8b05653749bd6 8075 
sysvinit_3.15-2_amd64.buildinfo
Files:
 2a9d72d7cb9723c4bbdc6e03792f8153 2382 admin optional sysvinit_3.15-2.dsc
 f56711a64e2c91216052b445482152c1 122696 admin optional 
sysvinit_3.15-2.debian.tar.xz
 742e604a0bf7e7b0b8e94d852e39654f 8075 admin optional 
sysvinit_3.15-2_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEUGwVpCsK9aCoVCPu0opFvzKH1kkFAmjSarsACgkQ0opFvzKH
1kmnHw/+J7fwbVyFUdvrSbTSleWofgobEt69myWDXzaWm/GM/Nt96jvAXhhyOmMm
v0U4f5p6Teq1KmJo2zYw8+AQP5oZD/a0BKdUncK6LPyfPAAHQgTxMt2Fi0inhh55
xz4+55ckxqJHgkjVOo9Wm/KJPFRWoacznZU47zSGBdSoMmvxoj5zreT3SvtIETD5
3i9hNeda6qzGOboCerqctXbMvZilXeOTkCBxx4TUmaxesqiwwJeN3RB2Pi9N5C9S
0uEL+jAetjesUJjIesF9qFFoctXmCFnEWvS+irwo/DTOjMV1zAOTJ19ujKnTdboT
P7Liex4ltZQw2JwL1zlvs9mi82vEjnxnOSrGwElHA3LermGvSp3LkSnyQGsw8Lep
dxFvXiuEBSrtwazVeq3Zlm+0/6rfH97o5iVSY3RFUsHQxhzsJklRH45YRrTgCHNy
tX838HzstOBKI8qoz+E2+849C2ZiQrgtC8ycIOuQF38/8F6eDANNerhjinBXmn8m
Xbwt9gxRQdyI5b2rdPLVINhnUeo8z19xGIdSZFZKF40kwyjTp9rvkLfyn8HKFzY4
Xca/S+DMYNJQ+rZ3q2ymh+nVVf0pWC0P7xW1SZROgvphpyWgsLGd6ra48hF112cB
odpfBM542U+E/uNpvO7dJI+n9M4bOPrChjpmCBHcjRcaYRubDrs=
=Slso
-----END PGP SIGNATURE-----

Attachment: pgpzj3njpEo2f.pgp
Description: PGP signature


--- End Message ---

Reply via email to