Hi,
We think the BCC should review the use of fmount or revise the script. fmount -u appears to wipe out all directories under /mnt and /media if no argument is supplied
Currently, BitCurator uses John Lehr's "fmount" script (located in /usr/local/bin/fmount) and called by the ~/.local/share/nautilus/scripts/Disk Image Mount and Disk Image Unmount scripts that run when right-clicking a mounted volume (or anything really) and clicking > scripts > Disk Image Unmount. The script, at least for us, has inadvertently removed content on other attached devices (mounted under /mnt or /media). The dangerous portions of this script are here:
--starting at line 123--## $OPTIND points to the next, unparsed argument
shift "$(( $OPTIND -1 ))"
IMAGE=($@)
DIR_NAME=$(basename ${IMAGE%.*})#check for root access
[[ $UID -ne 0 ]] && echo "Root access required." >&2 && exit 1## Determine volumes and starting offsets
if [ $UMOUNT -eq 1 ]
then
for DIR in media mnt
do
if [ -d /$DIR/$DIR_NAME ]
then
echo "Unmounting volumes at /${DIR}/$DIR_NAME/" >&2
umount /$DIR/$DIR_NAME/* 2>/dev/null
umount /$DIR/$DIR_NAME 2>/dev/null
rm -vrf /$DIR/$DIR_NAME
fi
done----------------
The nautilus script runs on all arguments "sudo fmount -u $@" and fmount does the same in line 125 'IMAGE="$@"'. If no argument is provided or if there is an issue with the argument, this affects the subsequent $IMAGE, and $DIR_NAME variables. If no $DIR_NAMEs are then created, then line 141 'rm -vrf /$DIR/$DIR_NAME' essentially removes all directories ($DIR) found under /mnt and /media, meaning any content on mounted media, e.g. if you had a separate USB key plugged in and it mounted as /media/USB, a rm -vrf would be run on it.
This isn't typically a feature we use (the nautilus scripts), but we tried it yesterday and subsequently lost content on an attached device under /media and /mnt was removed. I've tried this on two separate machines now, and got a coworker to check my work. Has anyone else seen this?
e.g.
run command: sudo fmount -u
output:
basename: missing operand
Try 'basename --help' for more information.
Unmounting volumes at /media//
removed directory '/media/storage'
removed directory '/media/test'
removed '/media/test/hello'
removed directory '/media/'
Unmounting volumes at /mnt//
removed directory '/mnt/'
Running Ubuntu 18.04.6 LTS.
Thank you,