FTR #31 : support key from stdin with -k -

This will be useful for integration with external tools/undertaker
This commit is contained in:
boyska 2011-08-28 19:28:47 +02:00
parent 13a9142949
commit ce7edc1b63

View File

@ -520,11 +520,24 @@ mount_tomb() {
error "no tomb name specified for creation" error "no tomb name specified for creation"
return 1 return 1
fi fi
# TODO: eliminate this function
get_arg_tomb $CMD2 get_arg_tomb $CMD2
local tombkey local tombkey
if option_is_set -k ; then if option_is_set -k ; then
tombkey=`option_value -k` if [[ "`option_value -k`" == "-" ]]; then
# take key from stdin
local tombkeydir
tombkeydir=`safe_dir`
cat > ${tombkeydir}/stdin.tmp
tombkey=${tombkeydir}/stdin.tmp
else else
# take key from a file
tombkey=`option_value -k`
fi
else
# guess key as lying besides the tomb
tombkey="${PARAM[1]}.key" tombkey="${PARAM[1]}.key"
fi fi
echo the key used is $tombkey echo the key used is $tombkey
@ -604,6 +617,12 @@ mount_tomb() {
unset tombpass unset tombpass
# if key was from stdin delete temp file and dir
if [ $tombkeydir ]; then
${WIPE[@]} ${tombkey}
rmdir $tombkeydir
fi
if [ -r /dev/mapper/${mapper} ]; then if [ -r /dev/mapper/${mapper} ]; then
break; # password was correct break; # password was correct
fi fi