mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-05 04:47:56 +00:00
sanitized the way key filenames are set
there was some inconsistency in the way load_keys was accepting different parameters or guessing from the tomb filename. fixes #98
This commit is contained in:
parent
325633d2fb
commit
9991405124
24
tomb
24
tomb
@ -566,15 +566,16 @@ load_key() {
|
|||||||
tombdir=`dirname $tombkey`
|
tombdir=`dirname $tombkey`
|
||||||
tombfile=`basename $tombkey`
|
tombfile=`basename $tombkey`
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
tombkey=${tombdir}/${tombfile}.key
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tombkey=${tombdir}/${tombfile}
|
xxx "load_key: ${tombkey}"
|
||||||
|
|
||||||
xxx "load_key: `ls -lh ${tombkey}`"
|
|
||||||
|
|
||||||
if [ -r "${tombkey}" ]; then
|
if [ -r "${tombkey}" ]; then
|
||||||
_message "We'll use this key: ${tombkey}"
|
_message "We'll use this key: ${tombkey}"
|
||||||
else
|
else
|
||||||
|
_warning "Key not found, specify one using -k"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1193,7 +1194,7 @@ lock_tomb_with_key() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# load key from options or file
|
# load key from options or file
|
||||||
tombkey=`load_key ${tombdir}/${tombfile}.key`
|
tombkey=`load_key ${tombdir}/${tombfile}`
|
||||||
{ test $? = 0 } || {
|
{ test $? = 0 } || {
|
||||||
losetup -d $nstloop
|
losetup -d $nstloop
|
||||||
die "Aborting operations: error loading key $tombkey" }
|
die "Aborting operations: error loading key $tombkey" }
|
||||||
@ -1412,7 +1413,7 @@ mount_tomb() {
|
|||||||
xxx "tomb found: ${tombdir}/${tombfile}"
|
xxx "tomb found: ${tombdir}/${tombfile}"
|
||||||
|
|
||||||
# load_key called here
|
# load_key called here
|
||||||
tombkey=`load_key ${tombdir}/${tombfile}.key`
|
tombkey=`load_key ${tombdir}/${tombfile}`
|
||||||
{ test $? = 0 } || {
|
{ test $? = 0 } || {
|
||||||
die "Aborting operations: error loading key $tombkey" }
|
die "Aborting operations: error loading key $tombkey" }
|
||||||
|
|
||||||
@ -1952,6 +1953,10 @@ resize_tomb() {
|
|||||||
fi
|
fi
|
||||||
# $1 is the tomb file path
|
# $1 is the tomb file path
|
||||||
|
|
||||||
|
local newtombsize="`option_value -s`"
|
||||||
|
{ test "$newtombsize" = "" } && {
|
||||||
|
die "Aborting operations: new size was not specified, use -s" }
|
||||||
|
|
||||||
local c tombpass tombkey
|
local c tombpass tombkey
|
||||||
|
|
||||||
tombdir=`dirname $1`
|
tombdir=`dirname $1`
|
||||||
@ -1959,13 +1964,12 @@ resize_tomb() {
|
|||||||
tombname=${tombfile%%\.*}
|
tombname=${tombfile%%\.*}
|
||||||
|
|
||||||
# load key from options or file
|
# load key from options or file
|
||||||
tombkey=`load_key ${tombdir}/${tombfile}`
|
local tombkey="`load_key ${tombdir}/${tombfile}`"
|
||||||
{ test $? = 0 } || {
|
|
||||||
die "Aborting operations: error loading key $tombkey" }
|
|
||||||
# make sure to call drop_key later
|
# make sure to call drop_key later
|
||||||
|
{ test -r "$tombkey" } || {
|
||||||
|
die "Aborting operations: key not found, use -k" }
|
||||||
|
|
||||||
local tmp_resize=`safe_filename resize`
|
local tmp_resize=`safe_filename resize`
|
||||||
local newtombsize=$opts[-s]
|
|
||||||
local oldtombsize=$(( `stat -c %s "$1" 2>/dev/null` / 1048576 ))
|
local oldtombsize=$(( `stat -c %s "$1" 2>/dev/null` / 1048576 ))
|
||||||
local mounted_tomb=`mount -l |
|
local mounted_tomb=`mount -l |
|
||||||
awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 }'`
|
awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 }'`
|
||||||
@ -2016,8 +2020,8 @@ resize_tomb() {
|
|||||||
get_lukskey "${tombpass}" ${tombkey} | \
|
get_lukskey "${tombpass}" ${tombkey} | \
|
||||||
cryptsetup --key-file - luksOpen ${nstloop} ${mapper}
|
cryptsetup --key-file - luksOpen ${nstloop} ${mapper}
|
||||||
|
|
||||||
unset tombpass
|
|
||||||
drop_key # cleanup after load_key
|
drop_key # cleanup after load_key
|
||||||
|
unset tombpass
|
||||||
|
|
||||||
if ! [ -r /dev/mapper/${mapper} ]; then
|
if ! [ -r /dev/mapper/${mapper} ]; then
|
||||||
losetup -d ${nstloop}
|
losetup -d ${nstloop}
|
||||||
|
Loading…
Reference in New Issue
Block a user