commit 131032f063eb5da404ab75ac9f0e68d6fbdf60e0
Author: Arkadiusz MiĆkiewicz <[email protected]>
Date: Mon Aug 1 17:17:07 2016 +0200
Check if /proc/pid/exe is symlink to /usr/bin/gpg-agent. That way we are
100% sure that this is gpg-agent. Prevents script from failing if there is
other process running with the same pid as stored in .gnupg/GPG_AGENT_INFO.
gnupg-agent.sh | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/gnupg-agent.sh b/gnupg-agent.sh
index 1b3fa5a..68ec6f4 100644
--- a/gnupg-agent.sh
+++ b/gnupg-agent.sh
@@ -1,28 +1,30 @@
#!/bin/sh
if [ -r "${HOME}/.gnupg/gpg.conf" ]; then
- CFG="${HOME}/.gnupg/gpg.conf"
+ CFG="${HOME}/.gnupg/gpg.conf"
else
- CFG="${HOME}/.gnupg/options"
+ CFG="${HOME}/.gnupg/options"
fi
seahorse=no
if [ -r "${HOME}/.gnupg/gpg-agent.conf" ]; then
- grep -qE "^[[:blank:]]*pinentry-program[[:blank:]]*.*seahorse-agent"
"${HOME}/.gnupg/gpg-agent.conf" && seahorse=yes
+ grep -qE "^[[:blank:]]*pinentry-program[[:blank:]]*.*seahorse-agent"
"${HOME}/.gnupg/gpg-agent.conf" && seahorse=yes
fi
if grep -q "^[[:blank:]]*use-agent" ${CFG} 2>/dev/null; then
- if [ -f "${HOME}/.gnupg/GPG_AGENT_INFO" ] && pid="$(cut -d: -f2
$HOME/.gnupg/GPG_AGENT_INFO)" && [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null;
then
- export GPG_AGENT_INFO="$(cat ${HOME}/.gnupg/GPG_AGENT_INFO)"
- else
- if [ "$seahorse" = "no" ]; then
- eval "$(gpg-agent --daemon)"
+ if [ -f "${HOME}/.gnupg/GPG_AGENT_INFO" ] && \
+ pid="$(cut -d: -f2 $HOME/.gnupg/GPG_AGENT_INFO)" && \
+ [ "$(resolvesymlink "/proc/$pid/exe")" =
"/usr/bin/gpg-agent" ]; then
+ export GPG_AGENT_INFO="$(cat ${HOME}/.gnupg/GPG_AGENT_INFO)"
else
- eval "$(seahorse-agent --variables)"
+ if [ "$seahorse" = "no" ]; then
+ eval "$(gpg-agent --daemon)"
+ else
+ eval "$(seahorse-agent --variables)"
+ fi
+ echo $GPG_AGENT_INFO > ~/.gnupg/GPG_AGENT_INFO
+ export GPG_AGENT_INFO
fi
- echo $GPG_AGENT_INFO > ~/.gnupg/GPG_AGENT_INFO
- export GPG_AGENT_INFO
- fi
fi
unset CFG
unset pid
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/gnupg2.git/commitdiff/131032f063eb5da404ab75ac9f0e68d6fbdf60e0
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit