From 9e820f3de6a1b3ecab0662d0ae30c0b79d6d4e43 Mon Sep 17 00:00:00 2001 From: Jaromil Date: Mon, 3 Jun 2013 10:55:53 +0200 Subject: [PATCH] Fixes to GnuPG 1.4.11/1.4.12 result parsing GnuPG 1 changes behaviour across 1.4.11 and 12 minor versions when it comes to --status-fd and messaging on stderr/stdout. This is a fix to make sure that gpg output is parsed correctly --- tomb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tomb b/tomb index 3d61725..6120ead 100755 --- a/tomb +++ b/tomb @@ -610,15 +610,31 @@ get_lukskey() { ;; esac fi + + # fix for gpg 1.4.11 where the --status-* options don't work ;^/ + gpgver=`gpg --version | awk '/^gpg/ {print $3}'` + if [ "$gpgver" = "1.4.11" ]; then + xxx "GnuPG is version 1.4.11 - adopting status fix" + + print ${tombpass} | \ + gpg --batch --passphrase-fd 0 --no-tty --no-options -d "${keyfile}" + unset tombpass + ret=$? + + else # using status-file in gpg != 1.4.12 + res=`safe_filename tomb.open` - (( $? )) && { unset tombpass; die "error creating temp dir" } + { test $? = 0 } || { unset tombpass; die "Fatal error creating temp file." } print ${tombpass} | \ gpg --batch --passphrase-fd 0 --no-tty --no-options --status-fd 2 \ + --no-mdc-warning --no-permission-warning --no-secmem-warning \ -d "${keyfile}" 2>$res unset tombpass grep 'DECRYPTION_OKAY' $res ret=$?; rm -f $res + + fi xxx "get_lukskey returns $ret" return $ret }