From owner-freebsd-questions Fri Sep 8 09:52:21 1995 Return-Path: questions-owner Received: (from majordom@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id JAA17417 for questions-outgoing; Fri, 8 Sep 1995 09:52:21 -0700 Received: from everest (dtr.rain.com [204.119.8.19]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id JAA17411 for ; Fri, 8 Sep 1995 09:52:18 -0700 From: bmk@dtr.com Received: from rainier (rainier.dtr.com [204.119.48.36]) by everest (8.6.11/8.6.9) with ESMTP id JAA09316; Fri, 8 Sep 1995 09:45:14 -0700 Received: (from bmk@localhost) by rainier (8.6.11/8.6.9) id JAA00338; Fri, 8 Sep 1995 09:49:39 -0700 Message-Id: <199509081649.JAA00338@rainier> Subject: Re: PGP aware mailer ? To: mcw@hpato.aus.hp.com (M C Wong) Date: Fri, 8 Sep 1995 09:49:39 -0700 (PDT) Cc: questions@freebsd.org In-Reply-To: <199509080533.AA029138409@hp.com> from "M C Wong" at Sep 8, 95 03:33:27 pm Reply-To: bmk@dtr.com X-Mailer: ELM [version 2.4 PL24] Content-Type: text Content-Length: 4023 Sender: questions-owner@freebsd.org Precedence: bulk -----BEGIN PGP SIGNED MESSAGE----- > How about does there exist any editor which can support pgp > stuff ? In which case, I was hoping that I can just change the > editor in elm instead of installing a new version of elm or > different mailer. Write a shell script wrapper that does this. PGP includes example scripts - I used the morepgp and mailpgp scripts to do exactly what you're looking for. - --- morepgp #!/usr/bin/perl # written by jason steiner, jsteiner@anwsun.phya.utoledo.edu, Jan 1993 # # if you use or make improvements to this program i would appreciate # copies of your modifications & your PGP public key. $|=1; $topgp=0; $logname = $ENV{'LOGNAME'}; $pager='/usr/local/bin/less -i -n -s -S -c -M'; $pager = $ENV{'PAGER'} if ($ENV{'PAGER'}); umask 077; open (PAGER, "|$pager") || die "Cannot open pipe to $pager.\n"; print PAGER "\n"; while (<>) { if (!$topgp && m/^-----BEGIN PGP .*-----/) { $topgp = 1; $tmpfile = "/tmp/.pgp.$logname.$$"; unlink($tmpfile); open (TMPFILE, ">$tmpfile") || die "Cannot open $tmpfile for output.\n"; } if (!$topgp) { print PAGER; } else { print TMPFILE $_; if (m/^-----END PGP .*-----/) { $topgp = 0; close TMPFILE; open (CLEAR, "pgp -f < $tmpfile |") || die "Cannot open pipe to PGP.\n"; print PAGER "-----BEGIN PGP DECRYPTED BLOCK-----\n"; while () { print PAGER; } close CLEAR; unlink($tmpfile); print PAGER "-----END PGP DECRYPTED BLOCK-----\n"; } } } close PAGER; - --- mailpgp #!/usr/bin/perl ($visual = $ENV{'VISUAL'}) || ($visual = '/usr/bin/vi'); $topgp = 0; $blanks = 0; $paragraphs = 1; $blankcompress = 1; $name=@ARGV[$#ARGV]; umask (077); open (INPUT, "<$name"); open (OUTPUT, ">${name}.rply") || die "Cannot open ${name}.rply for output.\n"; while () { if (!$topgp && !m/^> -----BEGIN PGP .*-----/) { if (m/^> *$/) { if ($paragraphs) { if ($blankcompress) { if ($blanks == 0) { print OUTPUT "\n"; $blanks = 1; } } else { print OUTPUT "\n"; } } else { print OUTPUT; } } elsif (m/^ *$/) { if ($blankcompress) { if ($blanks == 0) { print OUTPUT "\n"; $blanks = 1; } } else { print OUTPUT; } } else { print OUTPUT; if ($. == 1 && !m/^> /) { print OUTPUT "\n"; $blanks = 1; } else { $blanks = 0; } } } if (!$topgp && m/^> -----BEGIN PGP .*-----/) { $topgp = 1; $tmpfile = "${name}.pgp", unlink ($tmpfile); open (TMPFILE, ">$tmpfile") || die "Cannot open $tmpfile for output.\n"; } if ($topgp) { $_ =~ s/^> //; print TMPFILE $_; if (m/^-----END PGP .*-----/) { $topgp = 0; close TMPFILE; $clrfile = "${name}.clr"; `pgp $tmpfile -o $clrfile`; open (CLEAR, "<$clrfile") || die "Cannot open $clrfile for input.\n"; print OUTPUT "-----BEGIN OF PGP DECRYPTED TEXT-----\n\n"; while () { if (m/^$/) { print OUTPUT "\n"; } else { print OUTPUT "> "; print OUTPUT; } } close CLEAR; unlink ($clrfile); unlink ($tmpfile); print OUTPUT "\n-----END OF PGP DECRYPTED TEXT-----\n\n"; } } } close OUTPUT; close INPUT; unlink ($name); rename ("${name}.rply", "$name"); system ($visual,@ARGV); while (!$q) { print "Sign this message? [Y]: "; $q = ; $q =~ s/[ \t\n]//g; $q = substr ($q, 0, 1); if (($q eq 'Y') || ($q eq 'y') || ($q eq '')) { push(@opts,'-st','+clearsig=on'); $q = "y"; } elsif (($q ne 'N') && ($q ne 'n')) { $q = ''; } } $q=''; while (!$q) { print "Encrypt this message? [N]: "; $q = ; $q =~ s/[ \t\n]//g; $q = substr ($q, 0, 1); if (($q eq 'Y') || ($q eq 'y')) { push(@opts,'-e'); $q = "y"; } elsif (($q ne 'N') && ($q ne 'n')) { $q = 'n'; } } if (@opts) { system ('pgp','-a',@opts,$name); if ($? == 0) { unlink ${name}; rename ("${name}.asc", "$name"); } } -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQBFAwUBMFB0F2ADWC0MDkc5AQF/hwGAgc8Beooqgb4PO8BwPkYKq9wiS39xOxOl AJzTYs8PWLdnkmfXVqLKwsvzDXfoggjp =CgXZ -----END PGP SIGNATURE-----