mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2025-01-03 14:17:37 +00:00
Delete mountpoint when tomb is closed (fix #149)
two 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 tombs must be closed when upgrading the tomb script, else it will not be able to correctly close them.
This commit is contained in:
parent
bfa77cc593
commit
eada0538c9
@ -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 }
|
||||
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
|
||||
@ -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"
|
||||
@ -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
|
||||
|
||||
@ -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) }
|
||||
|
||||
|
19
tomb
19
tomb
@ -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
|
||||
@ -1620,6 +1621,8 @@ change_tomb_key() {
|
||||
}
|
||||
|
||||
_check_swap
|
||||
|
||||
# this also calls _plot()
|
||||
is_valid_tomb $tombpath
|
||||
|
||||
lo_mount $TOMBPATH
|
||||
@ -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`
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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 ]] || {
|
||||
|
Loading…
Reference in New Issue
Block a user