Add emergency shutdown feature, triggered by root device removal

This commit is contained in:
Aaron Rainbolt 2025-05-09 18:46:41 -05:00
parent 341dce33fb
commit f3d46ee562
No known key found for this signature in database
GPG key ID: A709160D73C79109
5 changed files with 337 additions and 0 deletions

View file

@ -0,0 +1,24 @@
#!/bin/bash
# Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
# See the file COPYING for copying conditions.
gcc \
-o \
/run/force-shutdown-when-device-removed \
-static \
/usr/src/security-misc/force-shutdown-when-device-removed.c \
|| {
printf "%s\n" 'Could not compile force-shutdown executable!'
exit 1;
}
readarray -t root_devices < <(/usr/libexec/helper-scripts/get-backing-devices-for-mountpoint '/');
## memlockd daemonizes itself, so no need to background it
memlockd -c /usr/share/security-misc/security-misc-memlockd.cfg
/run/force-shutdown-when-device-removed "${root_devices}" &
sleep 1
disown
exit 0