Skip to content

Commit

Permalink
Refuse to destroy a jail with mounted filesystems
Browse files Browse the repository at this point in the history
```
 # bastille create temp 14.0-RELEASE 192.168.1.10 lo1
 ...
 # mkdir test
 # cp /usr/bin/less test/
 # mkdir /usr/local/bastille/jails/temp/root/test
 # bastille mount temp $(realpath test) test
 [temp]:
 Added: /root/admin/bastille/test
 /usr/local/bastille/jails/temp/root/test nullfs ro 0 0
 # /usr/local/bastille/jails/temp/root/test/less -f /dev/stdin &
 # bastille destroy force temp
 rdr-anchor not found in pf.conf
 [temp]:
 temp: removed
 umount: unmount of /usr/local/bastille/jails/temp/root/test failed:
 Device busy
 jail: temp: /sbin/umount -t nullfs
 /usr/local/bastille/jails/temp/root/test: failed

 Deleting Jail: temp.
 Jail has mounted filesystems:
 /usr/local/bastille/jails/temp/root/test
```
  • Loading branch information
gahr committed Jan 22, 2024
1 parent 3a4ebc6 commit 6c32f7f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions usr/local/share/bastille/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ 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_exit "Jail has mounted filesystems:\n$mount_points"
fi
## removing all flags
chflags -R noschg "${bastille_jail_base}"

Expand Down

0 comments on commit 6c32f7f

Please sign in to comment.