Thunderbird, Enigmail, and GnuPG 2 on Sun Solaris 10

This mini-HowTo explains how to use Thunderbird and the Enigmail extension with GnuPG 2.

When using GnuPG 2, Enigmail wants to communicate with GnuPG over the gpg-agent. The trouble is, if the gpg-agent does not run prior launching Thunderbird, Enigmail reports an error like that

[Enigmail error if gpg-agent is not running]

Therefore, you need to start the gpg-agent together with your X session. If you're running GDM as your login manager, you could put something like the script snippet shown below in your .xprofile file which has to be located in your home directory:

GPGAGENT=/opt/guengel/bin/gpg-agent
GPGPINENTRY=/opt/guengel/bin/pinentry-gtk-2
GPG_ENV_FILE="$HOME/.gnupg/gpg-agent-info"
echo "Starting up $GPGAGENT (on display $DISPLAY) ..."

echo $DISPLAY | /usr/bin/egrep -s '\.[0-9]+$'
if [ $? -eq 0 ] ; then
	mydisplay=$DISPLAY
else
	mydisplay="$DISPLAY".0
fi

GPGAGENTARGS="--sh --write-env-file $GPG_ENV_FILE --pinentry-program $GPGPINENTRY --display $mydisplay --daemon"
echo "\tUsing CMDARGS for gpg-agent: $GPGAGENTARGS"

if test -f "$GPG_ENV_FILE" && kill -0 `cut -d: -f 2 "$GPG_ENV_FILE"` 2>/dev/null; then
	echo "\tAlready running instance of gpg-agent found."
	echo "\tKilling running instance"
	kill -TERM `cut -d: -f 2 "$GPG_ENV_FILE"` 2>/dev/null
	if [ $? -ne 0 ] ; then
	    echo "\tError killing gpg-agent"
	else
	    echo "\tLaunch new instance of gpg-agent."
	    echo "\tInfo file is located in $GPG_ENV_FILE"
	    eval `$GPGAGENT $GPGAGENTARGS`
	fi
else
	echo "\tLaunch new instance of gpg-agent."
	echo "\tInfo file is located in $GPG_ENV_FILE"
	eval `$GPGAGENT $GPGAGENTARGS`
fi
echo "... Done"

GDM (more precisely its Xsession script) will then load the gpg-agent upon login.

This script snippet will start the gpg-agent. If you logout of your session, and re-login, the script will restart the agent. This is necessary for bringing up the pinentry window.

You can check the output of the script in the .xsession-errors which is also located in your home directory.

With this script-snippet in your .xprofile, you should be able to use Thunderbird, Enigmail and GnuPG 2 smoothly together.

$Id: tbenigmailgnupg.shtml 2665 2009-08-12 18:23:17Z rafi $