code simplification

This commit is contained in:
Patrick Schleizer 2023-10-22 08:50:57 -04:00
parent 05e9accf64
commit 167683ce76
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

View File

@ -54,8 +54,6 @@ if [ "$noexec" = "true" ]; then
noexec_maybe=",noexec"
fi
command -v str_replace >/dev/null
exit_code=0
mount_output="$(mount)"
@ -70,11 +68,6 @@ remount_secure() {
## example status_file_full_path:
## /var/run/remount-secure/_home
## str_replace is provided by package helper-scripts.
mount_folder="$(echo "${status_file_name}" | LANG=C str_replace "_" "/")"
## example mount_folder:
## /home
mount_line_of_mount_folder="$(echo "$mount_output" | grep "$mount_folder ")" || true
if echo "$mount_line_of_mount_folder" | grep --quiet "$new_mount_options" ; then
@ -107,28 +100,33 @@ remount_secure() {
}
_home() {
mount_folder="/home"
new_mount_options="nosuid,nodev${noexec_maybe}"
remount_secure "$@"
}
_run() {
mount_folder="/run"
## https://lists.freedesktop.org/archives/systemd-devel/2015-February/028456.html
new_mount_options="nosuid,nodev${noexec_maybe}"
remount_secure "$@"
}
_dev_shm() {
mount_folder="/dev/shm"
new_mount_options="nosuid,nodev${noexec_maybe}"
remount_secure "$@"
}
_tmp() {
mount_folder="/tmp"
new_mount_options="nosuid,nodev${noexec_maybe}"
remount_secure "$@"
}
## https://forums.whonix.org/t/re-mount-home-and-other-with-noexec-and-nosuid-among-other-useful-mount-options-for-better-security/7707/25
# _lib() {
# mount_folder="/lib"
# ## Not using noexec on /lib.
# new_mount_options="nosuid,nodev"
# remount_secure "$@"