Starting gpg-agent from Xsession

Albrecht Dreß albrecht.dress at arcor.de
Sat Jan 22 14:33:25 CET 2005


Am 22.01.05 11:22 schrieb(en) Peter Eisentraut:
> if $SOMEUSERSETTING; then
>   if [ -x /usr/bin/gpg-agent ] && [ -z "$GPG_AGENT_INFO" ]; then
>     eval `gpg-agent --daemon`

I recommend adding

<snip>
echo $GPG_AGENT_INFO > $HOME/.gpg-agent-info
</snip>

here... Now add

<snip>
if [ -z "$GPG_AGENT_INFO" ] ; then
     if [ -f $HOME/.gpg-agent-info ] ; then
         export GPG_AGENT_INFO=$(cat .gpg-agent-info)
     fi
fi
export GPG_TTY=$(tty)
</snip>

to $HOME/.bashrc, so even if the user logs in on a virtual console, the  
agent will be found, and it will automagically use the curses pinentry if  
necessary.

> The problem that I see, however, is that this does not terminate the
> gpg-agent when the X session finishes (unlike ssh-agent).  I've also
> played with a number of other invocation methods such as --server,
> --no-detach, or invoking the window manager as an argument of gpg-agent
> (which is how ssh-agent does it), without success.

I'm using gdm, and I simply added the following to the beginning of the  
file /etc/X11/gdm/PostSession/Default:

<snip>
GPGAGENTINFO="$HOME/.gpg-agent-info"

if [ -f $GPGAGENTINFO ] ; then
     AGENTPID=$(cat $GPGAGENTINFO | sed -e 's/^[^:]*://' -e 's/:.*//')
     if [ -n "$AGENTPID" ] ; then
         kill -TERM $AGENTPID > /dev/null 2>&1
     fi
     rm -f $GPGAGENTINFO
fi
</snip>

Works perfectly for me... I guess you'll have to tweak other files if you  
are using xdm or kdm, though.

Hope this helps,

	Albrecht.


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Albrecht Dreß  -  Johanna-Kirchner-Straße 13  -  D-53123 Bonn (Germany)
        Phone (+49) 228 6199571  -  mailto:albrecht.dress at arcor.de
    GnuPG public key:  http://home.arcor.de/dralbrecht.dress/pubkey.asc
_________________________________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : /pipermail/attachments/20050122/ac83b971/attachment.pgp


More information about the Gnupg-devel mailing list