Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong information in ctrlaltdel #47

Closed
ericonr opened this issue Jul 10, 2020 · 7 comments · Fixed by #50
Closed

Wrong information in ctrlaltdel #47

ericonr opened this issue Jul 10, 2020 · 7 comments · Fixed by #50

Comments

@ericonr
Copy link
Member

ericonr commented Jul 10, 2020

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.

@ericonr
Copy link
Member Author

ericonr commented Jul 12, 2020

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.

@Duncaen
Copy link
Member

Duncaen commented Jul 13, 2020

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.

@ericonr
Copy link
Member Author

ericonr commented Jul 13, 2020

@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.

@Duncaen
Copy link
Member

Duncaen commented Jul 13, 2020

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

@Duncaen
Copy link
Member

Duncaen commented Jul 13, 2020

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

@ericonr
Copy link
Member Author

ericonr commented Jul 13, 2020

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

@ahesford
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants