From ab56fb5761a0a73fcc252d9459f0d8feccee5330 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sun, 24 Nov 2024 15:24:21 -0700 Subject: [PATCH 1/3] Update destroy.sh - refuse to destroy jail with mounted filesystem --- usr/local/share/bastille/destroy.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index 9d9e9996..f3f0e3ec 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -54,6 +54,12 @@ destroy_jail() { fi if [ -d "${bastille_jail_base}" ]; then + ## make sure no filesystem is currently mounted in the jail directory + mount_points=$(mount | cut -d ' ' -f 3 | grep "${bastille_jail_base}") + if [ $? -eq 0 ]; then + error_notify "Failed to destroy jail: ${TARGET}" + error_exit "Jail has mounted filesystems:\n$mount_points" + fi info "Deleting Jail: ${TARGET}." if checkyesno bastille_zfs_enable; then if [ -n "${bastille_zfs_zpool}" ]; then From 09808b70ddb87740474271eef45d2e210573439d Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sun, 24 Nov 2024 17:45:49 -0700 Subject: [PATCH 2/3] Update destroy.sh - allow for jail root to be mounted when destroying This will allow the jail root to be mounted when destroying a jail, but if anything under 'root' is still mounted, it will exit. --- usr/local/share/bastille/destroy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index f3f0e3ec..0185e3d2 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -55,7 +55,7 @@ destroy_jail() { if [ -d "${bastille_jail_base}" ]; then ## make sure no filesystem is currently mounted in the jail directory - mount_points=$(mount | cut -d ' ' -f 3 | grep "${bastille_jail_base}") + mount_points=$(mount | cut -d ' ' -f 3 | grep "${bastille_jail_base}"/root/) if [ $? -eq 0 ]; then error_notify "Failed to destroy jail: ${TARGET}" error_exit "Jail has mounted filesystems:\n$mount_points" From ba2ff8ef75f6441934f4af36a9ae3ea68896727c Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:33:59 -0700 Subject: [PATCH 3/3] better error handling --- usr/local/share/bastille/destroy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index 0ba7e3f3..d95a4429 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -56,7 +56,7 @@ destroy_jail() { if [ -d "${bastille_jail_base}" ]; then ## make sure no filesystem is currently mounted in the jail directory mount_points=$(mount | cut -d ' ' -f 3 | grep "${bastille_jail_base}"/root/) - if [ $? -eq 0 ]; then + if [ -n "${mount_points}" ]; then error_notify "Failed to destroy jail: ${TARGET}" error_exit "Jail has mounted filesystems:\n$mount_points" fi