commit 6a62d2af937583707366325489f91fd9115abe6d Author: Arkadiusz MiĆkiewicz <ar...@maven.pl> Date: Mon Aug 1 17:18:51 2016 +0200
rel 2; 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/35b4bfec3cde3f52fcdc76c1f6514ed449314cc2 _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit