From 9fbb620c600baf163ff40febfe87ecf7eb063072 Mon Sep 17 00:00:00 2001 From: Anathema Date: Sun, 28 Aug 2011 20:21:10 +0200 Subject: [PATCH] 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]=""