security-misc/usr/lib/dracut/modules.d/10ram-wipe-exit/wipe-ram.sh

43 lines
1.2 KiB
Bash
Raw Normal View History

2023-01-06 10:50:34 -05:00
#!/bin/sh
2023-01-06 13:52:51 -05:00
## Copyright (C) 2023 - 2023 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## Copyright (C) 2023 - 2023 Friedrich Doku <friedrichdoku@gmail.com>
2023-01-06 13:47:34 -05:00
## See the file COPYING for copying conditions.
2023-01-06 10:50:34 -05:00
2023-01-07 12:54:35 -05:00
## TODO: rename to wipe-ram-exit.sh (so it is different from wipe-ram.sh)
2023-01-07 17:22:45 -05:00
DRACUT_QUIET=no
2023-01-07 17:23:25 -05:00
drop_caches() {
sync
## https://gitlab.tails.boum.org/tails/tails/-/blob/master/config/chroot_local-includes/usr/local/lib/initramfs-pre-shutdown-hook
### Ensure any remaining disk cache is erased by Linux' memory poisoning
echo 3 > /proc/sys/vm/drop_caches
sync
}
2023-01-06 10:50:34 -05:00
ram_wipe_action() {
local kernel_wiperam_exit
kernel_wiperam_exit=$(getarg wiperamexit)
if [ "$kernel_wiperam_exit" = "no" ]; then
2023-01-07 14:29:12 -05:00
info "wipe-ram.sh wiperamexit: Skip, because wiperamexit=no kernel parameter detected, OK."
return 0
fi
if [ "$kernel_wiperam_exit" != "yes" ]; then
2023-01-07 14:29:12 -05:00
info "wipe-ram.sh wiperamexit: Skip, because wiperamexit parameter is unset."
return 0
2023-01-06 10:50:34 -05:00
fi
2023-01-07 12:49:18 -05:00
info "wipe-ram.sh wiperamexit: wiperamexit=yes, therefore running second RAM wipe..."
2023-01-07 12:43:07 -05:00
2023-01-07 17:23:25 -05:00
drop_caches
2023-01-06 10:50:34 -05:00
sdmem -l -l -v
2023-01-07 17:23:25 -05:00
drop_caches
2023-01-07 16:00:42 -05:00
info "wipe-ram.sh wiperamexit: Second RAM wipe completed."
2023-01-06 10:50:34 -05:00
}
2023-01-07 12:43:07 -05:00
ram_wipe_action