tomb

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

commit 6c71f2c94bab144b5d9027f7cc2a84799766b699
parent 8df1575a4423b436b13c0447623df61ec0dac6b7
Author: hellekin <hellekin@cepheide.org>
Date:   Tue,  4 Nov 2014 02:45:10 -0300

[cleanup] Process subcommands

Diffstat:
Mtomb | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 74 insertions(+), 36 deletions(-)

diff --git a/tomb b/tomb @@ -2553,87 +2553,123 @@ main() { $_UID $_GID $_TTY } + # Process subcommand case "$subcommand" in - # new creation in three steps - forge) - check_priv - forge_key ${=PARAM} + # USAGE + help) + usage + ;; + + # DEPRECATED! + # TODO: remove in 2.0 + create) + _warning "The create command is deprecated, please use dig, forge and lock instead." + _warning "For more informations see Tomb's manual page (man tomb)." + _failure "Operation aborted." ;; + + # CREATE Step 1: dig -s NN file.tomb dig) check_priv dig_tomb ${=PARAM} ;; - lock) - check_priv - lock_tomb_with_key ${=PARAM} - ;; - setkey) + # CREATE Step 2: forge file.tomb.key + forge) check_priv - change_tomb_key ${=PARAM} - ;; - - engrave) - [[ $QRENCODE == 0 ]] && { - _failure "QREncode not installed: cannot engrave keys on paper." } - engrave_key ${=PARAM} + forge_key ${=PARAM} ;; - # backward compat - create) - _warning "The create command is deprecated, please use dig, forge and lock instead." - _warning "For more informations see Tomb's manual page (man tomb)." + # CREATE Step 2: lock -k file.tomb.key file.tomb + lock) + check_priv + lock_tomb_with_key ${=PARAM} ;; + # Open the tomb mount|open) check_priv mount_tomb $PARAM[1] $PARAM[2] ;; + + # Close the tomb + # `slam` is used to force closing. umount|close|slam) check_priv - [ "$subcommand" = "slam" ] && SLAM=1 + [[ "$subcommand" == "slam" ]] && SLAM=1 umount_tomb $PARAM[1] ;; - passwd) + + # Grow tomb's size + resize) + [[ $RESIZER == 0 ]] && { + _failure "Resize2fs not installed: cannot resize tombs." } check_priv - change_passwd $PARAM[1] - ;; - list) - list_tombs $PARAM[1] + resize_tomb $PARAM[1] ;; + ## Contents manipulation + + # Index tomb contents index) index_tombs $PARAM[1] + ;; + + # List tombs + list) + list_tombs $PARAM[1] ;; + + # Search tomb contents search) search_tombs ${=PARAM} ;; - help) - usage + ## Locking operations + + # Export key to QR Code + engrave) + [[ $QRENCODE == 0 ]] && { + _failure "QREncode not installed: cannot engrave keys on paper." } + engrave_key ${=PARAM} ;; + + # Change password on existing key + passwd) + check_priv + change_passwd $PARAM[1] + ;; + + # Change tomb key + setkey) + check_priv + change_tomb_key ${=PARAM} + ;; + + # STEGANOGRAPHY: hide key inside an image bury) [[ $STEGHIDE == 0 ]] && { _failure "Steghide not installed: cannot bury keys into images." } bury_key $PARAM[1] ;; - exhume) + + # STEGANOGRAPHY: read key hidden in an image + exhume) [[ $STEGHIDE == 0 ]] && { _failure "Steghide not installed: cannot exhume keys from images." } exhume_key $PARAM[1] ;; - resize) - [[ $RESIZER == 0 ]] && { - _failure "Resize2fs not installed: cannot resize tombs." } - check_priv - resize_tomb $PARAM[1] - ;; - # internal commands useful to developers + ## Internal commands useful to developers + + # Make tomb functions available to the calling shell or script 'source') return 0 ;; + + # Ask user for a password interactively askpass) ask_password $PARAM[1] $PARAM[2] ;; + # Default operation: presentation, or version information with -v __default) _print "Tomb ::1 version:: - a strong and gentle undertaker for your secrets" $VERSION _print "\000" @@ -2660,6 +2696,8 @@ EOF } usage ;; + + # Reject unknown command and suggest help *) _warning "Command \"::1 subcommand::\" not recognized." $subcommand _message "Try -h for help."