Subject: PGP: new and improved version of pgpdecode

From: [email-masked] (Roland Rosenfeld)
Date: 17 May 1996 13:56:38 +0200

Here is the new and improved version of my pine-input-filter
pgpdecode.

This new version supports 
- PGP PUBLIC KEY BLOCKs
- multiple PGP BLOCKs in one message
- unsigned and unencrypted text outside the PGP BLOCKs

It does not yet support nested PGP BLOCKS (does someone need this?).

Here it is:

-------------------------- pgpdecode -------------------------------
#!/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 = "/tmp/pgpout$$";
$pgperr = "/tmp/pgperr$$";

$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");
        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|\n| $pgpheader|\n\n";
    }
}

exit;

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

Any comments are welcome!

Ciao

        Roland

-- 
  * Internet: [email-masked] * Fido: 2:2450/30.1 *

---

From: Andrej Borsenkow <[email-masked]>
Date: Tue, 21 May 1996 15:38:11 +0400 (MOW)

Hi!

Little problem with pgpdecode and Pine 3.93.

I tried to setup the pgpdecode (I used mkpgp before) and it works really
fine. Only one comment.

If I reply to a PGP message and decide to include original message, text
is passed through display filter (in this case pgpdecode) and thus the
included text contains output of filter together with original message. I
find it at least strange.

Is it a problem of filter or Pine? The culprit seems to be the Pine - why
display filter is called when R)eplying to message at all?

thanks in advance

-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: [email-masked]
-------------------------------------------------------------------------

---

From: [email-masked] (Greg Sullivan)
Date: 23 May 1996 20:46:01 GMT

On Thu, 23 May 1996 10:16:45 -0400, "Steven P. Crain" <[email-masked]> wrote:
>On 17 May 1996, Roland Rosenfeld wrote:
>Just a tiny little point.  With something that is sent with PGP, you
>probably don't want temp files in /tmp.  Even though they aren't going to
>be readable.  I made a similar script (I like yours better, :-) and put
>the temp files in ${PGPPATH}/.pgp.tmp.stderr.$$, etc.

     Hello.  I seem to have missed the original posting of these scripts 
for intergrating PGP with Pine.  If they could be reposted, it would be 
appreciated.  Thanks.

-- 
________________________________________________________________________

Greg `SULLY' Sullivan | e-mail: [email-masked]
                      |    www: http://www.osha.igs.net/~gsully
________________________________________________________________________

---

From: "Steven P. Crain" <[email-masked]>
Date: Thu, 23 May 1996 10:16:45 -0400

-----BEGIN PGP SIGNED MESSAGE-----

Steven P. Crain		[email-masked]
Unix Administration and Programming
North Shore Access