]> git.pld-linux.org Git - packages/gnupg2.git/blame - gnupg-agent.sh
Check if /proc/pid/exe is symlink to /usr/bin/gpg-agent. That way we are 100% sure...
[packages/gnupg2.git] / gnupg-agent.sh
CommitLineData
37037e90
AM
1#!/bin/sh
2
3if [ -r "${HOME}/.gnupg/gpg.conf" ]; then
131032f0 4 CFG="${HOME}/.gnupg/gpg.conf"
37037e90 5else
131032f0 6 CFG="${HOME}/.gnupg/options"
37037e90
AM
7fi
8
e94dfe96 9seahorse=no
37037e90 10if [ -r "${HOME}/.gnupg/gpg-agent.conf" ]; then
131032f0 11 grep -qE "^[[:blank:]]*pinentry-program[[:blank:]]*.*seahorse-agent" "${HOME}/.gnupg/gpg-agent.conf" && seahorse=yes
37037e90
AM
12fi
13
8753b7ed 14if grep -q "^[[:blank:]]*use-agent" ${CFG} 2>/dev/null; then
131032f0
AM
15 if [ -f "${HOME}/.gnupg/GPG_AGENT_INFO" ] && \
16 pid="$(cut -d: -f2 $HOME/.gnupg/GPG_AGENT_INFO)" && \
17 [ "$(resolvesymlink "/proc/$pid/exe")" = "/usr/bin/gpg-agent" ]; then
18 export GPG_AGENT_INFO="$(cat ${HOME}/.gnupg/GPG_AGENT_INFO)"
9594d542 19 else
131032f0
AM
20 if [ "$seahorse" = "no" ]; then
21 eval "$(gpg-agent --daemon)"
22 else
23 eval "$(seahorse-agent --variables)"
24 fi
25 echo $GPG_AGENT_INFO > ~/.gnupg/GPG_AGENT_INFO
26 export GPG_AGENT_INFO
37037e90 27 fi
37037e90 28fi
63d7337b 29unset CFG
30unset pid
This page took 0.057695 seconds and 4 git commands to generate.