mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-12-22 18:18:59 +00:00
FTR #31 : support key from stdin with -k -
This will be useful for integration with external tools/undertaker
This commit is contained in:
parent
13a9142949
commit
ce7edc1b63
21
src/tomb
21
src/tomb
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user