tFTR #31 : support key from stdin with -k - - tomb - the crypto undertaker
HTML git clone git://parazyd.org/tomb.git
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit ce7edc1b6321196088c7447c8b3612dc5dd86e7a
DIR parent 13a9142949e8ccb4b9816cf30bc34e2c82fe6267
HTML Author: boyska <piuttosto@logorroici.org>
Date: Sun, 28 Aug 2011 19:28:47 +0200
FTR #31 : support key from stdin with -k -
This will be useful for integration with external tools/undertaker
Diffstat:
M src/tomb | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
---
DIR diff --git a/src/tomb b/src/tomb
t@@ -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
t@@ -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