tomb

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

commit df75c39a584d05eba4f7c575d0b5b650bf2c9b01
parent 4b1afb4fab83984b8fb4b3c27c6b5ccabdce93d5
Author: Jaromil <jaromil@dyne.org>
Date:   Mon, 26 Dec 2016 12:12:34 +0100

new parsing for gpg_decrypt function

this new parser works with all ZSh versions and brings overall
improvement by eliminating the invocation of exernal binary `grep`
over the secret data.

Diffstat:
Mtomb | 28+++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/tomb b/tomb @@ -919,6 +919,7 @@ gpg_decrypt() { local gpgver=$(gpg --version --no-permission-warning | awk '/^gpg/ {print $3}') local gpgpass="$1\n$TOMBKEY" local gpgstatus + local tmpres [[ $gpgver == "1.4.11" ]] && { _verbose "GnuPG is version 1.4.11 - adopting status fix." @@ -927,23 +928,24 @@ gpg_decrypt() { gpg --batch --passphrase-fd 0 --no-tty --no-options` ret=$? unset gpgpass + return $ret + } - } || { # using status-file in gpg != 1.4.11 - - TOMBSECRET=`print - "$gpgpass" | \ - gpg --batch --passphrase-fd 0 --no-tty --no-options \ + _tmp_create + tmpres=$TOMBTMP + print - "$gpgpass" | \ + gpg --batch --passphrase-fd 0 --no-tty --no-options \ --status-fd 2 --no-mdc-warning --no-permission-warning \ - --no-secmem-warning` |& grep GNUPG: \ - | read -r -d'\n' gpgstatus - - unset gpgpass - - ret=1 - - [[ "${gpgstatus}" =~ "DECRYPTION_OKAY" ]] && { ret=0 } + --no-secmem-warning 2> $tmpres \ + | read -r -d'\n' TOMBSECRET + unset gpgpass - } + ret=1 + for i in ${(f)"$(cat $tmpres)"}; do + _verbose "$i" + [[ "$i" =~ "DECRYPTION_OKAY" ]] && { ret=0 } + done return $ret }