It took me a little while, but I finally wrote a few scripts to help me
encode w/o using MIME (for those broken windows clients). What was bothering
me was having to enter the message destination twice; one for mutt's header,
and another time for PGP. My script reads the To: (etc.) header and passes
the e-mail addresses to PGP. That way, PGP only asks for my private key
password to sign -- that's it...

Here's the jist of it...

In my .muttrc:

set editor="mutt-vim"

macro compose X "pf:set editor=\"mutt-vim -feast\"\nE:set
editor=\"mutt-vim\"\ny^T^Uapplication/pgp; format=text; x-action=encrypt\n"
"PGP Encrypt Message w/o MIME"

macro compose S "pfFpgp -fast\ny^T^Uapplication/pgp; format=text;
x-action=sign\n" "PGP Sign Message w/o MIME"

(each paragraph above is each one line)

Attached is the "mutt-vim" script and "pgp-feast-filter" it uses. They work,
but I'm sure someone could optimize the code. :-)

Later!
js.
-- 
Jean-Sebastien Morisset, Sr. UNIX Administrator
up2 technologies inc.
[EMAIL PROTECTED], www.up2me.com
#!/bin/sh

clear

TMPFILE="/tmp/`basename $0`.$$"

# Parse command line parameters:
# EXEC_PARM variable accumulates unrecognized parameters
# which can be passed-on to an executable.
#    
ORIGINAL_ARG="$*"
while : 
do 
    for ARG in $*
    do
        case $ARG in 
            -feast)     FILTER="yes"; shift ;;
            *)  EXEC_PARM="$EXEC_PARM $1" ; shift ;;
        esac
        continue 2
    done
    break
done


if [ "$FILTER" = "yes" ]
then
        for FILE in $EXEC_PARM
        do
                if [ -r $FILE ]
                then
                        cat $FILE | pgp-feast-filter >$TMPFILE
                        [ $? ] && mv $TMPFILE $FILE
                fi
        done
else
        vim "+set nonu" "+set wm=4" "+set ai" "+set ts=8" $EXEC_PARM
fi

#!/usr/local/bin/perl

#
# PGP filter which encrypts a message. The message headers are 
# parsed to find the recipients.
#

$tmpfile = "/tmp/pgp-feast-filter.tmp-$$";
$msgfile = "/tmp/pgp-feast-filter.msg-$$";

if (open (F, "> $tmpfile") && open (M, "> $msgfile")) {
        $inhdr = "yes";
        while (<>) {
                $hdr = $_;
                if ($inhdr eq "yes") {
                        print M $hdr;
                        chop ($hdr);
                        if (! $hdr) { $inhdr = "no"; }
                        if ($hdr !~ /^\s/) { $cont = 0; }
                        if ($hdr =~ /^(From|To|Cc|Bcc): / || $cont) {
                                $cont++;
                                $hdr =~ s/^(From|To|Cc|Bcc|\s):*\s*//g;
                                @addr = split (/,/, $hdr);
                                foreach (@addr) {
                                        $_ =~ s/^.*<//g;
                                        $_ =~ s/>.*$//g;
                                        $dest = $dest . " " . $_;
                                }
                        }
                } else {
                        print F $hdr;
                }
        }
        close (F);
        close (M);
        system ("cat $tmpfile | pgp -feast $dest >>$msgfile");
        if (open (M, "$msgfile")) {
                while (<M>) { print $_; }
                close (M);
        }
        system ("rm -f $tmpfile $msgfile >/dev/null 2>&1");
}

PGP signature

Reply via email to