Using GnuPG 1.06 with pine 4.33 on Red Hat 7.2

Anthony E. Greene agreene@pobox.com
Fri Nov 23 02:43:01 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

After running into a series of problems trying to run pgp4pine on my newly 
installed RH72 system, I decided to write the pine filters myself. I also 
needed to write a perl script to function as the display filter because 
gpg outputs to both STDOUT and STERR. I needed both to be displayed as 
STDOUT and shell redirection would not work.

Here's my solution. It assumes my perl script is named
/usr/local/bin/mydecrypt and that /usr/local/bin/gpge is a symlink to gpg. 
This allows me to specify separate filters for clearsigning and 
encrypt/sign. Pine uses the name of the program as the name of the filter, 
so if you specify the same program with different arguments, you would not 
be able to tell the difference when selecting a send filter from within 
pine. Both would be shown as:  Send message (filtered thru "gpg")?

So I created a symlink: ln -s /usr/bin/gpg /usr/local/bin/gpge

I don't think this will encrypt to multiple recipients, but that is rare
for me anyway, so this solution is satisfactory. Comments are welcome.

 --Tony


Changes to ~/.pinerc:
=====================
display-filters=_LEADING("-----BEGIN PGP")_ /usr/local/bin/mydecrypt

sending-filters=/usr/bin/gpg --clearsign,
       /usr/local/bin/gpge --encrypt --sign --armor -r _RECIPIENTS_



The Perl Script "mydecrypt"
===========================
#!/usr/bin/perl
#
# Decrypt/verify a message on STDIN and write the decrypted text
# and status messages to STDOUT.
#
# Anthony E. Greene <agreene@pobox.com>
#


# Get the date for inclusion in the status messsage.
$currdate = `date`;
chomp($currdate);


# Get the scriptname for use in the status message and to use
# in generating names for the temp files.
$scriptname = `basename $0`;
chomp($scriptname);


# Generate names for the temp files.
$msgfile = $ENV{"HOME"} . "/$scriptname.msg.$$";
$errfile = $ENV{"HOME"} . "/$scriptname.err.$$";


# Send the data from STDIN thorugh GnuPG for processing.
# STDOUT (file descriptor 1) contains the message text.
# STDERR (file descriptor 2) contains the gpg result messages.
# Each is redirected to it's own tempfile.
open(GPG,"| gpg --decrypt 1>$msgfile 2>$errfile");
while ($line = <STDIN>) {
  print GPG "$line";
}
close(GPG);


# Output the message text and delete the message file.
open(MSG,$msgfile);
while ($line = <MSG>) {
  print "$line";
}
close(MSG);
unlink($msgfile);


# Output a line to separate the message from the gpg results.
print "\n\n***** Processed by $scriptname on $currdate *****\n";


# Output the gpg results and delete the results file.
open(ERR,$errfile);
while ($line = <ERR>) {
  print "$line";
}
close(ERR);
unlink($errfile);

exit;




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Anthony E. Greene <agreene@pobox.com> 0x6C94239D

iD8DBQE7/aiZpCpg3WyUI50RAloiAJ0S7SuDqeLYCbjk2ZHtixhLhWRARwCg0gNY
+uBT5yOFyAaEHI8AYxBO2c0=
=PGci
-----END PGP SIGNATURE-----