procmail + GnuPG decrypt

procmail + GnuPG decrypt

am 25.06.2007 10:13:49 von Joolz

Hi everyone,

I'm new on this group but I'm working with gpg and Linux in general
for years. Right now I'm working on a problem and it makes me feel
like I'm reinventing the wheel. A linux mailserver (Debian stable,
postfix, procmail, gpg) receives mail from a customer of ours with GPG
encrypted attachments. Before the mail is forwarded to another (Lotus
Domino) server, the attachments should be decrypted because Domino
only understands it's own encryption.

So what I need is a procmail recipe that will detach any .asc
attachments, decrypt them, attach the decrypted files and send the
mail. Does anyone have a link or solution? I've come up with this
(working) bash script for the decryption part but now I'm stranded
with procmail and Google isn't my friend :)

Thanks!

#!/bin/bash
BASE='/home/me/decrypt_test'
SOURCEDIR=$BASE/sourcedir
TARGETDIR=$BASE/targetdir
GPGDIR=$BASE/gpgdata
pushd $SOURCEDIR
for i in ls *.csv.asc
do
RESULT=${i%.asc}
gpg --homedir $GPGDIR --passphrase-fd 3 \
-o $TARGETDIR/$RESULT -d $i \
3< $GPGDIR/password.txt
done
popd