void-linux/void-runit

Wrong information in ctrlaltdel

ericonr opened this issue · 7 comments

I believe this comment in ctrlaltdel

# We check for this file in stage3 to halt or reboot
touch /run/runit/reboot

is wrong, because runit checks for it continuously during stage 2 (which is when it's running /etc/runit/2, which is what runs runsvdir), and then reboots the system if it is found. I feel like this comment implies that the file is only used for determining whether the system will reboot or shutdown, when runit gets to stage 3, but instead it just reboots the whole system.

How is this happening? runit-init(8) says that if it's called as either init 0 or init 6, it will change the permissions in /etc/runit/stopit and /etc/runit/reboot, and then send a CONT signal to runit. Is that signal not necessary? Because ctrlaltdel doesn't seem to send any signals beside touching that file, but it reliably reboots my system.

When runit(8) receives SIGINT it will execute /etc/runit/ctrlaltdel, after executing runit(8) checks for /etc/runit/stopit and /etc/runit/reboot and decides what should happen.

runit-init(8) has nothing really todo with it as its runit(8) which runs as pid 1.
The man page just describes what happens if you execute init 0 or init 6 to shutdown/reboot the system.

CTRL-ALT-DEL
If runit receives the ctrl-alt-del keyboard request and the file
/etc/runit/ctrlaltdel exists and has the execute by owner permission
set, runit runs /etc/runit/ctrlaltdel, waits for it to terminate, and
then sends itself a CONT signal.

@Duncaen I see, thanks! I guess I was missing that part about sending itself a CONT signal. Therefore, since we set the necessary permissions in /etc/runit/stopit during 1, removing the touch /run/runit/reboot line from ctrlaltdel will just control wheter the system halts or reboots?

Is there some way I could use ctrlaltdel for something other than halt/reboot? Would removing the execute permission from stopit be enough, and would it make the system behave weird? If it can work fine, I'd like to add it as a comment there, like uncomment the line below so Ctrl+Alt+Del doesn't reboot / halt the system.

The reboot file needs to be user executable to cause a reboot, so not sure if this even works as intended.

Yes I think removing u-x on stopit should work to ignore SIGINT/SIGCONT for pid1.
We are doing it a little bit wrong and I've talked with @leahneukirchen about it last time it came up in this issue: void-linux/void-packages#20098

2020-03-16 19:26:25     leah2   duncaen: arent we doing /run/runit/stopit wrong?
2020-03-16 19:27:36     duncaen I think so, I think the whole purpose is that only runit-init or our halt can take down the system, not a signal alone
2020-03-16 19:27:46     leah2   yes
2020-03-16 19:27:55     leah2   amazing noone complained about that
2020-03-16 19:27:59     leah2   sending SIGCONT should always be safe

So the right way would be to not chmod u+x stopit on boot and to do the chmod u+x it from ctrlaltdel.

I see. I will try to work on a patch for that, thanks!

Taking this discussion to #50, where we can debate the problem and solution simultaneously.