From 55261a609129b2d82312070a4a67ba6d4569c676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Mon, 13 Jul 2020 17:05:36 -0300 Subject: [PATCH 1/3] 1: only create /run/runit directory. The 100 permission in /run/runit/stopit made it so that signaling runit with SIGCONT would shut the system down. To achieve the correct behavior, we should create the stopit and reboot files with 000 perms, and allow their permissions to be set correctly by calls to `init 0` or `init 6` or by /etc/runit/ctrlaltdel. 1 --- 1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/1 b/1 index 6938bc8..0bdba54 100755 --- a/1 +++ b/1 @@ -12,7 +12,7 @@ msg "Welcome to Void!" # Start core services: one-time system tasks. detect_virt for f in /etc/runit/core-services/*.sh; do - [ -r $f ] && . $f + [ -r $f ] && . $f done dmesg >/var/log/dmesg.log @@ -22,7 +22,9 @@ else chmod 0644 /var/log/dmesg.log fi +# create files for controlling runit mkdir -p /run/runit -install -m100 /dev/null /run/runit/stopit +install -m000 /dev/null /run/runit/stopit +install -m000 /dev/null /run/runit/reboot msg "Initialization complete, running stage 2..." From 369df4852c846f6f3f27fa84ac04d46964ec1724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Sat, 18 Jul 2020 04:00:56 -0300 Subject: [PATCH 2/3] 3: remove /run/runit/reboot handling. runit uses the permissions in the /etc/runit/reboot file to determine whether it's going to perform a halt or reboot action. This conditional in 3 meant that touching the reboot file, even with 000 perms, would lead to a reboot, which goes agains what is expected according to the runit documentation. --- 3 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/3 b/3 index 7945490..4a4781e 100755 --- a/3 +++ b/3 @@ -7,10 +7,6 @@ PATH=/usr/bin:/usr/sbin detect_virt [ -r /etc/rc.conf ] && . /etc/rc.conf -if [ -e /run/runit/reboot ]; then - chmod 100 /run/runit/reboot -fi - echo msg "Waiting for services to stop..." sv force-stop /var/service/* From 09465722f5413ff4581420dd2bc87c7df9a0525c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Mon, 13 Jul 2020 17:10:09 -0300 Subject: [PATCH 3/3] ctrlaltdel: trigger a reboot properly. /run/runit/{stopit,reboot} should have their perms set to 100 by ctrlaltdel, before runit signals itself with SIGCONT, in order to trigger a reboot. This script can be changed by a user to perform different actions. The comments in it explain what each file is for. --- ctrlaltdel | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ctrlaltdel b/ctrlaltdel index 7738067..866dcc8 100755 --- a/ctrlaltdel +++ b/ctrlaltdel @@ -3,8 +3,11 @@ PATH=/usr/bin:/usr/sbin MSG="System is going down..." +# We check for this file after receiving a SIGCONT to move to stage3 +chmod 100 /run/runit/stopit + # We check for this file in stage3 to halt or reboot -touch /run/runit/reboot +chmod 100 /run/runit/reboot # Proceed with shutdown process echo "$MSG" | wall