avoid creating targets for hooks

we require users to have the mount targets for hooks already existing
this behaviour is less intrusive in someone's home that is unconscious of hooks
plus it now supports mount bind of normal files
This commit is contained in:
Jaromil 2011-02-25 09:58:45 +01:00
parent b1208fca60
commit ce85f0aaa4

View File

@ -633,7 +633,6 @@ exec_safe_bind_hooks() {
func "bind-hooks not found in $MOUNTPOINT" func "bind-hooks not found in $MOUNTPOINT"
return 1 return 1
fi fi
typeset -al created
typeset -al mounted typeset -al mounted
typeset -Al maps typeset -Al maps
maps=($(<"$MOUNTPOINT/bind-hooks")) maps=($(<"$MOUNTPOINT/bind-hooks"))
@ -645,16 +644,16 @@ exec_safe_bind_hooks() {
if [ "${${maps[$dir]}[1]}" = "/" -o "${${maps[$dir]}[1,2]}" = ".." ]; then if [ "${${maps[$dir]}[1]}" = "/" -o "${${maps[$dir]}[1,2]}" = ".." ]; then
error "bind-hooks map format: local/to/tomb local/to/\$HOME. Rolling back" error "bind-hooks map format: local/to/tomb local/to/\$HOME. Rolling back"
for dir in ${mounted}; do umount $dir; done for dir in ${mounted}; do umount $dir; done
for dir in ${created}; do rmdir $dir; done
return 1 return 1
fi fi
if [ ! -d "$HOME/${maps[$dir]}" ]; then if [ ! -r "$HOME/${maps[$dir]}" ]; then
act "creating $HOME/${maps[$dir]}" error "bind-hook target not existent, skipping $HOME/${maps[$dir]}"
mkdir -p $HOME/${maps[$dir]} elif [ ! -r "$MOUNTPOINT/$dir" ]; then
created+=("$HOME/${maps[$dir]}") error "bind-hook source not found in tomb, skipping ${MOUNTPOINT}/${dir}"
else
mount -o bind $MOUNTPOINT/$dir $HOME/${maps[$dir]}
mounted+=("$HOME/${maps[$dir]}")
fi fi
mount --bind $MOUNTPOINT/$dir $HOME/${maps[$dir]}
mounted+=("$HOME/${maps[$dir]}")
done done
} }