24.06.2009 14:00

Notes on Alpine and GnuPG

In my previous article on Alpine I mentioned the Pine Privacy Guard as one solution for adding GPG support to Alpine. Well the problem with that and other filters is that they all do inline signing and encryption of messages. Due to a limitation in Alpine you can't work with MIME RFC2015/3156 multipart/signed and multipart/encrypted messages. The rest of the MUA world is keeping up with the standards, and many mailers won't even validate your messages with inline signatures. At the same time you are unable to validate their own.

Fortunately there is a filter for Alpine which adds MIME support. Topal requires some modification of the Alpine code in order to send and receive multipart e-mail, but it's well worth it. The setup however is not easy and I decided to note a few things.

To start with topal, if it's not packaged for your distribution you can download the sources and build it your self (you will need the gcc-gnat Ada compiler). In Arch Linux the topal package is in AUR. Next you should rebuild your Alpine package applying both patches provided by topal.

When both are installed, generate the topal config file first:

$ topal -default > ~/.topal/config
Then edit "~/.pinerc" and enable topal support, relevant parts shown here:
# List of features; see Pine's Setup/options menu for the current set.
# e.g. feature-list= select-without-confirm, signature-at-bottom
# Default condition for all of the features is no-.
#	...,
#	...,

# This variable takes a list of programs that message text is piped into
# after MIME decoding, prior to display.
display-filters=_BEGINNING("-----BEGIN PGP ")_ /usr/bin/topal -display _TMPFILE_ _RESULTFILE_

# This defines a program that message text is piped into before MIME
# encoding, prior to sending
sending-filters=/usr/bin/topal -send _TMPFILE_ _RESULTFILE_ _RECIPIENTS_,
	/usr/bin/topal -sendmime _TMPFILE_ _RESULTFILE_ _MIMETYPE_ _RECIPIENTS_
Edit "~/.mailcap" next:
# cat (default) should not be used, e-mail text would just scroll by
text/plain; less '%s'; copiousoutput
# Topal GPG integration for Alpine
multipart/signed; topal -mime '%s' '%t'; needsterminal
multipart/encrypted; topal -mime '%s' '%t'; needsterminal
application/pgp; topal -mimeapgp '%s' '%t'; needsterminal
You will need several extra utilities (check your config file). Some like metamail are available in just about any distribution but there are a few that were not easy to track down. To start with MIME-tool, a modified copy is distributed along with topal. You will also need dos2unix from the unixdos-tools, but the hd2u implementation could work as well. In case you need run-mailcap and mime-construct, grab those from Debian mime-support and mime-construct packages.

This covers the setup, how to actually use topal from within Alpine is well explained in "Topal Usage" section of the README. If you are interested in some tips from my own practical experience with topal read my notes on alpine and topal.

Written by anrxc | Permalink | Filed under crypto, desktop, work