[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Mutt and inline gpg



Hi Marc,

* Marc Leeman <Marc.Leeman@esat.kuleuven.ac.be> [09-08-01 11:55]:

> Due to the flexibility of mutt, I would guess that I can solve the 
> problem in my config, but as I said, I haven't found a solution quite
> yet.

I use the following procmail rules and a little script (attached)
to convert the content-type of attachments to application/pgp:

----
:0
* !^Content-Type: message/
* !^Content-Type: multipart/
* !^Content-Type: application/pgp
{
  :0 fBw
  * ^-----BEGIN PGP MESSAGE-----
  * ^-----END PGP MESSAGE-----
  | formail -i "Content-Type: application/pgp; format=text; x-action=encrypt"

  :0 fBw
  *  ^-----BEGIN PGP SIGNED MESSAGE-----
  *  ^-----BEGIN PGP SIGNATURE-----
  *  ^-----END PGP SIGNATURE-----
  | formail -i "Content-Type: application/pgp; format=text; x-action=sign"
}

:0 fBw
* ^-----BEGIN PGP PUBLIC KEY BLOCK-----
* ^-----END PGP PUBLIC KEY BLOCK-----
| formail -i "Content-Type: application/pgp-keys; format=text;"

:0
* ^Content-Type: multipart/
{
  :0 fBw
  * ^-----BEGIN PGP MESSAGE-----
  * ^-----END PGP MESSAGE-----
  | $MAILFILTER_PGP_ATTACHMENT -
}
----

If you want textmode-encryption for some people use this macro and
press 'xfoo' before you send the message:

macro compose xfoo "Fgpg -es --textmode --armor -r $your-key-ID -r $recipient-key-ID\ny"

Janto

-- 
"Open Source" heißt, jeder Anwender erhält eine Kopie des
Quellcodes. Dabei stoßen Entwickler, die mit Linux arbeiten,
häufig auf Sicherheitslücken. Auf Microsoft Windows trifft dies
nicht zu.        - Microsoft
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
       if 0;

($script = $0) =~ s#.*/(.*)$#$1#;
$USAGE = "
# Usage: $script mail
#
# Task: This script converts the Content-Type of attachments to
#       application/pgp ...
#       if the attachment is pgp encrypted.
#       The output will be the stdout.
#
# Version : 1.0
# Author: Daniel.Kollar\@bigfoot.de
#
";
$user=`whoami`;
$date=`date`;

die "$USAGE" if @ARGV == 0;

$header = 1;

while (<>) {
  $line = $_;

  if ( $header && $line =~ /^[\s\t]*$/ ) {
    $header = 0;
    print "$line";
    next;
  }

  if ( $header == 1 ) {   # skip header
    print "$line";
    next;
  }

  if ( !$header && $line =~ /^------.*/ ) {
    print "$line";
    $aheader = 1;
    @lines1 = ();
    $content_type = "";
    @lines = ();
    while (<>) {
      $line = $_;

      if ( $aheader && $line =~ /^Content-Type:.*/) {   # save Content-Type separately
        @lines1 = @lines;
        $content_type = $line;
        @lines = ();
        next;
      }

      if ( $aheader && $line =~ /^[\s\t]*$/ ) {   # look for header of attachment
        $aheader = 0;
        push(@lines, $line);
        next;
      }

      if ( $aheader == 1 ) {
        push(@lines, $line);
        next;
      }

      if ( !$aheader && $line =~ /^-----BEGIN PGP MESSAGE-----.*/ ) {   # attachment pgp encrypted
        $content_type = "Old-${content_type}Content-Type: application/pgp; format=text; x-action=encrypt\n";
        push (@lines, $line);
        next;
      }

      if ( !$aheader && $line =~ /^------.*/ ) {   # next attachment begins
        print join '',@lines1;
        print "$content_type";
        print join '',@lines;
        print "$line";
        $aheader = 1;
        @lines1 = ();
        $content_type = "";
        @lines = ();
        next;
      }

      push(@lines, $line);
    }
    print join '',@lines1;
    print "$content_type";
    print join '',@lines;

    last;
  }

  print "$line";

}

Attachment: pgpya34PyXuyP.pgp
Description: PGP signature


Reply to: