Samples
Pine Output Filter
I use this script as my default output filter in Pine 3.95. The
list of recipients is placed as arguments (the $@, bash syntax) and
the message body is on stdin. This checks that if there are some
recipients (there aren't, generally, in newsgroup posts for example)
that you have a public key for each of them, and if so encrypts and
signs the message to stdout. Otherwise, it clearsigns the message to
stdout.
#!/bin/sh
TMP=/tmp/pine_humbugf.$LOGNAME.$$.tmp
umask 077
cat - >$TMP
COMMAND=encrypt
LOOP=no
for TO in "$@"; do
if pgp -kv 2>/dev/null | grep "$TO" >/dev/null 2>&1; then
LOOP=yes
true;
else
COMMAND=sign
fi
done
cat $TMP | (
if [ $COMMAND = encrypt ] && [ $LOOP = yes ]; then
pgpencrypt "$@" "aj@humbug.org.au"
else
pgpsign
fi
)
rm $TMP
Pine Input Filter
This is my input filter. It checks for encrypted sections, and if
it finds any pipes it through pgppipe, and also checks any signatures
that happen to be in the file.
#!/bin/sh
TEMP="/tmp/pgp_filter.$LOGNAME.$$.tmp"
umask 077
cat > $TEMP
if grep >/dev/null 2>&1 "^-----BEGIN PGP MESSAGE-----" $TEMP; then
pgppipe < $TEMP > $TEMP.2
mv $TEMP.2 $TEMP
fi
if grep >/dev/null 2>&1 "^-----BEGIN PGP SIGNATURE-----" $TEMP; then
(
echo -----BEGIN PGP SIGNATURE CHECK-----
cat $TEMP | pgp -f +batchmode 2>&1 >/dev/null | tr -d "\a"
echo -----END PGP SIGNATURE CHECK-----
) | cat $TEMP - | tr -d "\a" > $TEMP.2
mv $TEMP.2 $TEMP
fi
cat $TEMP