Subject: Re: PGP in Pine?

From: [email-masked] (Rick Troxel)
Date: 14 Nov 1996 18:02:47 GMT

In article <[email-masked]> [email-masked] (Zarina Musa)
writes:

	   I'm searching for pine which has support for PGP. Read
   somewhere that version 3.92 can ... does the latest version(3.95)
   also support PGP?

Yes, and better (if I recall) than version 3.92, through the
display-filters and sending-filters options.  For instance, I use

display-filters=_LEADING("-----BEGIN PGP SIGNED MESSAGE-----")_ /path/to/slowpgp,
	_LEADING("-----BEGIN PGP MESSAGE-----")_ /path/to/slowpgp
sending-filters=/path/to/pgp -fast,
	/path/to/pgp -feast _RECIPIENTS_

where the slowpgp script is as follows.

#!/usr/local/bin/perl
#
# filter for pine 3.93 and newer for decoding pgp mails
# use this with the following in your .pinerc:
# display-filters=_BEGINNING("-----BEGIN PGP")_ /home/roland/bin/pgpdecode
#
# $Id: pgpdecode,v 1.3 1996/05/17 11:47:30 roland Exp $
#
# 21.03.96 Roland Rosenfeld <[email-masked]> 
# 23.03.96 $TMPFILE moved to $PGPPATH.
# 17.05.96 total rewrite in perl; many new features

umask 077;

$pgpout = "/home/rick/.pgp/pgp.tmp.stdout$$";
$pgperr = "/home/rick/.pgp/pgp.tmp.stderr$$";

$pgpfound=1;

while ($pgpfound) {

    while (($_=<>) && !(/^-----BEGIN PGP/)) {
	print $_;
    }
    if (/^-----BEGIN PGP/) {
	$pgpfound=1;
    } else {
	$pgpfound=0;
    }
    
    if (/^-----BEGIN PGP PUBLIC KEY BLOCK-----$/) {
	$pgpkeyblock .= $_;
	while (($_=<>) && !(/^-----END PGP PUBLIC KEY BLOCK-----$/)) {
	    $pgpkeyblock .= $_;
	}
	$pgpkeyblock .= $_;
	
	open(SAVEOUT, ">&STDOUT");
	open(SAVEERR, ">&STDERR");
	open(STDOUT, ">$pgpout") || &abort("Can't redirect stdout");
	open(STDERR, ">&STDOUT") || &abort("Can't redirect stderr");
	open(PGP, "|pgp -kaf") || &abort("Can't execute pgp");
	print PGP $pgpkeyblock;
	close(PGP);
	close(STDOUT);
	close(STDERR);
	open(STDOUT, ">&SAVEOUT");
	open(STDERR, ">&SAVEERR");
	
	open(PGPOUT, "<$pgpout") || &abort("Can't read $pgpout");
	while (<PGPOUT>) {
	    print "| $_";
	}
	close(PGPOUT);
	unlink $pgpout;
    } elsif (/^-----BEGIN PGP( SIGNED)? MESSAGE-----$/) {
	$pgpmessage .= $_;
	$pgpheader = $_;

	while (($_=<>) && !(/^-----END PGP (MESSAGE|SIGNATURE)-----$/)) {
	    $pgpmessage .= $_;
	}
	$pgpmessage .= $_;
	
	open(SAVEOUT, ">&STDOUT");
	open(SAVEERR, ">&STDERR");
	open(STDOUT, ">$pgpout") || &abort("Can't redirect stdout");
	open(STDERR, "| tee $pgperr 1>&2") || &abort("Can't redirect stderr");
	open(PGP, "|pgp -f") || &abort("Can't execute pgp");
	print PGP $pgpmessage;
	close(PGP);
	close(STDOUT);
	close(STDERR);
	open(STDOUT, ">&SAVEOUT");
	open(STDERR, ">&SAVEERR");
	
	open(PGPERR, "<$pgperr") || &abort("Can't read $pgperr");
	print "| ";
	while (<PGPERR>) {
	    print "$_|";
	}
	close(PGPERR);
	unlink $pgperr;

	print "\n| $pgpheader\n";

	open(PGPOUT, "<$pgpout") || &abort("Can't read $pgpout");
	while (<PGPOUT>) {
	    print $_;
	}
	close(PGPOUT);
	unlink $pgpout;
	
	$pgpheader =~ s/BEGIN/END/;
	print "\n| $pgpheader\n";
    }
}

exit;

sub abort {
    local ($message) = @_;
    unlink $pgpout;
    unlink $pgperr;
    die $message;
}

# Local variables:
# mode:Perl
# End:

Hope it helps,
--
   Rick Troxel     [email-masked]     [email-masked]
     http://www.dc-sage.org/bios/rick_troxel  301/435-2983
/////////////////////////////////////////////////////////////////
All effort and exertion put forth by man from the fullness of his
heart is worship, if it  is prompted  by the  highest motives and
the will to do service to humanity.                 --Abdu'l-Baha