From: Pierre Habouzit Date: Mon, 2 Apr 2007 22:22:44 +0000 (+0200) Subject: Even remove more code. X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=82589516e2473b5451218d7b00a9dfbc3e18f3ca Even remove more code. Signed-off-by: Pierre Habouzit --- diff --git a/attach.c b/attach.c index d42e47a..db791f5 100644 --- a/attach.c +++ b/attach.c @@ -370,9 +370,6 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, int pagerfd = -1; is_message = mutt_is_message_type(a); - if (is_message && a->hdr && (a->hdr->security & ENCRYPT) && - !crypt_valid_passphrase (a->hdr->security)) - return (rc); use_mailcap = (flag == M_MAILCAP || (flag == M_REGULAR && rfc1524_mailcap_isneeded(a))); snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype); diff --git a/commands.c b/commands.c index c7fc7a5..f5b4d43 100644 --- a/commands.c +++ b/commands.c @@ -93,9 +93,6 @@ int mutt_display_message (HEADER * cur) if (cur->security & ENCRYPT) { if (cur->security & APPLICATION_SMIME) crypt_smime_getkeys (cur->env); - if (!crypt_valid_passphrase (cur->security)) - return 0; - cmflags |= M_CM_VERIFY; } else if (cur->security & SIGN) { @@ -301,8 +298,6 @@ static void pipe_msg (HEADER * h, FILE * fp, int decode, int print) pipe_set_flags (decode, print, &cmflags, &chflags); if (decode && h->security & ENCRYPT) { - if (!crypt_valid_passphrase (h->security)) - return; endwin (); } @@ -335,8 +330,6 @@ static int _mutt_pipe_message(HEADER * h, char *cmd, int decode, int print, if (decode) { mutt_parse_mime_message (Context, h); - if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security)) - return 1; } mutt_endwin (NULL); @@ -358,10 +351,6 @@ static int _mutt_pipe_message(HEADER * h, char *cmd, int decode, int print, mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK); mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]); - if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT && - !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]-> - security)) - return 1; } } @@ -713,10 +702,6 @@ int mutt_save_message (HEADER * h, int delete, if (mutt_save_confirm (buf, &st) != 0) return -1; - if (need_passphrase && (decode || decrypt) - && !crypt_valid_passphrase (app)) - return -1; - mutt_message (_("Copying to %s..."), buf); if (Context->magic == M_IMAP && !(decode || decrypt) && mx_get_magic (buf) == M_IMAP) { diff --git a/compose.c b/compose.c index 7660a45..22af265 100644 --- a/compose.c +++ b/compose.c @@ -1268,10 +1268,6 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ mutt_message_hook (NULL, msg, M_SEND2HOOK); break; - case OP_FORGET_PASSPHRASE: - crypt_forget_passphrase (); - break; - case OP_COMPOSE_SMIME_MENU: if (msg->security & APPLICATION_PGP) { if (mutt_yesorno (_("PGP already selected. Clear & continue ? "), diff --git a/lib-crypt/Makefile.am b/lib-crypt/Makefile.am index b379b47..ab296ba 100644 --- a/lib-crypt/Makefile.am +++ b/lib-crypt/Makefile.am @@ -1,7 +1,7 @@ noinst_LIBRARIES = libcrypt.a -libcrypt_a_SOURCES = smime.h crypt.h crypt-mod.h \ - smime.c crypt.c crypt-mod.c \ +libcrypt_a_SOURCES = crypt.h crypt-mod.h \ + crypt.c crypt-mod.c \ cryptglue.c \ crypt-gpgme.h crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c diff --git a/lib-crypt/crypt-mod-pgp-gpgme.c b/lib-crypt/crypt-mod-pgp-gpgme.c index d0e4851..da506f2 100644 --- a/lib-crypt/crypt-mod-pgp-gpgme.c +++ b/lib-crypt/crypt-mod-pgp-gpgme.c @@ -14,23 +14,10 @@ #include #include "crypt-gpgme.h" -static void crypt_mod_pgp_void_passphrase (void) -{ - /* Handled by gpg-agent. */ -} - -static int crypt_mod_pgp_valid_passphrase (void) -{ - /* Handled by gpg-agent. */ - return 1; -} - struct crypt_module_specs crypt_mod_pgp_gpgme = { APPLICATION_PGP, { /* Common. */ pgp_gpgme_init, - crypt_mod_pgp_void_passphrase, - crypt_mod_pgp_valid_passphrase, pgp_gpgme_decrypt_mime, pgp_gpgme_application_handler, pgp_gpgme_encrypted_handler, diff --git a/lib-crypt/crypt-mod-smime-gpgme.c b/lib-crypt/crypt-mod-smime-gpgme.c index 7ee8951..5396b28 100644 --- a/lib-crypt/crypt-mod-smime-gpgme.c +++ b/lib-crypt/crypt-mod-smime-gpgme.c @@ -21,17 +21,6 @@ static void crypt_mod_smime_init (void) smime_gpgme_init (); } -static void crypt_mod_smime_void_passphrase (void) -{ - /* Handled by gpg-agent. */ -} - -static int crypt_mod_smime_valid_passphrase (void) -{ - /* Handled by gpg-agent. */ - return 1; -} - static int crypt_mod_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d) { @@ -78,8 +67,6 @@ static int crypt_mod_smime_verify_sender (HEADER * h) struct crypt_module_specs crypt_mod_smime_gpgme = { APPLICATION_SMIME, { crypt_mod_smime_init, - crypt_mod_smime_void_passphrase, - crypt_mod_smime_valid_passphrase, crypt_mod_smime_decrypt_mime, crypt_mod_smime_application_handler, NULL, /* encrypted_handler */ diff --git a/lib-crypt/crypt-mod.h b/lib-crypt/crypt-mod.h index c74081e..6e6a1c3 100644 --- a/lib-crypt/crypt-mod.h +++ b/lib-crypt/crypt-mod.h @@ -13,12 +13,7 @@ #include #include "crypt.h" -/* - Type defintions for crypto module functions. - */ -typedef void (*crypt_func_void_passphrase_t) (void); -typedef int (*crypt_func_valid_passphrase_t) (void); - +/* Type defintions for crypto module functions. */ typedef int (*crypt_func_decrypt_mime_t) (FILE * a, FILE ** b, BODY * c, BODY ** d); @@ -64,8 +59,6 @@ typedef void (*crypt_func_init_t) (void); typedef struct crypt_module_functions { /* Common/General functions. */ crypt_func_init_t init; - crypt_func_void_passphrase_t void_passphrase; - crypt_func_valid_passphrase_t valid_passphrase; crypt_func_decrypt_mime_t decrypt_mime; crypt_func_application_handler_t application_handler; crypt_func_encrypted_handler_t encrypted_handler; diff --git a/lib-crypt/crypt.c b/lib-crypt/crypt.c index f8cf471..8ccac11 100644 --- a/lib-crypt/crypt.c +++ b/lib-crypt/crypt.c @@ -52,16 +52,6 @@ void crypt_current_time (STATE * s, const char *app_name) state_attach_puts (tmp, s); } - - -void crypt_forget_passphrase (void) -{ - crypt_pgp_void_passphrase (); - crypt_smime_void_passphrase (); - mutt_message _("Passphrase(s) forgotten."); -} - - #if defined(HAVE_SETRLIMIT) static void disable_coredumps (void) @@ -77,26 +67,6 @@ static void disable_coredumps (void) #endif /* HAVE_SETRLIMIT */ - -int crypt_valid_passphrase (int flags) -{ - int ret = 0; - -# if defined(HAVE_SETRLIMIT) - disable_coredumps (); -# endif - - if (flags & APPLICATION_PGP) - ret = crypt_pgp_valid_passphrase (); - - if (flags & APPLICATION_SMIME) - ret = crypt_smime_valid_passphrase (); - - return ret; -} - - - int mutt_protect (HEADER * msg, char *keylist) { BODY *pbody = NULL, *tmp_pbody = NULL; @@ -105,9 +75,6 @@ int mutt_protect (HEADER * msg, char *keylist) int flags = msg->security; int i; - if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security)) - return (-1); - if ((msg->security & PGPINLINE) == PGPINLINE) { /* they really want to send it inline... go for it */ if (!isendwin ()) @@ -339,13 +306,6 @@ void crypt_extract_keys_from_messages (HEADER * h) for (i = 0; i < Context->vcount; i++) { if (Context->hdrs[Context->v2r[i]]->tagged) { mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]); - if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT && - !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]-> - security)) { - m_fclose(&fpout); - break; - } - 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); @@ -384,31 +344,29 @@ 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 (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 (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 (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); - else - mutt_copy_message (fpout, Context, h, 0, 0); - - fflush (fpout); - if (h->env->from) - tmp = mutt_expand_aliases (h->env->from); - else if (h->env->sender) - tmp = mutt_expand_aliases (h->env->sender); - mbox = tmp ? tmp->mailbox : NULL; - if (mbox) { /* else ? */ - mutt_message (_("Trying to extract S/MIME certificates...\n")); - crypt_smime_invoke_import (tempfname, mbox); - } + 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); + else + mutt_copy_message (fpout, Context, h, 0, 0); + + fflush (fpout); + if (h->env->from) + tmp = mutt_expand_aliases (h->env->from); + else if (h->env->sender) + tmp = mutt_expand_aliases (h->env->sender); + mbox = tmp ? tmp->mailbox : NULL; + if (mbox) { /* else ? */ + mutt_message (_("Trying to extract S/MIME certificates...\n")); + crypt_smime_invoke_import (tempfname, mbox); } } } diff --git a/lib-crypt/crypt.h b/lib-crypt/crypt.h index f9dc9a7..45cb952 100644 --- a/lib-crypt/crypt.h +++ b/lib-crypt/crypt.h @@ -106,25 +106,11 @@ void crypt_extract_keys_from_messages (HEADER * h); Return the list of keys in KEYLIST. */ int crypt_get_keys (HEADER * msg, char **keylist); -/* Forget a passphrase and display a message. */ -void crypt_forget_passphrase (void); - -/* Check that we have a usable passphrase, ask if not. */ -int crypt_valid_passphrase (int); - - /*-- cryptglue.c --*/ /* Show a message that a backend will be invoked. */ void crypt_invoke_message (int type); - -/* Silently forget about a passphrase. */ -void crypt_pgp_void_passphrase (void); - -int crypt_pgp_valid_passphrase (void); - - /* Decrypt a PGP/MIME message. */ int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d); @@ -180,14 +166,6 @@ void crypt_pgp_extract_keys_from_attachment_list (FILE * fp, int tag, BODY * top); - - - -/* Silently forget about a passphrase. */ -void crypt_smime_void_passphrase (void); - -int crypt_smime_valid_passphrase (void); - /* Decrypt an S/MIME message. */ int crypt_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d); diff --git a/lib-crypt/cryptglue.c b/lib-crypt/cryptglue.c index 79fc246..046e777 100644 --- a/lib-crypt/cryptglue.c +++ b/lib-crypt/cryptglue.c @@ -60,22 +60,6 @@ void crypt_invoke_message (int type) */ -/* Reset a PGP passphrase */ -void crypt_pgp_void_passphrase (void) -{ - if (CRYPT_MOD_CALL_CHECK (PGP, void_passphrase)) - (CRYPT_MOD_CALL (PGP, void_passphrase)) (); -} - -int crypt_pgp_valid_passphrase (void) -{ - if (CRYPT_MOD_CALL_CHECK (PGP, valid_passphrase)) - return (CRYPT_MOD_CALL (PGP, valid_passphrase)) (); - - return 0; -} - - /* Decrypt a PGP/MIME message. */ int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d) { @@ -209,21 +193,6 @@ void crypt_pgp_extract_keys_from_attachment_list (FILE * fp, int tag, */ -/* Reset an SMIME passphrase */ -void crypt_smime_void_passphrase (void) -{ - if (CRYPT_MOD_CALL_CHECK (SMIME, void_passphrase)) - (CRYPT_MOD_CALL (SMIME, void_passphrase)) (); -} - -int crypt_smime_valid_passphrase (void) -{ - if (CRYPT_MOD_CALL_CHECK (SMIME, valid_passphrase)) - return (CRYPT_MOD_CALL (SMIME, valid_passphrase)) (); - - return 0; -} - /* Decrypt am S/MIME message. */ int crypt_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d) { diff --git a/lib-crypt/pgp.c b/lib-crypt/pgp.c index 8db2a5d..abab102 100644 --- a/lib-crypt/pgp.c +++ b/lib-crypt/pgp.c @@ -609,10 +609,8 @@ static void pgp_extract_keys_from_attachment (FILE * fp, BODY * top) m_fclose(&tempfp); - if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_import)) { - (CRYPT_MOD_CALL (PGP, pgp_invoke_import)) (fname); - mutt_any_key_to_continue (NULL); - } + pgp_invoke_import (tempfname); + mutt_any_key_to_continue (NULL); mutt_unlink (tempfname); } diff --git a/lib-crypt/pgp.h b/lib-crypt/pgp.h index 669fc4e..86fba30 100644 --- a/lib-crypt/pgp.h +++ b/lib-crypt/pgp.h @@ -38,13 +38,9 @@ pgp_key_t pgp_getkeybystr (const char *, short, pgp_ring_t); char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc); -void pgp_forget_passphrase (void); int pgp_application_pgp_handler (BODY *, STATE *); int pgp_encrypted_handler (BODY *, STATE *); void pgp_extract_keys_from_attachment_list (FILE * fp, int tag, BODY * top); -void pgp_void_passphrase (void); -int pgp_valid_passphrase (void); - /* The PGP invocation interface - not really beautiful. */ diff --git a/lib-crypt/smime.h b/lib-crypt/smime.h index 452946f..f127e06 100644 --- a/lib-crypt/smime.h +++ b/lib-crypt/smime.h @@ -11,9 +11,6 @@ #include "crypt.h" -void smime_void_passphrase (void); -int smime_valid_passphrase (void); - int smime_decrypt_mime (FILE *, FILE **, BODY *, BODY **); int smime_application_smime_handler (BODY *, STATE *); diff --git a/lib-ui/curs_main.c b/lib-ui/curs_main.c index 5abbf49..bf3c5a1 100644 --- a/lib-ui/curs_main.c +++ b/lib-ui/curs_main.c @@ -1994,11 +1994,6 @@ int mutt_index_menu (void) menu->redraw = REDRAW_FULL; break; - - case OP_FORGET_PASSPHRASE: - crypt_forget_passphrase (); - break; - case OP_GROUP_REPLY: CHECK_MSGCOUNT; diff --git a/pager.c b/pager.c index 3f1db6e..be51928 100644 --- a/pager.c +++ b/pager.c @@ -2478,11 +2478,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) redraw = REDRAW_FULL; break; - - case OP_FORGET_PASSPHRASE: - crypt_forget_passphrase (); - break; - case OP_EXTRACT_KEYS: CHECK_MODE (IsHeader (extra)); crypt_extract_keys_from_messages (extra->hdr); diff --git a/pattern.c b/pattern.c index eb58688..8d0e4ba 100644 --- a/pattern.c +++ b/pattern.c @@ -152,17 +152,6 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) if (pat->op != M_HEADER) { mutt_parse_mime_message (ctx, h); - - if ((h->security & ENCRYPT) && !crypt_valid_passphrase (h->security)) - { - mx_close_message (&msg); - if (fp) { - m_fclose(&fp); - unlink (tempfile); - } - return (0); - } - fseeko (msg->fp, h->offset, 0); mutt_body_handler (h->content, &s); } diff --git a/postpone.c b/postpone.c index 165438d..7f5aff1 100644 --- a/postpone.c +++ b/postpone.c @@ -508,9 +508,6 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr, { int ccap = (APPLICATION_PGP | APPLICATION_SMIME) & hdr->security; newhdr->security |= ENCRYPT | ccap; - if (!crypt_valid_passphrase (ccap)) - goto err; - mutt_message _("Decrypting message..."); if (((ccap & APPLICATION_PGP) diff --git a/recvattach.c b/recvattach.c index 198bfa7..ef8fc18 100644 --- a/recvattach.c +++ b/recvattach.c @@ -825,10 +825,6 @@ void mutt_view_attachments (HEADER * hdr) { need_secured = 1; - if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) { - mx_close_message (&msg); - return; - } if (hdr->security & APPLICATION_SMIME) { if (hdr->env) crypt_smime_getkeys (hdr->env); @@ -935,10 +931,6 @@ void mutt_view_attachments (HEADER * hdr) mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu); break; - case OP_FORGET_PASSPHRASE: - crypt_forget_passphrase (); - break; - case OP_EXTRACT_KEYS: crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix, menu-> diff --git a/send.c b/send.c index 3bddf4e..f786e5c 100644 --- a/send.c +++ b/send.c @@ -449,11 +449,6 @@ static int include_forward (CONTEXT * ctx, HEADER * cur, FILE * out) mutt_parse_mime_message (ctx, cur); mutt_message_hook (ctx, cur, M_MESSAGEHOOK); - if ((cur->security & ENCRYPT) && option (OPTFORWDECODE)) { - /* make sure we have the user's passphrase before proceeding... */ - crypt_valid_passphrase (cur->security); - } - mutt_forward_intro (out, cur); if (option (OPTFORWDECODE)) { @@ -498,11 +493,6 @@ 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 ((cur->security & ENCRYPT)) { - /* make sure we have the user's passphrase before proceeding... */ - crypt_valid_passphrase (cur->security); - } - mutt_parse_mime_message (ctx, cur); mutt_message_hook (ctx, cur, M_MESSAGEHOOK); diff --git a/sendlib.c b/sendlib.c index a81949c..152862b 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1107,8 +1107,6 @@ BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg) if ((option (OPTMIMEFORWDECODE) || option (OPTFORWDECRYPT)) && (hdr->security & ENCRYPT)) { - if (!crypt_valid_passphrase (hdr->security)) - return (NULL); } fp = m_tempfile(buffer, sizeof(buffer), NONULL(MCore.tmpdir), NULL);