mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-22 20:45:13 +00:00
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.
This commit is contained in:
parent
4b1afb4fab
commit
df75c39a58
22
tomb
22
tomb
@ -919,6 +919,7 @@ gpg_decrypt() {
|
|||||||
local gpgver=$(gpg --version --no-permission-warning | awk '/^gpg/ {print $3}')
|
local gpgver=$(gpg --version --no-permission-warning | awk '/^gpg/ {print $3}')
|
||||||
local gpgpass="$1\n$TOMBKEY"
|
local gpgpass="$1\n$TOMBKEY"
|
||||||
local gpgstatus
|
local gpgstatus
|
||||||
|
local tmpres
|
||||||
|
|
||||||
[[ $gpgver == "1.4.11" ]] && {
|
[[ $gpgver == "1.4.11" ]] && {
|
||||||
_verbose "GnuPG is version 1.4.11 - adopting status fix."
|
_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`
|
gpg --batch --passphrase-fd 0 --no-tty --no-options`
|
||||||
ret=$?
|
ret=$?
|
||||||
unset gpgpass
|
unset gpgpass
|
||||||
|
return $ret
|
||||||
|
}
|
||||||
|
|
||||||
} || { # using status-file in gpg != 1.4.11
|
_tmp_create
|
||||||
|
tmpres=$TOMBTMP
|
||||||
TOMBSECRET=`print - "$gpgpass" | \
|
print - "$gpgpass" | \
|
||||||
gpg --batch --passphrase-fd 0 --no-tty --no-options \
|
gpg --batch --passphrase-fd 0 --no-tty --no-options \
|
||||||
--status-fd 2 --no-mdc-warning --no-permission-warning \
|
--status-fd 2 --no-mdc-warning --no-permission-warning \
|
||||||
--no-secmem-warning` |& grep GNUPG: \
|
--no-secmem-warning 2> $tmpres \
|
||||||
| read -r -d'\n' gpgstatus
|
| read -r -d'\n' TOMBSECRET
|
||||||
|
|
||||||
unset gpgpass
|
unset gpgpass
|
||||||
|
|
||||||
ret=1
|
ret=1
|
||||||
|
for i in ${(f)"$(cat $tmpres)"}; do
|
||||||
[[ "${gpgstatus}" =~ "DECRYPTION_OKAY" ]] && { ret=0 }
|
_verbose "$i"
|
||||||
|
[[ "$i" =~ "DECRYPTION_OKAY" ]] && { ret=0 }
|
||||||
|
done
|
||||||
}
|
|
||||||
return $ret
|
return $ret
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user