RFH: sysvinit etc. in Debian

Jonathan de Boyne Pollard J.deBoynePollard-newsgroups at NTLWorld.COM
Sat Nov 17 15:00:13 GMT 2018


Lorenz:

> The problem was solved by Mark Hindley on Elogind's side,
>
But as you yourself later added, it isn't very satisfactory.

This is something where Debian's shim for runit could improve *anyway*, 
considered standalone without reference to elogind.

There are four different shutdown actions: shutdown-and-infinite-loop, 
shutdown-and-poweroff, shutdown-and-powercycle, and 
shutdown-and-restart.  Debian's shim for runit provides just two 
actions; it missing out shutdown-and-powercycle, and mixing 
shutdown-and-infinite-loop and shutdown-and-poweroff into one.

The shim expects to be sending commands to a van Smoorenburg init 
program listening on the initctl FIFO.  shutdown-and-powercycle is too 
new an idea for this, it having been introduced by Warner Losh in 2017.  
So that's going to be a difficulty for the future, although I strongly 
recommend keeping the -c flag to halt/reboot/poweroff , and the related 
command name "powercycle", reserved now so that there aren't conflicts.

Differentiating shutdown-and-poweroff from shutdown-and-infinite-loop 
has two parts.

First, there's a step of the dance that the shim does not currently do, 
that it has to do.  In the actual van Smoorenburg system, *two* commands 
are sent via the FIFO when the action is explicit.  The first sets the 
INIT_HALT environment variable in the environment of process 1, to 
either POWEROFF or HALT.  (This is picked up by a later child process 
that runs /etc/rc0.d/K99halt.)  The second command requests the change 
to run level 0.  (This kicks off the procedure that eventually ends up 
running /etc/rc0.d/K99halt in a child process.)

(This is currently broken in the van Smoorenburg toolset.  Tell it to 
"/sbin/halt -p" and it outright forgets about the "-p" flag and thus 
never forces the INIT_HALT environment variable.)

Second, the shim, which is one of those programs that varies its 
behaviour according to what name it is invoked by, needs to recognize 
the name "poweroff" as well, which it currently does not.

There's more to a general-purpose shim than this.  I speak as the author 
of one.  A general purpose shim has to recognize commands such as 
"reboot -h", "halt -p", and "poweroff -r", run by sadistic system 
adminstrators who like to give the poor computers self-contradictory 
instructions.  (I kid you not.  For compatibility with multiple toolsets 
and their usages, one ends up with every one of these commands 
supporting options that contradict the name of the command.)  Debian's 
shim for runit can probably get away with not supporting "-r", "-p", and 
"-h", luckily.

But one of the things that it probably cannot get away with is that 
initctl isn't necessarily there on a systemd system, it being an 
optional backwards compatibility mechanism; and even when it is it does 
not support the INIT_HALT environment variable part of the dance: making 
the runit-under-systemd case act differently from the 
runit-under-van-Smoorenburg case, for shutdown-and-poweroff and 
shutdown-and-infinite-loop.  On a systemd system, the native API is to 
send signals to process 1, not to write messages to the initctl FIFO. 
Debian's shim for runit really needs to use the native mechanism in the 
systemd case.





More information about the Debian-init-diversity mailing list