tomb

the crypto undertaker
git clone git://parazyd.org/tomb.git
Log | Files | Refs | README | LICENSE

commit a5d09a055977ae544f940dd8e5fcca14a531c820
parent 825f7ed687c6a0facc8bad7ccc14e3d10e52015f
Author: Jaromil <jaromil@dyne.org>
Date:   Sat, 30 Mar 2013 18:59:34 +0100

create command restored for backward compatibility

the new mechanism to create tombs is in place (dig/forge/lock), but we
still wrap it with a create command for backward compatibility.

Diffstat:
Msrc/tomb | 35++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/src/tomb b/src/tomb @@ -800,6 +800,7 @@ dig_tomb() { # we will first touch the file and set permissions: this way, even if interrupted, permissions are right touch ${tombdir}/${tombfile} chmod 0600 "${tombdir}/${tombfile}" + chown $_uid:$_gid "${tombdir}/${tombfile}" $DD if=/dev/urandom bs=4k count=${tombsize_4k} of=${tombdir}/${tombfile} if [ $? = 0 -a -e ${tombdir}/${tombfile} ]; then @@ -972,7 +973,34 @@ lock_tomb_with_key() { _success "Your tomb is ready in ${tombdir}/${tombfile} and secured with key ${tombkey}" } + +# backward compatibility +create_tomb() { + if ! [ $1 ]; then + _warning "no tomb name specified for creation" + return 1 + fi + dig_tomb ${=PARAM} + { test $? = 0 } || { die "Failed to dig tomb, operation aborted." } + + tombfile=`basename $1` + tombdir=`dirname $1` + # make sure the file has a .tomb extension + tombname=${tombfile%%\.*} + tombfile=${tombname}.tomb + + forge_key ${tombfile}.key + { test $? = 0 } || { die "Failed to forge key, operation aborted." } + + lock_tomb_with_key ${tombfile} -l ${tombfile}.key + { test $? = 0 } || { die "Failed to lock tomb with key, operation aborted." } + + yes "Tomb $tombname succesfully created" + ls -l ${tombfile}* +} + + #internal use #$1 is the keyfile we are checking is_valid_key() { @@ -2140,7 +2168,12 @@ main() { check_priv lock_tomb_with_key ${=PARAM} ;; - + # backward compat + create) + check_priv + create_tomb ${=PARAM} + ;; + mount|open) check_priv mount_tomb $PARAM[1] $PARAM[2]