From c53abe40f5e1efc4272262a9ee5689577897d045 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Tue, 8 Jun 1999 09:28:16 +0000 Subject: [PATCH] - Add a $weed option. - Add out-of-band reporting of signature status. --- Makefile.am | 6 ++++++ commands.c | 15 +++++++++------ compose.c | 1 - configure.in | 3 ++- hdrline.c | 6 ++++-- init.c | 2 ++ init.h | 3 ++- mutt.h | 7 ++++++- pgp.c | 38 ++++++++++++++++++++++++++++++-------- pgpinvoke.c | 13 +++++++++---- pgpkey.c | 1 + pgplib.h | 7 ++++--- pgppubring.c | 3 +-- recvattach.c | 6 +++++- 14 files changed, 81 insertions(+), 30 deletions(-) diff --git a/Makefile.am b/Makefile.am index 592ae2a1..dd58ac9b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/commands.c b/commands.c index d0daac87..86592db2 100644 --- a/commands.c +++ b/commands.c @@ -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; diff --git a/compose.c b/compose.c index 221f3493..43be5b55 100644 --- 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; diff --git a/configure.in b/configure.in index a4a14faa..2a4ce27c 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/hdrline.c b/hdrline.c index 85600e07..da202e36 100644 --- 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 3195581c..bcce6aef 100644 --- 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 315948e9..caac6b43 100644 --- 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 6a7bbd15..aba6f15d 100644 --- 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 df1b15fe..dfd7e3c5 100644 --- 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); diff --git a/pgpinvoke.c b/pgpinvoke.c index 4af8b933..4728a7ec 100644 --- a/pgpinvoke.c +++ b/pgpinvoke.c @@ -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); } diff --git a/pgpkey.c b/pgpkey.c index b1c12a95..4f9b033b 100644 --- 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); diff --git a/pgplib.h b/pgplib.h index 2f4c5bfd..28eea098 100644 --- a/pgplib.h +++ b/pgplib.h @@ -19,9 +19,10 @@ #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) diff --git a/pgppubring.c b/pgppubring.c index 318e45c3..0e79a913 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -42,7 +42,6 @@ #include #include #include - #ifdef HAVE_GETOPT_H # include #endif @@ -84,7 +83,7 @@ int main (int argc, char * const argv[]) case '2': case '5': { - version = 'c' - '0'; + version = c - '0'; break; } diff --git a/recvattach.c b/recvattach.c index f736b65a..80bc6037 100644 --- a/recvattach.c +++ b/recvattach.c @@ -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 } -- 2.40.0