tbetter checks on file creation, both on dig and forge - tomb - the crypto undertaker (HTM) git clone git://parazyd.org/tomb.git (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit d8c5cd24d14b561742f614c43eed77269a2ab635 (DIR) parent dd91e124b41ef4d139f2b28d7b993529377d5ca5 (HTM) Author: Jaromil <jaromil@dyne.org> Date: Sun, 4 Jan 2015 21:02:27 +0100 better checks on file creation, both on dig and forge Diffstat: M tomb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- (DIR) diff --git a/tomb b/tomb t@@ -1358,6 +1358,10 @@ dig_tomb() { # Ensure that file permissions are safe even if interrupted touch $TOMBPATH + [[ $? = 0 ]] || { + _warning "Error creating the tomb ::1 tomb path::" $TOMBPATH + _failure "Operation aborted." + } chmod 0600 $TOMBPATH _verbose "Data dump using ::1:: from /dev/urandom" ${DD[1]} t@@ -1410,6 +1414,12 @@ forge_key() { ls -lh $destkey _failure "Forging this key would overwrite an existing file. Operation aborted." } + touch $destkey + [[ $? == 0 ]] || { + _warning "Cannot generate encryption key." + _failure "Operation aborted." } + chmod 0600 $destkey + # Update algorithm if it was passed on the command line with -o { option_is_set -o } && algopt="$(option_value -o)" [[ -n "$algopt" ]] && algo=$algopt t@@ -1439,8 +1449,6 @@ forge_key() { _success "Choose the password of your key: ::1 tomb key::" $TOMBKEYFILE _message "(You can also change it later using 'tomb passwd'.)" # _user_file $TOMBKEYFILE - touch $TOMBKEYFILE - chmod 0600 $TOMBKEYFILE tombname="$TOMBKEYFILE" # XXX ??? # the gen_key() function takes care of the new key's encryption