]> granicus.if.org Git - mutt/commitdiff
- Add a $weed option.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 8 Jun 1999 09:28:16 +0000 (09:28 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 8 Jun 1999 09:28:16 +0000 (09:28 +0000)
- Add out-of-band reporting of signature status.

14 files changed:
Makefile.am
commands.c
compose.c
configure.in
hdrline.c
init.c
init.h
mutt.h
pgp.c
pgpinvoke.c
pgpkey.c
pgplib.h
pgppubring.c
recvattach.c

index 592ae2a13e65bf8ff27001f07e5c2608e9c9a553..dd58ac9b97ce3c3f6dc0910b6621647aad2f5839 100644 (file)
@@ -6,6 +6,12 @@
 AUTOMAKE_OPTIONS = foreign
 EXTRA_PROGRAMS = mutt_dotlock pgpring
 
+if NEEDS_PGPEWRAP
+bin_SCRIPTS = pgpewrap
+else
+bin_SCRIPTS =
+endif
+
 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
 mutt_SOURCES = addrbook.c alias.c attach.c browser.c buffy.c color.c \
        commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
index d0daac87fa615b1b676e05cc2523c9b93eba1f49..86592db23a031c0a16ab7f72376e547060fb9cf1 100644 (file)
@@ -73,7 +73,6 @@ int mutt_display_message (HEADER *cur)
   mutt_parse_mime_message (Context, cur);
 
 
-
 #ifdef _PGPPATH
   /* see if PGP is needed for this message.  if so, we should exit curses */
   if (cur->pgp)
@@ -100,10 +99,6 @@ int mutt_display_message (HEADER *cur)
 
 
 
-
-
-
-
   mutt_mktemp (tempfile);
   if ((fpout = safe_fopen (tempfile, "w")) == NULL)
   {
@@ -135,10 +130,18 @@ int mutt_display_message (HEADER *cur)
     return (0);
   }
 
+#ifdef _PGPPATH
+  /* update PGP information for this message */
+  cur->pgp |= pgp_query (cur->content);
+#endif
+
   if (builtin)
   {
     pager_t info;
-    
+
+    if (cur->pgp & PGPGOODSIGN)
+      mutt_message _("PGP signature successfully verified.");
+
     /* Invoke the builtin pager */
     memset (&info, 0, sizeof (pager_t));
     info.hdr = cur;
index 221f34933d442147e99d004174f4d44f99a4d7d2..43be5b55b57f0538a8d578ba4b42c1804a7d2d92 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -161,7 +161,6 @@ static int pgp_send_menu (int bits, int *redraw)
     else
     {
       bits &= ~PGPSIGN;
-      mutt_error _("An unkown PGP version was defined for signing.");
     }
 
     *redraw = REDRAW_FULL;
index a4a14faa6c031614d60b5a744beb91fb5cd1a7ac..2a4ce27c9a7b7c67994f3372d03afd493fbe7c32 100644 (file)
@@ -72,7 +72,8 @@ else
        fi
 
        if test $PGP != no || test $PGPK != no || test $GPG != no ; then
-               PGPAUX_TARGET="pgpring pgpewrap"
+               PGPAUX_TARGET=pgpring
+               AM_CONDITIONAL(NEEDS_PGPEWRAP, true)
                MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgplib.o gnupgparse.o"
                OPS="$OPS \$(srcdir)/OPS.PGP"
        fi
index 85600e07d8f090df9cf7d6dab967fc10b5a2710f..da202e36b444005e95d4271a73e0e7b9103edbda 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -601,10 +601,12 @@ hdr_format_str (char *dest,
       ch = ' ';
 
 #ifdef _PGPPATH
-      if (hdr->pgp & PGPENCRYPT)
+      if (hdr->pgp & PGPGOODSIGN)
+        ch = 'S';
+      else if (hdr->pgp & PGPENCRYPT)
        ch = 'P';
       else if (hdr->pgp & PGPSIGN)
-        ch = 'S';
+        ch = 's';
       else if (hdr->pgp & PGPKEY)
         ch = 'K';
 #endif
diff --git a/init.c b/init.c
index 3195581c12effaffd381306856b293b3bcd33b74..bcce6aef1f90d7277ba0219053cfd60f1875915c 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1734,5 +1734,7 @@ void mutt_init (int skip_sys_rc, LIST *commands)
       mutt_exit(1);
   }
 
+#if 0
   set_option (OPTWEED); /* turn weeding on by default */
+#endif
 }
diff --git a/init.h b/init.h
index 315948e9563ebd8f205f37b3ceb6217450e3e0ad..caac6b43c8159b8e6016c8ebdec94cf110511b9e 100644 (file)
--- a/init.h
+++ b/init.h
@@ -174,7 +174,7 @@ struct option_t MuttVars[] = {
   { "msg_format",      DT_SYN,  R_NONE, UL "message_format", 0 },
   { "pager",           DT_PATH, R_NONE, UL &Pager, UL "builtin" },
   { "pager_context",   DT_NUM,  R_NONE, UL &PagerContext, 0 },
-  { "pager_format",    DT_STR,  R_PAGER, UL &PagerFmt, UL "-%S- %C/%m: %-20.20n   %s" },
+  { "pager_format",    DT_STR,  R_PAGER, UL &PagerFmt, UL "-%Z- %C/%m: %-20.20n   %s" },
   { "pager_index_lines",DT_NUM,         R_PAGER, UL &PagerIndexLines, 0 },
   { "pager_stop",      DT_BOOL, R_NONE, OPTPAGERSTOP, 0 },
 
@@ -289,6 +289,7 @@ struct option_t MuttVars[] = {
   { "user_agent",      DT_BOOL, R_NONE, OPTXMAILER, 1},
   { "visual",          DT_PATH, R_NONE, UL &Visual, 0 },
   { "wait_key",                DT_BOOL, R_NONE, OPTWAITKEY, 1 },
+  { "weed",            DT_BOOL, R_NONE, OPTWEED, 1 },
   { "wrap_search",     DT_BOOL, R_NONE, OPTWRAPSEARCH, 1 },
   { "write_inc",       DT_NUM,  R_NONE, UL &WriteInc, 10 },
   { "write_bcc",       DT_BOOL, R_NONE, OPTWRITEBCC, 1},
diff --git a/mutt.h b/mutt.h
index 6a7bbd15df8e5ebbd94cc90988e7adb9a31827e8..aba6f15d15a85a2bd5ed1000740a5396ce708c29 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -508,12 +508,17 @@ typedef struct body
   unsigned int tagged : 1;
   unsigned int deleted : 1;    /* attachment marked for deletion */
   unsigned int noconv : 1;     /* don't do character set conversion */
+
+#ifdef _PGPPATH
+  unsigned int goodsig : 1;    /* good PGP signature */
+#endif
+
 } BODY;
 
 typedef struct header
 {
 #ifdef _PGPPATH
-  unsigned int pgp : 3;
+  unsigned int pgp : 4;
 #endif
 
   unsigned int mime : 1;    /* has a Mime-Version header? */
diff --git a/pgp.c b/pgp.c
index df1b15fe9a17c773d23ffd32dac4eb62ccc816f4..dfd7e3c5e7e43c87ba7a70410b99245c1f5d9fb9 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -443,20 +443,24 @@ int pgp_query (BODY *m)
   /* Check for PGP/MIME messages. */
   if (m->type == TYPEMULTIPART)
   {
-    if(mutt_is_multipart_signed(m))
+    if (mutt_is_multipart_signed(m))
       t |= PGPSIGN;
     else if (mutt_is_multipart_encrypted(m))
       t |= PGPENCRYPT;
+
+    if ((mutt_is_multipart_signed (m) || mutt_is_multipart_encrypted (m)) 
+       && m->goodsig)
+      t |= PGPGOODSIGN;
   }
 
-  if(m->type == TYPEMULTIPART || m->type == TYPEMESSAGE)
+  if (m->type == TYPEMULTIPART || m->type == TYPEMESSAGE)
   {
     BODY *p;
  
-    for(p = m->parts; p; p = p->next)
-      t |= pgp_query(p);
+    for (p = m->parts; p; p = p->next)
+      t |= pgp_query(p) & ~PGPGOODSIGN;
   }
-  
+
   return t;
 }
 
@@ -522,6 +526,7 @@ static int pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
   char sigfile[_POSIX_PATH_MAX], pgperrfile[_POSIX_PATH_MAX];
   FILE *fp, *pgpout, *pgperr;
   pid_t thepid;
+  int rv = -1;
   
   snprintf (sigfile, sizeof (sigfile), "%s.asc", tempfile);
   
@@ -556,7 +561,7 @@ static int pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
     mutt_copy_stream(pgperr, s->fpout);
     fclose(pgperr);
     
-    mutt_wait_filter (thepid);
+    rv = mutt_wait_filter (thepid);
   }
   
   state_puts (_("[-- End of PGP output --]\n\n"), s);
@@ -564,7 +569,7 @@ static int pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
   mutt_unlink (sigfile);
   mutt_unlink (pgperrfile);
 
-  return 0;
+  return rv;
 }
 
 /*
@@ -577,9 +582,11 @@ void pgp_signed_handler (BODY *a, STATE *s)
   int protocol_major = TYPEOTHER;
   char *protocol_minor = NULL;
   
+  BODY *b = a;
   BODY **signatures = NULL;
   int sigcnt = 0;
   int i;
+  short goodsig = 1;
 
   protocol = mutt_get_parameter ("protocol", a->parameter);
   a = a->parts;
@@ -632,7 +639,10 @@ void pgp_signed_handler (BODY *a, STATE *s)
        {
          if (signatures[i]->type == TYPEAPPLICATION 
              && !mutt_strcasecmp(signatures[i]->subtype, "pgp-signature"))
-           pgp_verify_one (signatures[i], s, tempfile);
+         {
+           if (pgp_verify_one (signatures[i], s, tempfile) != 0)
+             goodsig = 0;
+         }
          else
            state_printf (s, _("[-- Warning: We can't verify %s/%s signatures. --]\n\n"),
                          TYPE(signatures[i]), signatures[i]->subtype);
@@ -640,6 +650,8 @@ void pgp_signed_handler (BODY *a, STATE *s)
       }
       
       mutt_unlink (tempfile);
+
+      b->goodsig = goodsig;
       
       /* Now display the signed body */
       state_puts (_("[-- The following data is signed --]\n\n"), s);
@@ -937,6 +949,16 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
     mutt_body_handler (tattach, s);
     s->fpin = fpin;
 
+    /* 
+     * if a multipart/signed is the _only_ sub-part of a
+     * multipart/encrypted, cache signature verification
+     * status.
+     *
+     */
+    
+    if (mutt_is_multipart_signed (tattach) && !tattach->next)
+      a->goodsig = tattach->goodsig;
+    
     if (s->flags & M_DISPLAY)
       state_puts (_("\n[-- End of PGP/MIME encrypted data --]\n"), s);
 
index 4af8b933ef2753885ffcde02d6ca0e985c95a279..4728a7ec4458f3558e2b140f1f39ae854d47da0a 100644 (file)
@@ -121,13 +121,18 @@ const char *_mutt_fmt_pgp_command (char *dest,
        optional = 0;
       break;
     }
+    default:
+    {
+      *dest = '\0';
+      break;
+    }
   }
-  
+
   if (optional)
-    mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
+    mutt_FormatString (dest, destlen, ifstring, _mutt_fmt_pgp_command, data, 0);
   else if (flags & M_FORMAT_OPTIONAL)
-    mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
-  
+    mutt_FormatString (dest, destlen, elsestring, _mutt_fmt_pgp_command, data, 0);
+
   return (src);
 }
 
index b1c12a95acd5ee5d9597c392492b498c204741ca..4f9b033b0ad49aaa4bad25331e43f9e059e6b0b1 100644 (file)
--- a/pgpkey.c
+++ b/pgpkey.c
@@ -703,6 +703,7 @@ BODY *pgp_make_key_attachment (char *tempf)
   att = mutt_new_body ();
   att->filename = safe_strdup (tempf);
   att->unlink = 1;
+  att->use_disp = 0;
   att->type = TYPEAPPLICATION;
   att->subtype = safe_strdup ("pgp-keys");
   snprintf (buff, sizeof (buff), _("PGP Key %s."), tmp);
index 2f4c5bfd63ec76c064142aeb19b80516ef7df306..28eea0986dfc8b2c7570b4c1ff453ab574662c47 100644 (file)
--- a/pgplib.h
+++ b/pgplib.h
 
 #ifdef _PGPPATH
 
-#define PGPENCRYPT 1
-#define PGPSIGN    2
-#define PGPKEY     4
+#define PGPENCRYPT  (1 << 0)
+#define PGPSIGN     (1 << 1)
+#define PGPKEY      (1 << 2)
+#define PGPGOODSIGN (1 << 3)
 
 #define KEYFLAG_CANSIGN                (1 <<  0)
 #define KEYFLAG_CANENCRYPT             (1 <<  1)
index 318e45c39743e3d582cb1c9a4b3868af73183c8e..0e79a913c6a682485b74bc6f36d09da611e63ea3 100644 (file)
@@ -42,7 +42,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <time.h>
-
 #ifdef HAVE_GETOPT_H
 # include <getopt.h>
 #endif
@@ -84,7 +83,7 @@ int main (int argc, char * const argv[])
       
       case '2': case '5':
       {
-       version = 'c' - '0';
+       version = c - '0';
        break;
       }
       
index f736b65a870f1535cab966fecc8df13f6b71d6a6..80bc6037d61936b35806994b2b6396b61fc89ef8 100644 (file)
@@ -867,9 +867,11 @@ cleanup:
 void
 mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, ATTACHPTR **idx)
 {
+#if 0
   int old_optweed = option (OPTWEED);
-
   set_option (OPTWEED);
+#endif
+  
   do
   {
     switch (op)
@@ -908,8 +910,10 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, ATTACHPTR **idx)
   }
   while (op != OP_NULL);
 
+#if 0
   if (option (OPTWEED) != old_optweed)
     toggle_option (OPTWEED);
+#endif
 }