URI: 
       tDelete mountpoint when tomb is closed (fix #149) - tomb - the crypto undertaker
  HTML git clone git://parazyd.org/tomb.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit eada0538c9c3bc67c376163f470d8bca7848e42e
   DIR parent bfa77cc5934cf8b5ac43bd2f92dc5bd6a80c8e1c
  HTML Author: Jaromil <jaromil@dyne.org>
       Date:   Fri, 26 Jun 2015 11:47:19 +0200
       
       Delete mountpoint when tomb is closed (fix #149)
       
       ttwo bugs were left behind by the last refactoring, one about
       consistency of the mountpoint naming (now using $TOMBNAME everywhere,
       without the added .tomb extension as per #180), the other about a
       missing _sudo to prefix rmdir commands.
       
       Test suite has been updated accordingly.
       
       This fix introduces a mandatory condition for the next update: all
       ttombs must be closed when upgrading the tomb script, else it will not
       be able to correctly close them.
       
       Diffstat:
         M extras/test/runtests                |      24 ++++++++++++------------
         M tomb                                |      19 ++++++++++++-------
       
       2 files changed, 24 insertions(+), 19 deletions(-)
       ---
   DIR diff --git a/extras/test/runtests b/extras/test/runtests
       t@@ -84,15 +84,15 @@ test-tomb-create() {
        
        test-bind-hooks() {
            notice "Testing bind hooks"
       -    tt list test
       -    [[ $? = 0 ]] || {
       -        tt --ignore-swap --unsafe --tomb-pwd ${dummypass} \
       -            open /tmp/test.tomb -k /tmp/test.tomb.key }
       +
       +    tt --ignore-swap --unsafe --tomb-pwd ${dummypass} \
       +        open /tmp/test.tomb -k /tmp/test.tomb.key
       +
            rnd=$RANDOM
            bindtest="dyne-tomb-bind-test-$rnd"
       -    echo $rnd > /media/test.tomb/$bindtest
       -    rm -f /media/test.tomb/bind-hooks
       -    echo "$bindtest $bindtest" > /media/test.tomb/bind-hooks
       +    echo $rnd > /media/test/$bindtest
       +    rm -f /media/test/bind-hooks
       +    echo "$bindtest $bindtest" > /media/test/bind-hooks
            touch $HOME/$bindtest
            tt close test
            tt -k /tmp/test.tomb.key --unsafe --tomb-pwd ${dummypass} open /tmp/test.tomb
       t@@ -104,7 +104,7 @@ test-bind-hooks() {
            else
                    error "Bind hook on file reports incongruence"
            fi
       -    rm -f "/media/test.tomb/$bindtest"
       +    rm -f "/media/test/$bindtest"
            tt close test
            # Remove test file in HOME
            rm -f "$HOME/$bindtest"
       t@@ -186,10 +186,10 @@ notice "Generating content for file integrity test"
        
        tt -k /tmp/test.tomb.key --unsafe --tomb-pwd ${dummypass} open /tmp/test.tomb
        
       -tt dig -s 10 /media/test.tomb/datacheck.raw
       +tt dig -s 10 /media/test/datacheck.raw
        
       -crc="sha256 /media/test.tomb/datacheck.raw"
       -echo "$crc" > /media/test.tomb/datacheck.sha
       +crc="sha256 /media/test/datacheck.raw"
       +echo "$crc" > /media/test/datacheck.sha
        
        tt --unsafe close test
        
       t@@ -208,7 +208,7 @@ tt -k /tmp/test.tomb.key --unsafe --tomb-pwd ${dummypass} open /tmp/test.tomb
        
        { test $? = 0 } && {
            
       -    crc2="sha256 /media/test.tomb/datacheck.raw"
       +    crc2="sha256 /media/test/datacheck.raw"
            
            { test "$crc" = "$crc2" } && { results+=(chksum SUCCESS) }
        
   DIR diff --git a/tomb b/tomb
       t@@ -230,6 +230,7 @@ _whoami() {
        
        # Define sepulture's plot (setup tomb-related arguments)
        # Synopsis: _plot /path/to/the.tomb
       +# Set TOMB{PATH,DIR,FILE,NAME}
        _plot() {
        
            # We set global variables
       t@@ -1620,6 +1621,8 @@ change_tomb_key() {
            }
        
            _check_swap
       +
       +    # this also calls _plot()
            is_valid_tomb $tombpath
        
            lo_mount $TOMBPATH
       t@@ -1704,20 +1707,21 @@ mount_tomb() {
        
            _check_swap
        
       +    # this also calls _plot()
            is_valid_tomb $tombpath
        
            _load_key # Try loading new key from option -k and set TOMBKEYFILE
        
            tombmount="$2"
            [[ "$tombmount" = "" ]] && {
       -        tombmount=/media/$TOMBFILE
       +        tombmount=/media/$TOMBNAME
                [[ -d /media ]] || { # no /media found, adopting /run/media/$USER (udisk2 compat)
       -            tombmount=/run/media/$_USER/$TOMBFILE
       +            tombmount=/run/media/$_USER/$TOMBNAME
                }
                _message "Mountpoint not specified, using default: ::1 mount point::" $tombmount
            }
        
       -    _success "Opening ::1 tomb file:: on ::2 mount point::" $TOMBFILE $tombmount
       +    _success "Opening ::1 tomb file:: on ::2 mount point::" $TOMBNAME $tombmount
        
            lo_mount $TOMBPATH
            nstloop=`lo_new`
       t@@ -1799,7 +1803,7 @@ mount_tomb() {
                [[ $oldmountopts != $MOUNTOPTS ]] && \
                  _warning "Are mount options '::1 mount options::' valid?" $MOUNTOPTS
                # TODO: move cleanup to _endgame()
       -        [[ -d $tombmount ]] && rmdir $tombmount
       +        [[ -d $tombmount ]] && _sudo rmdir $tombmount
                [[ -e /dev/mapper/$mapper ]] && _sudo cryptsetup luksClose $mapper
                # The loop is taken care of in _endgame()
                _failure "Cannot mount ::1 tomb name::" $TOMBNAME
       t@@ -2275,7 +2279,8 @@ resize_tomb() {
            [[ -z "$newtombsize" ]] && {
                _failure "Aborting operations: new size was not specified, use -s" }
        
       -    is_valid_tomb $tombpath        # Set TOMB{PATH,DIR,FILE,NAME}
       +    # this also calls _plot()
       +    is_valid_tomb $tombpath
        
            _load_key # Try loading new key from option -k and set TOMBKEYFILE
        
       t@@ -2414,8 +2419,8 @@ umount_tomb() {
                [[ $? = 0 ]] || { _failure "Tomb is busy, cannot umount!" }
        
                # If we used a default mountpoint and is now empty, delete it
       -        [[ "$tombmount" -regex-match "[/run]?/media[/$_USER]?/$tombname.tomb" ]] && {
       -            rmdir $tombmount }
       +        [[ "$tombmount" -regex-match "[/run]?/media[/$_USER]?/$tombname" ]] && {
       +            _sudo rmdir $tombmount }
        
                _sudo cryptsetup luksClose $mapper
                [[ $? == 0 ]] || {