tPrevent directory removals if tomb didn't create them - tomb - the crypto undertaker (HTM) git clone git://parazyd.org/tomb.git (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit f408017c07b75f30c728a3f6545d93b17fe4bd3b (DIR) parent 7756dc161011552661e474807515f48a3ec04d09 (HTM) Author: Hellekin O. Wolf =8) <hellekin@cepheide.org> Date: Sat, 12 Feb 2011 08:30:37 +0100 Prevent directory removals if tomb didn't create them Diffstat: M src/tomb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- (DIR) diff --git a/src/tomb b/src/tomb t@@ -570,7 +570,9 @@ mount_tomb() { notice "mounting $tombfile on mountpoint $tombmount" # we need root from here on - mkdir -p $tombmount + + local norm=$(test -d $tombmount) + $norm || mkdir -p $tombmount nstloop=`losetup -f` losetup -f ${tombfile} t@@ -580,7 +582,7 @@ mount_tomb() { if [ $? != 0 ]; then # is it a LUKS encrypted nest? see cryptsetup(1) error "$tombfile is not a valid Luks encrypted storage file" - rmdir $tombmount 2>/dev/null + $norm || rmdir $tombmount 2>/dev/null return 1 fi t@@ -624,7 +626,7 @@ mount_tomb() { if ! [ -r /dev/mapper/${mapper} ]; then error "failure mounting the encrypted file" losetup -d ${nstloop} - rmdir ${tombmount} 2>/dev/null + $norm || rmdir ${tombmount} 2>/dev/null return 1 fi