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"
return 1
fi
# TODO: eliminate this function
get_arg_tomb $CMD2
local tombkey
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
# take key from a file
tombkey=`option_value -k`
fi
else
# guess key as lying besides the tomb
tombkey="${PARAM[1]}.key"
fi
echo the key used is $tombkey
@ -604,6 +617,12 @@ mount_tomb() {
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
break; # password was correct
fi