tfix is_valid_tomb check for already mounted tombs - tomb - the crypto undertaker (HTM) git clone git://parazyd.org/tomb.git (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 14cba81f6e97d1a1fa8ffcf2d34fc96d13d79d63 (DIR) parent db976a521029c5991d8316f6d0572e5d6e9b482e (HTM) Author: Jaromil <jaromil@dyne.org> Date: Mon, 26 Dec 2016 20:40:23 +0100 fix is_valid_tomb check for already mounted tombs also added some more verbosity on debug Diffstat: M tomb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- (DIR) diff --git a/tomb b/tomb t@@ -507,20 +507,27 @@ is_valid_tomb() { _warning "Tomb file is not writable: ::1 tomb file::" $1 _fail=1 } + _verbose "tomb file is readable" + [[ ! -f "$1" ]] && { _warning "Tomb file is not a regular file: ::1 tomb file::" $1 _fail=1 } + _verbose "tomb file is a regular file" + [[ ! -s "$1" ]] && { _warning "Tomb file is empty (zero length): ::1 tomb file::" $1 _fail=1 } + _verbose "tomb file is not empty" _uid="`zstat +uid $1`" [[ "$_uid" = "$UID" ]] || { _user="`zstat -s +uid $1`" _warning "Tomb file is owned by another user: ::1 tomb owner::" $_user } + _verbose "tomb is not owned by another user" + [[ $_fail = 1 ]] && { _failure "Tomb command failed: ::1 command name::" $subcommand } t@@ -536,9 +543,12 @@ is_valid_tomb() { _plot $1 # Set TOMB{PATH,DIR,FILE,NAME} # Tomb already mounted (or we cannot alter it) - [[ "`mount -l`" -regex-match "${TOMBFILE}.*\[$TOMBNAME\]$" ]] && { + [[ "`mount -l | + awk -vtomb="[$TOMBNAME]" ' +/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 }'`" = "" ]] || { _failure "Tomb is currently in use: ::1 tomb name::" $TOMBNAME } + _verbose "tomb file is not currently in use" _message "Valid tomb file found: ::1 tomb path::" $TOMBPATH