From 10b7d54ecaa5c54622bf1239b57fa2e3359db0e1 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 4 Nov 2006 23:25:52 +0100 Subject: [PATCH] always build mutt with pgp + smime support. Signed-off-by: Pierre Habouzit --- Makefile.am | 10 ++-- attach.c | 2 +- commands.c | 55 ++++++++---------- compose.c | 56 ++++++------------- configure.ac | 19 ------- copy.c | 11 ++-- crypt-mod.h | 3 - crypt.c | 155 +++++++++++++++------------------------------------ cryptglue.c | 13 +---- curs_main.c | 9 --- handler.c | 47 +++++++--------- hdrline.c | 40 ++++++------- headers.c | 3 +- hook.c | 4 +- init.c | 8 +-- init.h | 3 - keymap.c | 9 +-- main.c | 5 -- mutt_crypt.h | 14 ----- muttlib.c | 8 +-- mx.c | 6 +- pager.c | 19 ------- parse.c | 3 +- pattern.c | 12 +--- pgp.c | 3 - pop/pop.c | 3 +- postpone.c | 42 +++++--------- recvattach.c | 60 +++++++++----------- send.c | 107 ++++++++++++++++------------------- sendlib.c | 45 +++++---------- smime.c | 11 +--- smime.h | 7 --- 32 files changed, 256 insertions(+), 536 deletions(-) diff --git a/Makefile.am b/Makefile.am index 5fb8853..bde3f54 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,7 @@ bin_SCRIPTS = muttngbug fleang BUILT_SOURCES = keymap_defs.h version.h -bin_PROGRAMS = muttng muttng_dotlock pgpringng pgpewrapng @SMIMEAUX_TARGET@ +bin_PROGRAMS = muttng muttng_dotlock pgpringng pgpewrapng smime_keysng muttng_SOURCES = $(BUILT_SOURCES) \ alias.c attach.c base64.c browser.c buffy.c \ charset.c color.c compress.c crypt.c cryptglue.c commands.c complete.c \ @@ -41,7 +41,7 @@ muttng_SOURCES = $(BUILT_SOURCES) \ thread.c url.c utf8.c wcwidth.c \ \ pgp.c pgpinvoke.c pgpkey.c pgplib.c gnupgparse.c pgpmicalg.c pgppacket.c \ - crypt-mod-pgp-classic.c + crypt-mod-pgp-classic.c smime.c crypt-mod-smime-classic.c muttng_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(LIBPOP) $(LIBNNTP) \ @@ -70,13 +70,11 @@ CPPFLAGS=@CPPFLAGS@ -I$(includedir) EXTRA_muttng_SOURCES = \ account.c mutt_sasl.c mutt_socket.c mutt_ssl.c \ - mutt_tunnel.c smime.c pgp.c pgpinvoke.c pgpkey.c \ + mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c \ pgplib.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \ alias.h browser.h enter.h \ mbyte.h remailer.h url.h state.h \ - pgppacket.c mutt_idna.h mutt_libesmtp.c \ - crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \ - sidebar.h state.h + mutt_idna.h mutt_libesmtp.c sidebar.h state.h EXTRA_DIST = config.rpath COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \ configure acconfig.h \ diff --git a/attach.c b/attach.c index e1cd5b6..c311ba2 100644 --- a/attach.c +++ b/attach.c @@ -399,7 +399,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, int unlink_tempfile = 0; is_message = mutt_is_message_type (a->type, a->subtype); - if (WithCrypto && is_message && a->hdr && (a->hdr->security & ENCRYPT) && + if (is_message && a->hdr && (a->hdr->security & ENCRYPT) && !crypt_valid_passphrase (a->hdr->security)) return (rc); use_mailcap = (flag == M_MAILCAP || diff --git a/commands.c b/commands.c index a14b471..58eaaa5 100644 --- a/commands.c +++ b/commands.c @@ -108,7 +108,7 @@ int mutt_display_message (HEADER * cur) if (res != -1) { /* see if crytpo is needed for this message. if so, we should exit curses */ - if (WithCrypto && cur->security) { + if (cur->security) { if (cur->security & ENCRYPT) { if (cur->security & APPLICATION_SMIME) crypt_smime_getkeys (cur->env); @@ -173,21 +173,18 @@ int mutt_display_message (HEADER * cur) safe_fclose (&fpfilterout); /* XXX - check result? */ - if (WithCrypto) { - /* update crypto information for this message */ - cur->security &= ~(GOODSIGN|BADSIGN); - cur->security |= crypt_query (cur->content); + /* update crypto information for this message */ + cur->security &= ~(GOODSIGN|BADSIGN); + cur->security |= crypt_query (cur->content); - /* Remove color cache for this message, in case there - are color patterns for both ~g and ~V */ - cur->pair = 0; - } + /* Remove color cache for this message, in case there + are color patterns for both ~g and ~V */ + cur->pair = 0; if (builtin) { pager_t info; - if (WithCrypto - && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) { + if ((cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) { if (cur->security & GOODSIGN) { if (!crypt_smime_verify_sender (cur)) mutt_message (_("S/MIME signature successfully verified.")); @@ -201,8 +198,7 @@ int mutt_display_message (HEADER * cur) mutt_error (_("S/MIME signature could NOT be verified.")); } - if (WithCrypto - && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) { + if ((cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) { if (cur->security & GOODSIGN) mutt_message (_("PGP signature successfully verified.")); else if (cur->security & PARTSIGN) @@ -334,7 +330,7 @@ static void pipe_msg (HEADER * h, FILE * fp, int decode, int print) pipe_set_flags (decode, print, &cmflags, &chflags); - if (WithCrypto && decode && h->security & ENCRYPT) { + if (decode && h->security & ENCRYPT) { if (!crypt_valid_passphrase (h->security)) return; endwin (); @@ -367,7 +363,7 @@ static int _mutt_pipe_message(HEADER * h, char *cmd, int decode, int print, mutt_message_hook (Context, h, M_MESSAGEHOOK); - if (WithCrypto && decode) { + if (decode) { mutt_parse_mime_message (Context, h); if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security)) return 1; @@ -386,7 +382,7 @@ static int _mutt_pipe_message(HEADER * h, char *cmd, int decode, int print, } else { /* handle tagged messages */ - if (WithCrypto && decode) { + if (decode) { for (i = 0; i < Context->vcount; i++) if (Context->hdrs[Context->v2r[i]]->tagged) { mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], @@ -621,17 +617,14 @@ static void set_copy_flags (HEADER * hdr, int decode, int decrypt, *cmflags = 0; *chflags = CH_UPDATE_LEN; - if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT)) { - if ((WithCrypto & APPLICATION_PGP) - && mutt_is_multipart_encrypted (hdr->content)) { + if (!decode && decrypt && (hdr->security & ENCRYPT)) { + if (mutt_is_multipart_encrypted (hdr->content)) { *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME; *cmflags = M_CM_DECODE_PGP; } - else if ((WithCrypto & APPLICATION_PGP) - && mutt_is_application_pgp (hdr->content) & ENCRYPT) + else if (mutt_is_application_pgp (hdr->content) & ENCRYPT) decode = 1; - else if ((WithCrypto & APPLICATION_SMIME) - && mutt_is_application_smime (hdr->content) & ENCRYPT) { + else if (mutt_is_application_smime (hdr->content) & ENCRYPT) { *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME; *cmflags = M_CM_DECODE_SMIME; } @@ -702,10 +695,8 @@ int mutt_save_message (HEADER * h, int delete, if (h) { - if (WithCrypto) { - need_passphrase = h->security & ENCRYPT; - app = h->security; - } + need_passphrase = h->security & ENCRYPT; + app = h->security; mutt_message_hook (Context, h, M_MESSAGEHOOK); mutt_default_save (buf, sizeof (buf), h); } @@ -723,10 +714,8 @@ int mutt_save_message (HEADER * h, int delete, if (h) { mutt_message_hook (Context, h, M_MESSAGEHOOK); mutt_default_save (buf, sizeof (buf), h); - if (WithCrypto) { - need_passphrase = h->security & ENCRYPT; - app = h->security; - } + need_passphrase = h->security & ENCRYPT; + app = h->security; h = NULL; } } @@ -759,7 +748,7 @@ int mutt_save_message (HEADER * h, int delete, if (mutt_save_confirm (buf, &st) != 0) return -1; - if (WithCrypto && need_passphrase && (decode || decrypt) + if (need_passphrase && (decode || decrypt) && !crypt_valid_passphrase (app)) return -1; @@ -916,7 +905,7 @@ void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp) if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype))) mutt_parse_part (fp, b); - if (WithCrypto && h) { + if (h) { if (h->content == b) h->security = 0; diff --git a/compose.c b/compose.c index 09acea2..aed420b 100644 --- a/compose.c +++ b/compose.c @@ -148,20 +148,12 @@ static void redraw_crypt_lines (HEADER * msg) { int off = 0; - if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME)) { - if (!msg->security) - mvaddstr (HDR_CRYPT, SW, " Security: "); - else if (msg->security & APPLICATION_SMIME) - mvaddstr (HDR_CRYPT, SW, " S/MIME: "); - else if (msg->security & APPLICATION_PGP) - mvaddstr (HDR_CRYPT, SW, " PGP: "); - } - else if ((WithCrypto & APPLICATION_SMIME)) + if (!msg->security) + mvaddstr (HDR_CRYPT, SW, " Security: "); + else if (msg->security & APPLICATION_SMIME) mvaddstr (HDR_CRYPT, SW, " S/MIME: "); - else if ((WithCrypto & APPLICATION_PGP)) + else if (msg->security & APPLICATION_PGP) mvaddstr (HDR_CRYPT, SW, " PGP: "); - else - return; if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN)) addstr (_("Sign, Encrypt")); @@ -172,31 +164,27 @@ static void redraw_crypt_lines (HEADER * msg) else addstr (_("Clear")); - if ((WithCrypto & APPLICATION_PGP)) - if ((msg->security & APPLICATION_PGP) - && (msg->security & (ENCRYPT | SIGN))) { - if ((msg->security & INLINE)) - addstr (_(" (inline)")); - else - addstr (_(" (PGP/MIME)")); - } + if ((msg->security & APPLICATION_PGP) + && (msg->security & (ENCRYPT | SIGN))) { + if ((msg->security & INLINE)) + addstr (_(" (inline)")); + else + addstr (_(" (PGP/MIME)")); + } clrtoeol (); move (HDR_CRYPTINFO, SW); clrtoeol (); - if ((WithCrypto & APPLICATION_PGP) - && msg->security & APPLICATION_PGP && msg->security & SIGN) + if (msg->security & APPLICATION_PGP && msg->security & SIGN) printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("")); - if ((WithCrypto & APPLICATION_SMIME) - && msg->security & APPLICATION_SMIME && msg->security & SIGN) { + if (msg->security & APPLICATION_SMIME && msg->security & SIGN) { printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("")); } - if ((WithCrypto & APPLICATION_SMIME) - && (msg->security & APPLICATION_SMIME) + if ((msg->security & APPLICATION_SMIME) && (msg->security & ENCRYPT) && SmimeCryptAlg && *SmimeCryptAlg) { mvprintw (HDR_CRYPTINFO, SW + 40, "%s%s", _("Encrypt with: "), @@ -305,8 +293,7 @@ static void draw_envelope (HEADER * msg, char *fcc) mvprintw (HDR_FCC, SW, TITLE_FMT, Prompts[HDR_FCC - 1]); mutt_paddstr (W, fcc); - if (WithCrypto) - redraw_crypt_lines (msg); + redraw_crypt_lines (msg); #ifdef MIXMASTER redraw_mix_line (msg->chain); @@ -751,8 +738,6 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ case OP_COMPOSE_ATTACH_KEY: - if (!(WithCrypto & APPLICATION_PGP)) - break; if (idxlen == idxmax) { p_realloc(&idx, idxmax += 5); menu->data = idx; @@ -1352,10 +1337,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ case OP_COMPOSE_PGP_MENU: - if (!(WithCrypto & APPLICATION_PGP)) - break; - if ((WithCrypto & APPLICATION_SMIME) - && msg->security & APPLICATION_SMIME) { + if (msg->security & APPLICATION_SMIME) { if (mutt_yesorno (_("S/MIME already selected. Clear & continue ? "), M_YES) != M_YES) { mutt_clear_error (); @@ -1375,11 +1357,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ case OP_COMPOSE_SMIME_MENU: - if (!(WithCrypto & APPLICATION_SMIME)) - break; - - if ((WithCrypto & APPLICATION_PGP) - && msg->security & APPLICATION_PGP) { + if (msg->security & APPLICATION_PGP) { if (mutt_yesorno (_("PGP already selected. Clear & continue ? "), M_YES) != M_YES) { mutt_clear_error (); diff --git a/configure.ac b/configure.ac index f9ee0ff..617f75d 100644 --- a/configure.ac +++ b/configure.ac @@ -127,22 +127,6 @@ dnl ---------------- gpgme ---------------- AC_SUBST(LIBGPGME_CFLAGS) AC_SUBST(LIBGPGME_LIBS) - -dnl ---------------- pgp/smime ---------------- - - AC_ARG_ENABLE(smime, AC_HELP_STRING([--disable-smime], [Disable SMIME support]), - [ if test x$enableval = xno ; then - have_smime=no - fi - ]) - - if test x$have_smime != xno ; then - AC_DEFINE(CRYPT_BACKEND_CLASSIC_SMIME,1, [ Define if you want clasic S/MIME support. ]) - MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o crypt-mod-smime-classic.o" - SMIMEAUX_TARGET="smime_keysng" - fi - - dnl ---------------- mixmaster ---------------- AC_ARG_WITH(mixmaster, AC_HELP_STRING([--with-mixmaster[=PATH]], [Include Mixmaster support]), @@ -160,9 +144,6 @@ dnl ---------------- mixmaster ---------------- OPS="$OPS \$(srcdir)/OPS.PGP \$(srcdir)/OPS.SMIME \$(srcdir)/OPS.CRYPT " AC_SUBST([OPS]) - -AC_SUBST(SMIMEAUX_TARGET) - AC_PATH_PROG(ISPELL, ispell, no) if test $ISPELL != no; then AC_DEFINE_UNQUOTED(ISPELL,"$ISPELL",[ Where to find ispell on your system. ]) diff --git a/copy.c b/copy.c index 504a1e2..989f3ce 100644 --- a/copy.c +++ b/copy.c @@ -621,26 +621,23 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body, if (flags & M_CM_REPLYING) s.flags |= M_REPLYING; - if (WithCrypto && flags & M_CM_VERIFY) + if (flags & M_CM_VERIFY) s.flags |= M_VERIFY; rc = mutt_body_handler (body, &s); } - else if (WithCrypto - && (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT)) { + else if ((flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT)) { BODY *cur; FILE *fp; - if ((WithCrypto & APPLICATION_PGP) - && (flags & M_CM_DECODE_PGP) && (hdr->security & APPLICATION_PGP) && + if ((flags & M_CM_DECODE_PGP) && (hdr->security & APPLICATION_PGP) && hdr->content->type == TYPEMULTIPART) { if (crypt_pgp_decrypt_mime (fpin, &fp, hdr->content, &cur)) return (-1); fputs ("MIME-Version: 1.0\n", fpout); } - if ((WithCrypto & APPLICATION_SMIME) - && (flags & M_CM_DECODE_SMIME) && (hdr->security & APPLICATION_SMIME) + if ((flags & M_CM_DECODE_SMIME) && (hdr->security & APPLICATION_SMIME) && hdr->content->type == TYPEAPPLICATION) { if (crypt_smime_decrypt_mime (fpin, &fp, hdr->content, &cur)) return (-1); diff --git a/crypt-mod.h b/crypt-mod.h index 09cc59a..c6846f6 100644 --- a/crypt-mod.h +++ b/crypt-mod.h @@ -13,9 +13,6 @@ #include "mutt.h" #include "mutt_crypt.h" -#define CRYPTO_SUPPORT(identifier) (WithCrypto & APPLICATION_ ## identifier) - - /* Type defintions for crypto module functions. */ diff --git a/crypt.c b/crypt.c index c0c64ad..bc44714 100644 --- a/crypt.c +++ b/crypt.c @@ -59,9 +59,6 @@ void crypt_current_time (STATE * s, const char *app_name) time_t t; char p[STRING], tmp[STRING]; - if (!WithCrypto) - return; - if (option (OPTCRYPTTIMESTAMP)) { t = time (NULL); setlocale (LC_TIME, ""); @@ -80,13 +77,8 @@ void crypt_current_time (STATE * s, const char *app_name) void crypt_forget_passphrase (void) { - if ((WithCrypto & APPLICATION_PGP)) crypt_pgp_void_passphrase (); - - if ((WithCrypto & APPLICATION_SMIME)) crypt_smime_void_passphrase (); - - if (WithCrypto) mutt_message _("Passphrase(s) forgotten."); } @@ -115,10 +107,10 @@ int crypt_valid_passphrase (int flags) disable_coredumps (); # endif - if ((WithCrypto & APPLICATION_PGP) && (flags & APPLICATION_PGP)) + if (flags & APPLICATION_PGP) ret = crypt_pgp_valid_passphrase (); - if ((WithCrypto & APPLICATION_SMIME) && (flags & APPLICATION_SMIME)) + if (flags & APPLICATION_SMIME) ret = crypt_smime_valid_passphrase (); return ret; @@ -131,17 +123,13 @@ int mutt_protect (HEADER * msg, char *keylist) BODY *pbody = NULL, *tmp_pbody = NULL; BODY *tmp_smime_pbody = NULL; BODY *tmp_pgp_pbody = NULL; - int flags = (WithCrypto & APPLICATION_PGP) ? msg->security : 0; + int flags = msg->security; int i; - if (!WithCrypto) - return -1; - if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security)) return (-1); - if ((WithCrypto & APPLICATION_PGP) - && ((msg->security & PGPINLINE) == PGPINLINE)) { + if ((msg->security & PGPINLINE) == PGPINLINE) { /* they really want to send it inline... go for it */ if (!isendwin ()) mutt_endwin _("Invoking PGP..."); @@ -169,21 +157,17 @@ int mutt_protect (HEADER * msg, char *keylist) if (!isendwin ()) mutt_endwin (NULL); - if ((WithCrypto & APPLICATION_SMIME)) - tmp_smime_pbody = msg->content; - if ((WithCrypto & APPLICATION_PGP)) - tmp_pgp_pbody = msg->content; + tmp_smime_pbody = msg->content; + tmp_pgp_pbody = msg->content; if (msg->security & SIGN) { - if ((WithCrypto & APPLICATION_SMIME) - && (msg->security & APPLICATION_SMIME)) { + if (msg->security & APPLICATION_SMIME) { if (!(tmp_pbody = crypt_smime_sign_message (msg->content))) return -1; pbody = tmp_smime_pbody = tmp_pbody; } - if ((WithCrypto & APPLICATION_PGP) - && (msg->security & APPLICATION_PGP) + if ((msg->security & APPLICATION_PGP) && (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG))) { if (!(tmp_pbody = crypt_pgp_sign_message (msg->content))) return -1; @@ -192,7 +176,7 @@ int mutt_protect (HEADER * msg, char *keylist) pbody = tmp_pgp_pbody = tmp_pbody; } - if (WithCrypto && (msg->security & APPLICATION_SMIME) + if ((msg->security & APPLICATION_SMIME) && (msg->security & APPLICATION_PGP)) { /* here comes the draft ;-) */ } @@ -200,8 +184,7 @@ int mutt_protect (HEADER * msg, char *keylist) if (msg->security & ENCRYPT) { - if ((WithCrypto & APPLICATION_SMIME) - && (msg->security & APPLICATION_SMIME)) { + if ((msg->security & APPLICATION_SMIME)) { if (!(tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody, keylist))) { /* signed ? free it! */ @@ -218,8 +201,7 @@ int mutt_protect (HEADER * msg, char *keylist) pbody = tmp_pbody; } - if ((WithCrypto & APPLICATION_PGP) - && (msg->security & APPLICATION_PGP)) { + if ((msg->security & APPLICATION_PGP)) { if (!(pbody = crypt_pgp_encrypt_message (tmp_pgp_pbody, keylist, flags & SIGN))) { @@ -268,15 +250,12 @@ int mutt_is_multipart_signed (BODY * b) if (!(ascii_strcasecmp (p, "multipart/mixed"))) return SIGN; - if ((WithCrypto & APPLICATION_PGP) - && !(ascii_strcasecmp (p, "application/pgp-signature"))) + if (!(ascii_strcasecmp (p, "application/pgp-signature"))) return PGPSIGN; - if ((WithCrypto & APPLICATION_SMIME) - && !(ascii_strcasecmp (p, "application/x-pkcs7-signature"))) + if (!(ascii_strcasecmp (p, "application/x-pkcs7-signature"))) return SMIMESIGN; - if ((WithCrypto & APPLICATION_SMIME) - && !(ascii_strcasecmp (p, "application/pkcs7-signature"))) + if (!(ascii_strcasecmp (p, "application/pkcs7-signature"))) return SMIMESIGN; return 0; @@ -285,19 +264,15 @@ int mutt_is_multipart_signed (BODY * b) int mutt_is_multipart_encrypted (BODY * b) { - if ((WithCrypto & APPLICATION_PGP)) { - char *p; - - if (!b || b->type != TYPEMULTIPART || - !b->subtype || ascii_strcasecmp (b->subtype, "encrypted") || - !(p = mutt_get_parameter ("protocol", b->parameter)) || - ascii_strcasecmp (p, "application/pgp-encrypted")) - return 0; + char *p; - return PGPENCRYPT; - } + if (!b || b->type != TYPEMULTIPART || + !b->subtype || ascii_strcasecmp (b->subtype, "encrypted") || + !(p = mutt_get_parameter ("protocol", b->parameter)) || + ascii_strcasecmp (p, "application/pgp-encrypted")) + return 0; - return 0; + return PGPENCRYPT; } @@ -419,25 +394,19 @@ int crypt_query (BODY * m) { int t = 0; - if (!WithCrypto) - return 0; - if (!m) return 0; if (m->type == TYPEAPPLICATION) { - if ((WithCrypto & APPLICATION_PGP)) - t |= mutt_is_application_pgp (m); - - if ((WithCrypto & APPLICATION_SMIME)) { - t |= mutt_is_application_smime (m); - if (t && m->goodsig) - t |= GOODSIGN; - if (t && m->badsig) - t |= BADSIGN; - } + t |= mutt_is_application_pgp (m); + + t |= mutt_is_application_smime (m); + if (t && m->goodsig) + t |= GOODSIGN; + if (t && m->badsig) + t |= BADSIGN; } - else if ((WithCrypto & APPLICATION_PGP) && m->type == TYPETEXT) { + else if (m->type == TYPETEXT) { t |= mutt_is_application_pgp (m); if (t && m->goodsig) t |= GOODSIGN; @@ -482,9 +451,6 @@ int crypt_write_signed (BODY * a, STATE * s, const char *tempfile) short hadcr; size_t bytes; - if (!WithCrypto) - return -1; - if (!(fp = safe_fopen (tempfile, "w"))) { mutt_perror (tempfile); return -1; @@ -520,16 +486,13 @@ int crypt_write_signed (BODY * a, STATE * s, const char *tempfile) void convert_to_7bit (BODY * a) { - if (!WithCrypto) - return; - while (a) { if (a->type == TYPEMULTIPART) { if (a->encoding != ENC7BIT) { a->encoding = ENC7BIT; convert_to_7bit (a->parts); } - else if ((WithCrypto & APPLICATION_PGP) && option (OPTPGPSTRICTENC)) + else if (option (OPTPGPSTRICTENC)) convert_to_7bit (a->parts); } else if (a->type == TYPEMESSAGE && @@ -559,17 +522,13 @@ void crypt_extract_keys_from_messages (HEADER * h) address_t *tmp = NULL; FILE *fpout; - if (!WithCrypto) - return; - mutt_mktemp (tempfname); if (!(fpout = safe_fopen (tempfname, "w"))) { mutt_perror (tempfname); return; } - if ((WithCrypto & APPLICATION_PGP)) - set_option (OPTDONTHANDLEPGPKEYS); + set_option (OPTDONTHANDLEPGPKEYS); if (!h) { for (i = 0; i < Context->vcount; i++) { @@ -582,8 +541,7 @@ void crypt_extract_keys_from_messages (HEADER * h) break; } - if ((WithCrypto & APPLICATION_PGP) - && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP)) { + if (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP) { mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]], M_CM_DECODE | M_CM_CHARCONV, 0); fflush (fpout); @@ -592,8 +550,7 @@ void crypt_extract_keys_from_messages (HEADER * h) crypt_pgp_invoke_import (tempfname); } - if ((WithCrypto & APPLICATION_SMIME) - && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_SMIME)) { + if (Context->hdrs[Context->v2r[i]]->security & APPLICATION_SMIME) { if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT) mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]], M_CM_NOHEADER | M_CM_DECODE_CRYPT @@ -623,16 +580,14 @@ void crypt_extract_keys_from_messages (HEADER * h) else { mutt_parse_mime_message (Context, h); if (!(h->security & ENCRYPT && !crypt_valid_passphrase (h->security))) { - if ((WithCrypto & APPLICATION_PGP) - && (h->security & APPLICATION_PGP)) { + if (h->security & APPLICATION_PGP) { mutt_copy_message (fpout, Context, h, M_CM_DECODE | M_CM_CHARCONV, 0); fflush (fpout); mutt_endwin (_("Trying to extract PGP keys...\n")); crypt_pgp_invoke_import (tempfname); } - if ((WithCrypto & APPLICATION_SMIME) - && (h->security & APPLICATION_SMIME)) { + if (h->security & APPLICATION_SMIME) { if (h->security & ENCRYPT) mutt_copy_message (fpout, Context, h, M_CM_NOHEADER | M_CM_DECODE_CRYPT | M_CM_DECODE_SMIME, 0); @@ -659,8 +614,7 @@ void crypt_extract_keys_from_messages (HEADER * h) mutt_unlink (tempfname); - if ((WithCrypto & APPLICATION_PGP)) - unset_option (OPTDONTHANDLEPGPKEYS); + unset_option (OPTDONTHANDLEPGPKEYS); } @@ -671,24 +625,18 @@ int crypt_get_keys (HEADER * msg, char **keylist) * keys if the user has requested this service. */ - if (!WithCrypto) - return 0; - - if ((WithCrypto & APPLICATION_PGP)) - set_option (OPTPGPCHECKTRUST); + set_option (OPTPGPCHECKTRUST); *keylist = NULL; if (msg->security & ENCRYPT) { - if ((WithCrypto & APPLICATION_PGP) - && (msg->security & APPLICATION_PGP)) { + if (msg->security & APPLICATION_PGP) { if ((*keylist = crypt_pgp_findkeys (msg->env->to, msg->env->cc, msg->env->bcc)) == NULL) return (-1); unset_option (OPTPGPCHECKTRUST); } - if ((WithCrypto & APPLICATION_SMIME) - && (msg->security & APPLICATION_SMIME)) { + if (msg->security & APPLICATION_SMIME) { if ((*keylist = crypt_smime_findkeys (msg->env->to, msg->env->cc, msg->env->bcc)) == NULL) return (-1); @@ -702,9 +650,6 @@ int crypt_get_keys (HEADER * msg, char **keylist) static void crypt_fetch_signatures (BODY ***signatures, BODY * a, int *n) { - if (!WithCrypto) - return; - for (; a; a = a->next) { if (a->type == TYPEMULTIPART) crypt_fetch_signatures (signatures, a->parts, n); @@ -736,9 +681,6 @@ int mutt_signed_handler (BODY * a, STATE * s) short goodsig = 1; int rc = 0; - if (!WithCrypto) - return (-1); - protocol = mutt_get_parameter ("protocol", a->parameter); a = a->parts; @@ -769,11 +711,9 @@ int mutt_signed_handler (BODY * a, STATE * s) } - if ((WithCrypto & APPLICATION_PGP) - && protocol_major == TYPEAPPLICATION + if (protocol_major == TYPEAPPLICATION && !m_strcasecmp(protocol_minor, "pgp-signature")); - else if ((WithCrypto & APPLICATION_SMIME) - && protocol_major == TYPEAPPLICATION + else if (protocol_major == TYPEAPPLICATION && !(m_strcasecmp(protocol_minor, "x-pkcs7-signature") && m_strcasecmp(protocol_minor, "pkcs7-signature"))); else if (protocol_major == TYPEMULTIPART @@ -793,8 +733,7 @@ int mutt_signed_handler (BODY * a, STATE * s) mutt_mktemp (tempfile); if (crypt_write_signed (a, s, tempfile) == 0) { for (i = 0; i < sigcnt; i++) { - if ((WithCrypto & APPLICATION_PGP) - && signatures[i]->type == TYPEAPPLICATION + if (signatures[i]->type == TYPEAPPLICATION && !m_strcasecmp(signatures[i]->subtype, "pgp-signature")) { if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0) goodsig = 0; @@ -802,12 +741,10 @@ int mutt_signed_handler (BODY * a, STATE * s) continue; } - if ((WithCrypto & APPLICATION_SMIME) - && signatures[i]->type == TYPEAPPLICATION - && - (!m_strcasecmp(signatures[i]->subtype, "x-pkcs7-signature") - || !m_strcasecmp(signatures[i]->subtype, - "pkcs7-signature"))) { + if (signatures[i]->type == TYPEAPPLICATION + && (!m_strcasecmp(signatures[i]->subtype, "x-pkcs7-signature") + || !m_strcasecmp(signatures[i]->subtype, "pkcs7-signature"))) + { if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0) goodsig = 0; diff --git a/cryptglue.c b/cryptglue.c index d83b612..d76fa44 100644 --- a/cryptglue.c +++ b/cryptglue.c @@ -37,13 +37,8 @@ */ -#ifdef CRYPT_BACKEND_CLASSIC_PGP extern struct crypt_module_specs crypt_mod_pgp_classic; -#endif - -#ifdef CRYPT_BACKEND_CLASSIC_SMIME extern struct crypt_module_specs crypt_mod_smime_classic; -#endif #ifdef CRYPT_BACKEND_GPGME extern struct crypt_module_specs crypt_mod_pgp_gpgme; @@ -52,7 +47,6 @@ extern struct crypt_module_specs crypt_mod_smime_gpgme; void crypt_init (void) { -#ifdef CRYPT_BACKEND_CLASSIC_PGP if ( #ifdef CRYPT_BACKEND_GPGME (!option (OPTCRYPTUSEGPGME)) @@ -61,9 +55,7 @@ void crypt_init (void) #endif ) crypto_module_register (&crypt_mod_pgp_classic); -#endif -#ifdef CRYPT_BACKEND_CLASSIC_SMIME if ( #ifdef CRYPT_BACKEND_GPGME (!option (OPTCRYPTUSEGPGME)) @@ -72,7 +64,6 @@ void crypt_init (void) #endif ) crypto_module_register (&crypt_mod_smime_classic); -#endif if (option (OPTCRYPTUSEGPGME)) { #ifdef CRYPT_BACKEND_GPGME @@ -99,10 +90,10 @@ void crypt_init (void) /* Show a message that a backend will be invoked. */ void crypt_invoke_message (int type) { - if ((WithCrypto & APPLICATION_PGP) && (type & APPLICATION_PGP)) { + if (type & APPLICATION_PGP) { mutt_message _("Invoking PGP..."); } - else if ((WithCrypto & APPLICATION_SMIME) && (type & APPLICATION_SMIME)) { + else if (type & APPLICATION_SMIME) { mutt_message _("Invoking S/MIME..."); } } diff --git a/curs_main.c b/curs_main.c index 6d8421e..53b11c5 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1512,9 +1512,6 @@ int mutt_index_menu (void) case OP_DECRYPT_COPY: case OP_DECRYPT_SAVE: - if (!WithCrypto) - break; - /* fall thru */ case OP_COPY_MESSAGE: case OP_SAVE: case OP_DECODE_COPY: @@ -2071,8 +2068,6 @@ int mutt_index_menu (void) break; case OP_MAIL_KEY: - if (!(WithCrypto & APPLICATION_PGP)) - break; CHECK_ATTACH; ci_send_message (SENDKEY, NULL, NULL, NULL, NULL); menu->redraw = REDRAW_FULL; @@ -2080,8 +2075,6 @@ int mutt_index_menu (void) case OP_EXTRACT_KEYS: - if (!WithCrypto) - break; CHECK_MSGCOUNT; CHECK_VISIBLE; crypt_extract_keys_from_messages (tag ? NULL : CURHDR); @@ -2090,8 +2083,6 @@ int mutt_index_menu (void) case OP_CHECK_TRADITIONAL: - if (!(WithCrypto & APPLICATION_PGP)) - break; CHECK_MSGCOUNT; CHECK_VISIBLE; if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) diff --git a/handler.c b/handler.c index 3a9dd14..abde630 100644 --- a/handler.c +++ b/handler.c @@ -968,11 +968,9 @@ int mutt_can_decode (BODY * a) else if (a->type == TYPEMULTIPART) { BODY *p; - if (WithCrypto) { - if (ascii_strcasecmp (a->subtype, "signed") == 0 || - ascii_strcasecmp (a->subtype, "encrypted") == 0) - return (1); - } + if (ascii_strcasecmp (a->subtype, "signed") == 0 || + ascii_strcasecmp (a->subtype, "encrypted") == 0) + return (1); for (p = a->parts; p; p = p->next) { if (mutt_can_decode (p)) @@ -980,10 +978,10 @@ int mutt_can_decode (BODY * a) } } - else if (WithCrypto && a->type == TYPEAPPLICATION) { - if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (a)) + else if (a->type == TYPEAPPLICATION) { + if (mutt_is_application_pgp(a)) return (1); - if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime (a)) + if (mutt_is_application_smime (a)) return (1); } @@ -1285,24 +1283,20 @@ void mutt_decode_attachment (BODY * b, STATE * s) fseeko (s->fpin, b->offset, 0); switch (b->encoding) { case ENCQUOTEDPRINTABLE: - mutt_decode_quoted (s, b->length, istext || - ((WithCrypto & APPLICATION_PGP) && - mutt_is_application_pgp (b)), cd); + mutt_decode_quoted(s, b->length, + istext || mutt_is_application_pgp(b), cd); break; case ENCBASE64: - mutt_decode_base64 (s, b->length, istext || - ((WithCrypto & APPLICATION_PGP) && - mutt_is_application_pgp (b)), cd); + mutt_decode_base64(s, b->length, + istext || mutt_is_application_pgp(b), cd); break; case ENCUUENCODED: - mutt_decode_uuencoded (s, b->length, istext - || ((WithCrypto & APPLICATION_PGP) && - mutt_is_application_pgp (b)), cd); + mutt_decode_uuencoded(s, b->length, + istext || mutt_is_application_pgp(b), cd); break; default: - mutt_decode_xbit (s, b->length, istext - || ((WithCrypto & APPLICATION_PGP) && - mutt_is_application_pgp (b)), cd); + mutt_decode_xbit(s, b->length, + istext || mutt_is_application_pgp(b), cd); break; } @@ -1341,7 +1335,7 @@ int mutt_body_handler (BODY * b, STATE * s) /* avoid copying this part twice since removing the transfer-encoding is * the only operation needed. */ - if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b)) + if (mutt_is_application_pgp (b)) handler = crypt_pgp_application_pgp_handler; else if (ascii_strcasecmp @@ -1368,7 +1362,7 @@ int mutt_body_handler (BODY * b, STATE * s) if (ascii_strcasecmp ("alternative", b->subtype) == 0) handler = alternative_handler; - else if (WithCrypto && ascii_strcasecmp ("signed", b->subtype) == 0) { + else if (ascii_strcasecmp ("signed", b->subtype) == 0) { p = mutt_get_parameter ("protocol", b->parameter); if (!p) @@ -1377,8 +1371,7 @@ int mutt_body_handler (BODY * b, STATE * s) else if (s->flags & M_VERIFY) handler = mutt_signed_handler; } - else if ((WithCrypto & APPLICATION_PGP) - && m_strcasecmp("encrypted", b->subtype) == 0) { + else if (m_strcasecmp("encrypted", b->subtype) == 0) { p = mutt_get_parameter ("protocol", b->parameter); if (!p) @@ -1392,10 +1385,10 @@ int mutt_body_handler (BODY * b, STATE * s) if (!handler) handler = multipart_handler; } - else if (WithCrypto && b->type == TYPEAPPLICATION) { - if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b)) + else if (b->type == TYPEAPPLICATION) { + if (mutt_is_application_pgp (b)) handler = crypt_pgp_application_pgp_handler; - if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime (b)) + if (mutt_is_application_smime (b)) handler = crypt_smime_application_smime_handler; } diff --git a/hdrline.c b/hdrline.c index b47e2bd..79b3ea5 100644 --- a/hdrline.c +++ b/hdrline.c @@ -646,7 +646,7 @@ static const char *hdr_format_str (char *dest, /* The recursion allows messages without depth to return 0. */ if (optional) optional = count != 0; - + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); snprintf (dest, destlen, fmt, count); } @@ -656,35 +656,27 @@ static const char *hdr_format_str (char *dest, ch = ' '; - if (WithCrypto && hdr->security & GOODSIGN) + if (hdr->security & GOODSIGN) ch = 'S'; - else if (WithCrypto && hdr->security & ENCRYPT) + else if (hdr->security & ENCRYPT) ch = 'P'; - else if (WithCrypto && hdr->security & SIGN) + else if (hdr->security & SIGN) ch = 's'; - else if ((WithCrypto & APPLICATION_PGP) && hdr->security & PGPKEY) + else if (hdr->security & PGPKEY) ch = 'K'; - snprintf (buf2, sizeof (buf2), - "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' : - ((hdr->read - && (ctx - && ctx->msgnotreadyet != - hdr->msgno)) - ? (hdr-> - replied ? 'r' : ' ') : (hdr-> - old ? - 'O' : - 'N')))), + snprintf(buf2, sizeof (buf2), "%c%c%c", + (THREAD_NEW ? 'n' + : (THREAD_OLD + ? 'o' + : ((hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno)) + ? (hdr->replied ? 'r' : ' ') + : (hdr->old ? 'O' : 'N')))), hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch), - hdr->tagged ? '*' : (hdr-> - flagged ? '!' : (Tochars - && - ((i = - mutt_user_is_recipient - (hdr)) < - m_strlen(Tochars)) ? - Tochars[i] : ' '))); + hdr->tagged ? '*' + : (hdr->flagged ? '!' + : (Tochars && ((i = mutt_user_is_recipient(hdr)) < m_strlen(Tochars)) + ? Tochars[i] : ' '))); mutt_format_s (dest, destlen, prefix, buf2); break; diff --git a/headers.c b/headers.c index d1f2e35..1e95ed6 100644 --- a/headers.c +++ b/headers.c @@ -164,8 +164,7 @@ void mutt_edit_headers (const char *editor, } - else if ((WithCrypto & APPLICATION_PGP) - && ascii_strncasecmp ("pgp:", cur->data, 4) == 0) { + else if (ascii_strncasecmp("pgp:", cur->data, 4) == 0) { msg->security = mutt_parse_crypt_hdr (cur->data + 4, 0); if (msg->security) msg->security |= APPLICATION_PGP; diff --git a/hook.c b/hook.c index fb74206..afa528d 100644 --- a/hook.c +++ b/hook.c @@ -103,8 +103,8 @@ int mutt_parse_hook (BUFFER * buf __attribute__ ((unused)), BUFFER * s, unsigned } #endif else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK)) - && (!WithCrypto || !(data & M_CRYPTHOOK)) - ) { + && !(data & M_CRYPTHOOK)) + { char tmp[HUGE_STRING]; m_strcpy(tmp, sizeof(tmp), pattern.data); diff --git a/init.c b/init.c index d0c25e1..5ad2e22 100644 --- a/init.c +++ b/init.c @@ -1818,8 +1818,7 @@ static const struct mapping_t* get_sortmap (struct option_t* option) { map = SortBrowserMethods; break; case DT_SORT_KEYS: - if ((WithCrypto & APPLICATION_PGP)) - map = SortKeyMethods; + map = SortKeyMethods; break; case DT_SORT_AUX: map = SortAuxMethods; @@ -2461,10 +2460,7 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) map = SortBrowserMethods; break; case DT_SORT_KEYS: - if ((WithCrypto & APPLICATION_PGP)) - map = SortKeyMethods; - else - map = SortMethods; + map = SortKeyMethods; break; default: map = SortMethods; diff --git a/init.h b/init.h index 072618d..92d2a54 100644 --- a/init.h +++ b/init.h @@ -3897,9 +3897,6 @@ static const char* Features[] = { #ifdef HAVE_COLOR "color", #endif -#ifdef CRYPT_BACKEND_CLASSIC_SMIME - "class_smime", -#endif #ifdef CRYPT_BACKEND_GPGME "gpgme", #endif diff --git a/keymap.c b/keymap.c index 208fce0..272fe0a 100644 --- a/keymap.c +++ b/keymap.c @@ -529,11 +529,8 @@ void km_init (void) create_bindings (OpAlias, MENU_ALIAS); - if ((WithCrypto & APPLICATION_PGP)) - create_bindings (OpPgp, MENU_PGP); - - if ((WithCrypto & APPLICATION_SMIME)) - create_bindings (OpSmime, MENU_SMIME); + create_bindings (OpPgp, MENU_PGP); + create_bindings (OpSmime, MENU_SMIME); #ifdef CRYPT_BACKEND_GPGME create_bindings (OpPgp, MENU_KEY_SELECT_PGP); @@ -755,7 +752,7 @@ struct binding_t *km_get_table (int menu) return OpQuery; case MENU_PGP: - return (WithCrypto & APPLICATION_PGP) ? OpPgp : NULL; + return OpPgp; #ifdef CRYPT_BACKEND_GPGME case MENU_KEY_SELECT_PGP: diff --git a/main.c b/main.c index 7b266f9..f6e8d1f 100644 --- a/main.c +++ b/main.c @@ -402,11 +402,6 @@ static void show_version (void) ); puts ( -#ifdef CRYPT_BACKEND_CLASSIC_SMIME - "+CRYPT_BACKEND_CLASSIC_SMIME " -#else - "-CRYPT_BACKEND_CLASSIC_SMIME " -#endif #ifdef CRYPT_BACKEND_GPGME "+CRYPT_BACKEND_GPGME " #else diff --git a/mutt_crypt.h b/mutt_crypt.h index 19b28c6..2b9434c 100644 --- a/mutt_crypt.h +++ b/mutt_crypt.h @@ -50,20 +50,6 @@ #define SMIMEBADSIGN (APPLICATION_SMIME | BADSIGN) #define SMIMEOPAQUE (APPLICATION_SMIME | SIGNOPAQUE) - -/* WITHCRYPTO actually replaces ifdefs so make the code more readable. - Because it is defined as a constant and known at compile time, the - compiler can do dead code elimination and thus it behaves - effectively as a conditional compile directive. It is set to false - if no crypto backend is configures or to a bit vector denoting the - configured backends. */ -#if defined(CRYPT_BACKEND_CLASSIC_SMIME) || defined (CRYPT_BACKEND_GPGME) -# define WithCrypto (APPLICATION_PGP | APPLICATION_SMIME) -#else -# define WithCrypto APPLICATION_PGP -#endif - - #define KEYFLAG_CANSIGN (1 << 0) #define KEYFLAG_CANENCRYPT (1 << 1) #define KEYFLAG_ISX509 (1 << 2) diff --git a/muttlib.c b/muttlib.c index 73b2e5e..0bf733c 100644 --- a/muttlib.c +++ b/muttlib.c @@ -542,9 +542,9 @@ int mutt_needs_mailcap (BODY * m) break; case TYPEAPPLICATION: - if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (m)) + if (mutt_is_application_pgp (m)) return 0; - if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime (m)) + if (mutt_is_application_smime (m)) return 0; break; @@ -561,7 +561,7 @@ int mutt_is_text_part (BODY * b) int t = b->type; char *s = b->subtype; - if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b)) + if (mutt_is_application_pgp (b)) return 0; if (t == TYPETEXT) @@ -572,7 +572,7 @@ int mutt_is_text_part (BODY * b) return 1; } - if ((WithCrypto & APPLICATION_PGP) && t == TYPEAPPLICATION) { + if (t == TYPEAPPLICATION) { if (!ascii_strcasecmp ("pgp-keys", s)) return 1; } diff --git a/mx.c b/mx.c index b596bca..05f0552 100644 --- a/mx.c +++ b/mx.c @@ -1326,10 +1326,8 @@ void mx_update_context (CONTEXT * ctx, int new_messages) for (msgno = ctx->msgcount - new_messages; msgno < ctx->msgcount; msgno++) { h = ctx->hdrs[msgno]; - if (WithCrypto) { - /* NOTE: this _must_ be done before the check for mailcap! */ - h->security = crypt_query (h->content); - } + /* NOTE: this _must_ be done before the check for mailcap! */ + h->security = crypt_query (h->content); if (!ctx->pattern) { ctx->v2r[ctx->vcount] = msgno; diff --git a/pager.c b/pager.c index 965a85e..f429e77 100644 --- a/pager.c +++ b/pager.c @@ -2112,8 +2112,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) case OP_CHECK_TRADITIONAL: CHECK_MODE (IsHeader (extra)); - if (!(WithCrypto & APPLICATION_PGP)) - break; if (!(extra->hdr->security & PGP_TRADITIONAL_CHECKED)) { ch = -1; rc = OP_CHECK_TRADITIONAL; @@ -2419,11 +2417,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) break; case OP_DECRYPT_SAVE: - if (!WithCrypto) { - ch = -1; - break; - } - /* fall through */ case OP_SAVE: if (IsAttach (extra)) { mutt_save_attachment_list (extra->fp, 0, extra->bdy, extra->hdr, @@ -2435,10 +2428,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) case OP_DECODE_SAVE: case OP_DECODE_COPY: case OP_DECRYPT_COPY: - if (!WithCrypto && ch == OP_DECRYPT_COPY) { - ch = -1; - break; - } CHECK_MODE (IsHeader (extra)); if (mutt_save_message (extra->hdr, (ch == OP_DECRYPT_SAVE) || @@ -2564,10 +2553,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) case OP_MAIL_KEY: - if (!(WithCrypto & APPLICATION_PGP)) { - ch = -1; - break; - } CHECK_MODE (IsHeader (extra)); CHECK_ATTACH; ci_send_message (SENDKEY, NULL, NULL, extra->ctx, extra->hdr); @@ -2580,10 +2565,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) break; case OP_EXTRACT_KEYS: - if (!WithCrypto) { - ch = -1; - break; - } CHECK_MODE (IsHeader (extra)); crypt_extract_keys_from_messages (extra->hdr); redraw = REDRAW_FULL; diff --git a/parse.c b/parse.c index 9c1195d..d043331 100644 --- a/parse.c +++ b/parse.c @@ -927,8 +927,7 @@ void mutt_parse_mime_message (CONTEXT * ctx, HEADER * cur) if ((msg = mx_open_message (ctx, cur->msgno))) { mutt_parse_part (msg->fp, cur->content); - if (WithCrypto) - cur->security = crypt_query (cur->content); + cur->security = crypt_query (cur->content); mx_close_message (&msg); } diff --git a/pattern.c b/pattern.c index d388924..335337e 100644 --- a/pattern.c +++ b/pattern.c @@ -180,8 +180,8 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) if (pat->op != M_HEADER) { mutt_parse_mime_message (ctx, h); - if (WithCrypto && (h->security & ENCRYPT) - && !crypt_valid_passphrase (h->security)) { + if ((h->security & ENCRYPT) && !crypt_valid_passphrase (h->security)) + { mx_close_message (&msg); if (fp) { fclose (fp); @@ -1069,20 +1069,12 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, case M_COLLAPSED: return (pat->not ^ (h->collapsed && h->num_hidden > 1)); case M_CRYPT_SIGN: - if (!WithCrypto) - break; return (pat->not ^ ((h->security & SIGN) ? 1 : 0)); case M_CRYPT_VERIFIED: - if (!WithCrypto) - break; return (pat->not ^ ((h->security & GOODSIGN) ? 1 : 0)); case M_CRYPT_ENCRYPT: - if (!WithCrypto) - break; return (pat->not ^ ((h->security & ENCRYPT) ? 1 : 0)); case M_PGP_KEY: - if (!(WithCrypto & APPLICATION_PGP)) - break; return (pat->not ^ ((h->security & APPLICATION_PGP) && (h->security & PGPKEY))); case M_XLABEL: diff --git a/pgp.c b/pgp.c index a969176..c6e19e6 100644 --- a/pgp.c +++ b/pgp.c @@ -1489,9 +1489,6 @@ int pgp_send_menu (HEADER * msg, int *redraw) char prompt[LONG_STRING]; - if (!(WithCrypto & APPLICATION_PGP)) - return msg->security; - /* If autoinline and no crypto options set, then set inline. */ if (option (OPTPGPAUTOINLINE) && !((msg->security & APPLICATION_PGP) && (msg->security & (SIGN | ENCRYPT)))) diff --git a/pop/pop.c b/pop/pop.c index bba466f..73936d1 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -422,8 +422,7 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) h->content->length = ftello (msg->fp) - h->content->offset; /* This needs to be done in case this is a multipart message */ - if (!WithCrypto) - h->security = crypt_query (h->content); + h->security = crypt_query (h->content); mutt_clear_error (); rewind (msg->fp); diff --git a/postpone.c b/postpone.c index 7cfe924..afcc9b1 100644 --- a/postpone.c +++ b/postpone.c @@ -332,10 +332,9 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, mutt_free_list (&tmp); tmp = next; } - else if ((WithCrypto & APPLICATION_PGP) - && (m_strncmp("Pgp:", tmp->data, 4) == 0 /* this is generated - * by old mutt versions - */ + else if ((m_strncmp("Pgp:", tmp->data, 4) == 0 /* this is generated + * by old mutt versions + */ || m_strncmp("X-Mutt-PGP:", tmp->data, 11) == 0)) { hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1); hdr->security |= APPLICATION_PGP; @@ -350,8 +349,7 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, mutt_free_list (&tmp); tmp = next; } - else if ((WithCrypto & APPLICATION_SMIME) - && m_strncmp("X-Mutt-SMIME:", tmp->data, 13) == 0) { + else if (m_strncmp("X-Mutt-SMIME:", tmp->data, 13) == 0) { hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1); hdr->security |= APPLICATION_SMIME; @@ -405,11 +403,7 @@ int mutt_parse_crypt_hdr (char *p, int set_signas) char pgp_sign_as[LONG_STRING] = "\0", *q; char smime_cryptalg[LONG_STRING] = "\0"; - if (!WithCrypto) - return 0; - for (p = vskipspaces(p); *p; p++) { - switch (*p) { case 'e': case 'E': @@ -488,10 +482,10 @@ int mutt_parse_crypt_hdr (char *p, int set_signas) } /* the cryptalg field must not be empty */ - if ((WithCrypto & APPLICATION_SMIME) && *smime_cryptalg) + if (*smime_cryptalg) m_strreplace(&SmimeCryptAlg, smime_cryptalg); - if ((WithCrypto & APPLICATION_PGP) && (set_signas || *pgp_sign_as)) + if (set_signas || *pgp_sign_as) m_strreplace(&PgpSignAs, pgp_sign_as); return pgp; @@ -533,10 +527,10 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr, /* decrypt pgp/mime encoded messages */ - if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME) & hdr->security) - && mutt_is_multipart_encrypted (newhdr->content)) { - int ccap = - WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME) & hdr->security; + if ((APPLICATION_PGP | APPLICATION_SMIME) & hdr->security + && mutt_is_multipart_encrypted (newhdr->content)) + { + int ccap = (APPLICATION_PGP | APPLICATION_SMIME) & hdr->security; newhdr->security |= ENCRYPT | ccap; if (!crypt_valid_passphrase (ccap)) goto err; @@ -568,15 +562,13 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr, * resending messages */ - if (WithCrypto && mutt_is_multipart_signed (newhdr->content)) { + if (mutt_is_multipart_signed (newhdr->content)) { newhdr->security |= SIGN; - if ((WithCrypto & APPLICATION_PGP) - && - ascii_strcasecmp (mutt_get_parameter + if (ascii_strcasecmp (mutt_get_parameter ("protocol", newhdr->content->parameter), "application/pgp-signature") == 0) newhdr->security |= APPLICATION_PGP; - else if ((WithCrypto & APPLICATION_SMIME)) + else newhdr->security |= APPLICATION_SMIME; /* destroy the signature */ @@ -638,8 +630,7 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr, goto bail; - if ((WithCrypto & APPLICATION_PGP) - && (mutt_is_application_pgp (b) & (ENCRYPT | SIGN))) { + if (mutt_is_application_pgp (b) & (ENCRYPT | SIGN)) { mutt_body_handler (b, &s); @@ -668,12 +659,9 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr, /* Fix encryption flags. */ /* No inline if multipart. */ - if (WithCrypto && (newhdr->security & INLINE) && newhdr->content->next) + if ((newhdr->security & INLINE) && newhdr->content->next) newhdr->security &= ~INLINE; - /* Do we even support multiple mechanisms? */ - newhdr->security &= WithCrypto | ~(APPLICATION_PGP | APPLICATION_SMIME); - /* Theoretically, both could be set. Take the one the user wants to set by default. */ if ((newhdr->security & APPLICATION_PGP) && (newhdr->security & APPLICATION_SMIME)) { diff --git a/recvattach.c b/recvattach.c index 91428f1..fcad491 100644 --- a/recvattach.c +++ b/recvattach.c @@ -138,8 +138,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m, && (compose || (parent_type == -1 && ascii_strcasecmp ("alternative", m->subtype))) - && (!(WithCrypto & APPLICATION_PGP) - || !mutt_is_multipart_encrypted (m)) + && (!mutt_is_multipart_encrypted (m)) ) { idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level, @@ -156,14 +155,12 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m, new->level = level; /* We don't support multipart messages in the compose menu yet */ - if (!compose && !m->collapsed && - ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP) - || !mutt_is_multipart_encrypted (m)) - ) - || mutt_is_message_type (m->type, m->subtype))) { - idx = - mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, - level + 1, compose); + if (!compose && !m->collapsed + && ((m->type == TYPEMULTIPART && !mutt_is_multipart_encrypted(m)) + || mutt_is_message_type (m->type, m->subtype))) + { + idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, + level + 1, compose); } } } @@ -841,8 +838,7 @@ mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr, break; /* functions which are passed through from the pager */ case OP_CHECK_TRADITIONAL: - if (!(WithCrypto & APPLICATION_PGP) - || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) { + if (hdr && hdr->security & PGP_TRADITIONAL_CHECKED) { op = OP_NULL; break; } @@ -930,17 +926,16 @@ void mutt_view_attachments (HEADER * hdr) return; - if (WithCrypto && ((hdr->security & ENCRYPT) || - (mutt_is_application_smime (hdr->content) & - SMIMEOPAQUE))) { + if ((hdr->security & ENCRYPT) || + (mutt_is_application_smime (hdr->content) & SMIMEOPAQUE)) + { need_secured = 1; if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) { mx_close_message (&msg); return; } - if ((WithCrypto & APPLICATION_SMIME) - && (hdr->security & APPLICATION_SMIME)) { + if (hdr->security & APPLICATION_SMIME) { if (hdr->env) crypt_smime_getkeys (hdr->env); @@ -964,7 +959,7 @@ void mutt_view_attachments (HEADER * hdr) else need_secured = 0; } - if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) { + if (hdr->security & APPLICATION_PGP) { if (mutt_is_multipart_encrypted (hdr->content)) secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur); else @@ -979,7 +974,7 @@ void mutt_view_attachments (HEADER * hdr) } } - if (!WithCrypto || !need_secured) { + if (!need_secured) { fp = msg->fp; cur = hdr->content; } @@ -1038,21 +1033,19 @@ void mutt_view_attachments (HEADER * hdr) break; case OP_EXTRACT_KEYS: - if ((WithCrypto & APPLICATION_PGP)) { - crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix, - menu-> - tagprefix ? cur : - idx[menu->current]-> - content); - menu->redraw = REDRAW_FULL; - } + crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix, + menu-> + tagprefix ? cur : + idx[menu->current]-> + content); + menu->redraw = REDRAW_FULL; break; case OP_CHECK_TRADITIONAL: - if ((WithCrypto & APPLICATION_PGP) - && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur + if (crypt_pgp_check_traditional (fp, menu->tagprefix ? cur : idx[menu->current]->content, - menu->tagprefix)) { + menu->tagprefix)) + { hdr->security = crypt_query (cur); menu->redraw = REDRAW_FULL; } @@ -1103,10 +1096,9 @@ void mutt_view_attachments (HEADER * hdr) } #endif - if (WithCrypto && (hdr->security & (~PGP_TRADITIONAL_CHECKED))) { + if (hdr->security & (~PGP_TRADITIONAL_CHECKED)) { mutt_message - _ - ("Deletion of attachments from encrypted messages is unsupported."); + _("Deletion of attachments from encrypted messages is unsupported."); } else { if (!menu->tagprefix) { @@ -1252,7 +1244,7 @@ void mutt_view_attachments (HEADER * hdr) p_delete(&idx); idxmax = 0; - if (WithCrypto && need_secured && secured) { + if (need_secured && secured) { fclose (fp); mutt_free_body (&cur); } diff --git a/send.c b/send.c index 7b4b9bc..8ba9c3c 100644 --- a/send.c +++ b/send.c @@ -396,7 +396,7 @@ static int include_forward (CONTEXT * ctx, HEADER * cur, FILE * out) mutt_parse_mime_message (ctx, cur); mutt_message_hook (ctx, cur, M_MESSAGEHOOK); - if (WithCrypto && (cur->security & ENCRYPT) && option (OPTFORWDECODE)) { + if ((cur->security & ENCRYPT) && option (OPTFORWDECODE)) { /* make sure we have the user's passphrase before proceeding... */ crypt_valid_passphrase (cur->security); } @@ -445,7 +445,7 @@ static int include_reply (CONTEXT * ctx, HEADER * cur, FILE * out) int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV | M_CM_REPLYING; int chflags = CH_DECODE; - if (WithCrypto && (cur->security & ENCRYPT)) { + if ((cur->security & ENCRYPT)) { /* make sure we have the user's passphrase before proceeding... */ crypt_valid_passphrase (cur->security); } @@ -855,12 +855,10 @@ static int generate_body (FILE * tempfp, /* stream for outgoing message * else if (i == -1) return -1; } - /* if (WithCrypto && (flags & SENDKEY)) */ - else if ((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY)) { + else if (flags & SENDKEY) { BODY *tmp; - if ((WithCrypto & APPLICATION_PGP) - && (tmp = crypt_pgp_make_key_attachment (NULL)) == NULL) + if ((tmp = crypt_pgp_make_key_attachment (NULL)) == NULL) return -1; tmp->next = msg->content; @@ -1128,7 +1126,7 @@ int ci_send_message (int flags, /* send mode */ } - if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED)) + if (flags & SENDPOSTPONED) signas = m_strdup(PgpSignAs); /* Delay expansion of aliases until absolutely necessary--shouldn't @@ -1333,7 +1331,7 @@ int ci_send_message (int flags, /* send mode */ * can take effect. */ - if (WithCrypto && !(flags & SENDMAILX)) { + if (!(flags & SENDMAILX)) { if (option (OPTCRYPTAUTOSIGN)) msg->security |= SIGN; if (option (OPTCRYPTAUTOENCRYPT)) @@ -1345,7 +1343,7 @@ int ci_send_message (int flags, /* send mode */ if (option (OPTCRYPTREPLYSIGNENCRYPTED) && cur && (cur->security & ENCRYPT)) msg->security |= SIGN; - if (WithCrypto & APPLICATION_PGP && (msg->security & (ENCRYPT | SIGN))) { + if (msg->security & (ENCRYPT | SIGN)) { if (option (OPTPGPAUTOINLINE)) msg->security |= INLINE; if (option (OPTPGPREPLYINLINE) && cur && (cur->security & INLINE)) @@ -1353,7 +1351,7 @@ int ci_send_message (int flags, /* send mode */ } } - if (WithCrypto && msg->security) { + if (msg->security) { /* * When reypling / forwarding, use the original message's * crypto system. According to the documentation, @@ -1364,11 +1362,9 @@ int ci_send_message (int flags, /* send mode */ * disable individual mechanisms at run-time? */ if (cur) { - if ((WithCrypto & APPLICATION_PGP) && option (OPTCRYPTAUTOPGP) - && (cur->security & APPLICATION_PGP)) + if (option (OPTCRYPTAUTOPGP) && (cur->security & APPLICATION_PGP)) msg->security |= APPLICATION_PGP; - else if ((WithCrypto & APPLICATION_SMIME) - && option (OPTCRYPTAUTOSMIME) + else if (option (OPTCRYPTAUTOSMIME) && (cur->security & APPLICATION_SMIME)) msg->security |= APPLICATION_SMIME; } @@ -1378,13 +1374,11 @@ int ci_send_message (int flags, /* send mode */ * for the decision. */ if (!(msg->security & (APPLICATION_SMIME | APPLICATION_PGP))) { - if ((WithCrypto & APPLICATION_SMIME) && option (OPTCRYPTAUTOSMIME) - && option (OPTSMIMEISDEFAULT)) + if (option (OPTCRYPTAUTOSMIME) && option (OPTSMIMEISDEFAULT)) msg->security |= APPLICATION_SMIME; - else if ((WithCrypto & APPLICATION_PGP) && option (OPTCRYPTAUTOPGP)) + else if (option (OPTCRYPTAUTOPGP)) msg->security |= APPLICATION_PGP; - else if ((WithCrypto & APPLICATION_SMIME) - && option (OPTCRYPTAUTOSMIME)) + else if (option (OPTCRYPTAUTOSMIME)) msg->security |= APPLICATION_SMIME; } } @@ -1407,7 +1401,7 @@ int ci_send_message (int flags, /* send mode */ && !(flags & (SENDRESEND | SENDPOSTPONED))) msg->env->from->personal = m_strdup(Realname); - if (!((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY))) + if (!(flags & SENDKEY)) safe_fclose (&tempfp); if (flags & SENDMAILX) { @@ -1634,38 +1628,36 @@ int ci_send_message (int flags, /* send mode */ clear_content = NULL; free_clear_content = 0; - if (WithCrypto) { - if (msg->security) { - /* save the decrypted attachments */ - clear_content = msg->content; + if (msg->security) { + /* save the decrypted attachments */ + clear_content = msg->content; - if ((crypt_get_keys (msg, &pgpkeylist) == -1) || - mutt_protect (msg, pgpkeylist) == -1) { - msg->content = mutt_remove_multipart (msg->content); + if ((crypt_get_keys (msg, &pgpkeylist) == -1) || + mutt_protect (msg, pgpkeylist) == -1) { + msg->content = mutt_remove_multipart (msg->content); - p_delete(&pgpkeylist); + p_delete(&pgpkeylist); - decode_descriptions (msg->content); - goto main_loop; - } - encode_descriptions (msg->content, 0); + decode_descriptions (msg->content); + goto main_loop; } + encode_descriptions (msg->content, 0); + } - /* - * at this point, msg->content is one of the following three things: - * - multipart/signed. In this case, clear_content is a child. - * - multipart/encrypted. In this case, clear_content exists - * independently - * - application/pgp. In this case, clear_content exists independently. - * - something else. In this case, it's the same as clear_content. - */ + /* + * at this point, msg->content is one of the following three things: + * - multipart/signed. In this case, clear_content is a child. + * - multipart/encrypted. In this case, clear_content exists + * independently + * - application/pgp. In this case, clear_content exists independently. + * - something else. In this case, it's the same as clear_content. + */ - /* This is ugly -- lack of "reporting back" from mutt_protect(). */ + /* This is ugly -- lack of "reporting back" from mutt_protect(). */ - if (clear_content && (msg->content != clear_content) - && (msg->content->parts != clear_content)) - free_clear_content = 1; - } + if (clear_content && (msg->content != clear_content) + && (msg->content->parts != clear_content)) + free_clear_content = 1; if (!option (OPTNOCURSES) && !(flags & SENDMAILX)) mutt_message _("Sending message..."); @@ -1696,14 +1688,14 @@ int ci_send_message (int flags, /* send mode */ BODY *save_sig = NULL; BODY *save_parts = NULL; - if (WithCrypto && msg->security && option (OPTFCCCLEAR)) + if (msg->security && option (OPTFCCCLEAR)) msg->content = clear_content; /* check to see if the user wants copies of all attachments */ if (!option (OPTFCCATTACH) && msg->content->type == TYPEMULTIPART) { - if (WithCrypto - && (m_strcmp(msg->content->subtype, "encrypted") == 0 || - m_strcmp(msg->content->subtype, "signed") == 0)) { + if ((m_strcmp(msg->content->subtype, "encrypted") == 0 || + m_strcmp(msg->content->subtype, "signed") == 0)) + { if (clear_content->type == TYPEMULTIPART) { if (!(msg->security & ENCRYPT) && (msg->security & SIGN)) { /* save initial signature and attachments */ @@ -1747,7 +1739,7 @@ int ci_send_message (int flags, /* send mode */ msg->content = tmpbody; - if (WithCrypto && save_sig) { + if (save_sig) { /* cleanup the second signature structures */ if (save_content->parts) { mutt_free_body (&save_content->parts->next); @@ -1759,7 +1751,7 @@ int ci_send_message (int flags, /* send mode */ msg->content->parts->next = save_sig; msg->content->parts->parts->next = save_parts; } - else if (WithCrypto && save_content) { + else if (save_content) { /* destroy the new encrypted body. */ mutt_free_body (&save_content); } @@ -1774,10 +1766,9 @@ int ci_send_message (int flags, /* send mode */ */ if (fcc_error || (i = send_message (msg)) == -1) { if (!(flags & SENDBATCH)) { - if (!WithCrypto); - else if ((msg->security & ENCRYPT) || ((msg->security & SIGN) - && msg->content->type == - TYPEAPPLICATION)) { + if ((msg->security & ENCRYPT) + || ((msg->security & SIGN) + && msg->content->type == TYPEAPPLICATION)) { mutt_free_body (&msg->content); /* destroy PGP data */ msg->content = clear_content; /* restore clear text. */ } @@ -1806,10 +1797,10 @@ int ci_send_message (int flags, /* send mode */ _("Mail sent.")); #endif - if (WithCrypto && (msg->security & ENCRYPT)) + if (msg->security & ENCRYPT) p_delete(&pgpkeylist); - if (WithCrypto && free_clear_content) + if (free_clear_content) mutt_free_body (&clear_content); if (flags & SENDREPLY) { @@ -1827,7 +1818,7 @@ int ci_send_message (int flags, /* send mode */ cleanup: - if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED)) { + if (flags & SENDPOSTPONED) { if (signas) { p_delete(&PgpSignAs); PgpSignAs = signas; diff --git a/sendlib.c b/sendlib.c index 761054b..fc8462d 100644 --- a/sendlib.c +++ b/sendlib.c @@ -363,9 +363,7 @@ int mutt_write_mime_header (BODY * a, FILE * f) return (ferror (f) ? -1 : 0); } -# define write_as_text_part(a) (mutt_is_text_part(a) \ - || ((WithCrypto & APPLICATION_PGP)\ - && mutt_is_application_pgp(a))) +# define write_as_text_part(a) (mutt_is_text_part(a) || mutt_is_application_pgp(a)) int mutt_write_mime_body (BODY * a, FILE * f) { @@ -398,9 +396,7 @@ int mutt_write_mime_body (BODY * a, FILE * f) } /* This is pretty gross, but it's the best solution for now... */ - if ((WithCrypto & APPLICATION_PGP) - && a->type == TYPEAPPLICATION - && m_strcmp(a->subtype, "pgp-encrypted") == 0) { + if (a->type == TYPEAPPLICATION && !m_strcmp(a->subtype, "pgp-encrypted")) { fputs ("Version: 1\n", f); return 0; } @@ -1180,14 +1176,12 @@ BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg) BODY *body; FILE *fp; int cmflags, chflags; - int pgp = WithCrypto ? hdr->security : 0; + int pgp = hdr->security; - if (WithCrypto) { - if ((option (OPTMIMEFORWDECODE) || option (OPTFORWDECRYPT)) && - (hdr->security & ENCRYPT)) { - if (!crypt_valid_passphrase (hdr->security)) - return (NULL); - } + if ((option (OPTMIMEFORWDECODE) || option (OPTFORWDECRYPT)) && + (hdr->security & ENCRYPT)) { + if (!crypt_valid_passphrase (hdr->security)) + return (NULL); } mutt_mktemp (buffer); @@ -1212,26 +1206,20 @@ BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg) if (!attach_msg && option (OPTMIMEFORWDECODE)) { chflags |= CH_MIME | CH_TXTPLAIN; cmflags = M_CM_DECODE | M_CM_CHARCONV; - if ((WithCrypto & APPLICATION_PGP)) - pgp &= ~PGPENCRYPT; - if ((WithCrypto & APPLICATION_SMIME)) - pgp &= ~SMIMEENCRYPT; + pgp &= ~(PGPENCRYPT|SMIMEENCRYPT); } - else if (WithCrypto && option (OPTFORWDECRYPT) && (hdr->security & ENCRYPT)) { - if ((WithCrypto & APPLICATION_PGP) - && mutt_is_multipart_encrypted (hdr->content)) { + else if (option (OPTFORWDECRYPT) && (hdr->security & ENCRYPT)) { + if (mutt_is_multipart_encrypted (hdr->content)) { chflags |= CH_MIME | CH_NONEWLINE; cmflags = M_CM_DECODE_PGP; pgp &= ~PGPENCRYPT; } - else if ((WithCrypto & APPLICATION_PGP) - && (mutt_is_application_pgp (hdr->content) & PGPENCRYPT)) { + else if (mutt_is_application_pgp (hdr->content) & PGPENCRYPT) { chflags |= CH_MIME | CH_TXTPLAIN; cmflags = M_CM_DECODE | M_CM_CHARCONV; pgp &= ~PGPENCRYPT; } - else if ((WithCrypto & APPLICATION_SMIME) - && mutt_is_application_smime (hdr->content) & SMIMEENCRYPT) { + else if (mutt_is_application_smime (hdr->content) & SMIMEENCRYPT) { chflags |= CH_MIME | CH_TXTPLAIN; cmflags = M_CM_DECODE | M_CM_CHARCONV; pgp &= ~SMIMEENCRYPT; @@ -1247,8 +1235,7 @@ BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg) body->hdr->offset = 0; /* we don't need the user headers here */ body->hdr->env = mutt_read_rfc822_header (fp, body->hdr, 0, 0); - if (WithCrypto) - body->hdr->security = pgp; + body->hdr->security = pgp; mutt_update_encoding (body); body->parts = body->hdr->content; @@ -2397,8 +2384,7 @@ int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid, /* (postponment) if the mail is to be signed or encrypted, save this info */ - if ((WithCrypto & APPLICATION_PGP) - && post && (hdr->security & APPLICATION_PGP)) { + if (post && (hdr->security & APPLICATION_PGP)) { fputs ("X-Mutt-PGP: ", msg->fp); if (hdr->security & ENCRYPT) fputc ('E', msg->fp); @@ -2413,8 +2399,7 @@ int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid, } /* (postponment) if the mail is to be signed or encrypted, save this info */ - if ((WithCrypto & APPLICATION_SMIME) - && post && (hdr->security & APPLICATION_SMIME)) { + if (post && (hdr->security & APPLICATION_SMIME)) { fputs ("X-Mutt-SMIME: ", msg->fp); if (hdr->security & ENCRYPT) { fputc ('E', msg->fp); diff --git a/smime.c b/smime.c index 804ba95..e9f64f1 100644 --- a/smime.c +++ b/smime.c @@ -49,8 +49,6 @@ # include #endif -#ifdef CRYPT_BACKEND_CLASSIC_SMIME - #include "mutt_crypt.h" struct smime_command_context { @@ -1880,12 +1878,8 @@ int smime_send_menu (HEADER * msg, int *redraw) { char *p; - if (!(WithCrypto & APPLICATION_SMIME)) - return msg->security; - switch (mutt_multi_choice - (_ - ("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear? "), + (_("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear? "), _("eswabfc"))) { case 1: /* (e)ncrypt */ msg->security |= ENCRYPT; @@ -2001,6 +1995,3 @@ int smime_send_menu (HEADER * msg, int *redraw) return (msg->security); } - - -#endif /* CRYPT_BACKEND_CLASSIC_SMIME */ diff --git a/smime.h b/smime.h index e344a11..dbf9a3f 100644 --- a/smime.h +++ b/smime.h @@ -8,14 +8,9 @@ * please see the file GPL in the top level source directory. */ -#ifdef CRYPT_BACKEND_CLASSIC_SMIME #include "mutt_crypt.h" - - - - void smime_void_passphrase (void); int smime_valid_passphrase (void); @@ -45,5 +40,3 @@ char *smime_findKeys (address_t * to, address_t * cc, address_t * bcc); void smime_invoke_import (char *, char *); int smime_send_menu (HEADER * msg, int *redraw); - -#endif -- 2.20.1