guessing GPG_AGENT_INFO

Werner Koch wk at gnupg.org
Tue Sep 30 08:44:47 CEST 2008


On Mon, 29 Sep 2008 22:17, nicholas.cole at gmail.com said:

> Is there any way to correctly 'guess' the settings for the
> GPG_AGENT_INFO variable (for the case where gpg-agent has been called
> with --use-standard-socket)?

That is easy.  With --use-standard-socket the socket used is

  ~/.gnupg/S.gpg-agent

unless GNUPGHOME is set in which case it is

  ${GNUPGHOME}/S.gpg-agent

The environment variable you want is thus

  GPG_AGENT_INFO="${GNUPGHOME:-${HOME}/.gnupg}/S.gpg-agent:-1:1"

We do not actually need the PID, thus we set it to -1.  The trraling 1
is the protocol version (not checked, iirc).

If you don't use --use-standard-socket you can try to write a scripts
based on

  netstat -lx | awk '/\/S.gpg-agent$/ { print $8 }'

but you need to figure out whether this is the socket for the desired
user.  Maybe -lxp would be helpful.


Salam-Shalom,

   Werner


-- 
Linux-Kongress 2008 + Hamburg + October 7-10 + www.linux-kongress.org

   Die Gedanken sind frei.  Auschnahme regelt ein Bundeschgesetz.




More information about the Gnupg-users mailing list