bastille icon indicating copy to clipboard operation
bastille copied to clipboard

[BUG] destroy removes potentially mounted directories

Open gahr opened this issue 1 year ago • 1 comments

[MANDATORY] Describe the bug [MANDATORY] Normally, bastille stop would unmount any filesystems listed in the jail's fstab file, via jail -r. However, it is possible for the umount to fail (e.g., under a busy filesystem condition or under #659).

A subsequent bastille destroy (or a single bastille destroy force) doesn't double checks if any entries in fstab are still mounted, and proceeds to remove the whole jail directory.

I think bastille destroy should try harder not to remove files it doesn't own and error out if any filesystems are still mounted inside the jail dir.

[MANDATORY] Bastille and FreeBSD version (paste bastille -v && freebsd-version -kru output) 0.10.20231125 14.0-RELEASE-p3 14.0-RELEASE-p3 14.0-RELEASE-p4

[MANDATORY] How did you install bastille? (port/pkg/git) pkg

[optional] Steps to reproduce? Add a nullfs mount to a bastille jail. Make it fail to umount on bastille stop. Run bastille destroy. The target directory of the mount is now empty.

[optional] Expected behavior bastille destroy refuses to destroy a jail directory that contains mounted file systems.

gahr avatar Jan 07 '24 20:01 gahr

I ran into this as well. Checking for mounted filesystems before destruction would be much appreciated!

gzetzsche avatar Jun 03 '24 21:06 gzetzsche