From 9fbb620c600baf163ff40febfe87ecf7eb063072 Mon Sep 17 00:00:00 2001 From: Anathema Date: Sun, 28 Aug 2011 20:21:10 +0200 Subject: [PATCH 1/2] added feature #25: an user can now specify a key name when creating tomb, using the -k flag --- src/tomb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/tomb b/src/tomb index 3861649..c209c6c 100755 --- a/src/tomb +++ b/src/tomb @@ -365,9 +365,15 @@ create_tomb() { return 1 fi - if [ -e ${tombdir}/${tombfile}.key ]; then + if option_is_set -k; then + tombkey=`option_value -k` + else + tombkey="${tombdir}/${tombfile}.key" + fi + + if [ -e "${tombkey}" ]; then error "tomb key already exists. Quitting." - ls -lh ${tombdir}/${tombfile}.key + ls -lh ${tombkey} return 1 fi @@ -456,7 +462,7 @@ create_tomb() { print "${tombpass}" | gpg \ --openpgp --batch --no-options --no-tty --passphrase-fd 0 2>/dev/null \ - -o "${tombdir}/${tombname}.tomb.key" -c -a ${keytmp}/tomb.tmp + -o "${tombkey}" -c -a ${keytmp}/tomb.tmp # if [ $? != 0 ]; then # error "setting password failed: gnupg returns 2" @@ -504,7 +510,7 @@ create_tomb() { chown $(id -u $ME):$(id -g $ME) ${tombfile} act "done creating $tombname encrypted storage (using Luks dm-crypt AES/SHA256)" - notice "Your tomb is ready in ${tombdir}/${tombfile} and secured with key ${tombfile}.key" + notice "Your tomb is ready in ${tombdir}/${tombfile} and secured with key ${tombkey}" } @@ -1227,7 +1233,7 @@ main() { subcommands_opts[__default]="" subcommands_opts[open]="n -nohook=n k: -key=k o: -mount-options=o -ignore-swap" subcommands_opts[mount]=${subcommands_opts[open]} - subcommands_opts[create]="s: -size=s -ignore-swap" + subcommands_opts[create]="s: -size=s -ignore-swap k: -key=k" subcommands_opts[close]="" subcommands_opts[help]="" subcommands_opts[slam]="" From d486c45f53b2d3cd06293114fab7a904d8eb32a8 Mon Sep 17 00:00:00 2001 From: Anathema Date: Mon, 29 Aug 2011 23:52:50 +0200 Subject: [PATCH 2/2] added extension .tomb.key to a specified key file (-k param) --- src/tomb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tomb b/src/tomb index c209c6c..2a66762 100755 --- a/src/tomb +++ b/src/tomb @@ -352,7 +352,7 @@ create_tomb() { # make sure the file has a .tomb extension tombname=${tombfile%%\.*} tombfile=${tombname}.tomb - tombsize=$opts[-s] + tombsize=$opts[-s] if [[ $tombsize != <-> ]]; then error "Size is not an integer" @@ -366,7 +366,7 @@ create_tomb() { fi if option_is_set -k; then - tombkey=`option_value -k` + tombkey="`option_value -k`.tomb.key" else tombkey="${tombdir}/${tombfile}.key" fi @@ -436,7 +436,7 @@ create_tomb() { exit 1 fi - notice "Setup your secret key file ${tombname}.tomb.key" + notice "Setup your secret key file ${tombkey}" # here user is prompted for key password for c in 1 2 3; do