Gitlab issue #3 exposed an awkward corner case: if mutt is configured
without PGP or S/MIME, and with GPGME, but $crypt_use_gpgme is unset.
In this case, no backend will be available, but WithCrypto will be set
with both APPLICATION_PGP and APPLICATION_SMIME bits.
That will allow various config vars to enable encryption or signing,
even though there will be no backend available to perform them. The
message security flag might then be set, but when the user hits send,
will end up back at the compose menu due to the error.
The pgp or smime menu might not even be available to clear the
security setting!
Add a check in send.c before the compose menu is invoked, and give a
warning message for the menu ops inside the compose menu.
I believe this should prevent the issue. However this is a corner
case combined with user misconfiguration, so I don't believe is worth
a large effort to completely eradicate.
case OP_COMPOSE_PGP_MENU:
if (!(WithCrypto & APPLICATION_PGP))
break;
+ if (!crypt_has_module_backend(APPLICATION_PGP))
+ {
+ mutt_error(_("No PGP backend configured"));
+ break;
+ }
if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME))
{
if (msg->security & (ENCRYPT | SIGN))
case OP_COMPOSE_SMIME_MENU:
if (!(WithCrypto & APPLICATION_SMIME))
break;
+ if (!crypt_has_module_backend(APPLICATION_SMIME))
+ {
+ mutt_error(_("No S/MIME backend configured"));
+ break;
+ }
if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP))
{
mutt_message(_("Invoking S/MIME..."));
}
+/* Returns 1 if a module backend is registered for the type */
+int crypt_has_module_backend(int type)
+{
+ if ((WithCrypto & APPLICATION_PGP) && (type & APPLICATION_PGP) &&
+ crypto_module_lookup(APPLICATION_PGP))
+ {
+ return 1;
+ }
+
+ if ((WithCrypto & APPLICATION_SMIME) && (type & APPLICATION_SMIME) &&
+ crypto_module_lookup(APPLICATION_SMIME))
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
/*
* PGP
*/
int crypt_smime_send_menu(struct Header *msg);
void crypt_init(void);
+/* Returns 1 if a module backend is registered for the type */
+int crypt_has_module_backend(int type);
+
#endif /* _NCRYPT_NCRYPT_H */
msg->security = 0;
}
+ /* Deal with the corner case where the crypto module backend is not available.
+ * This can happen if configured without pgp/smime and with gpgme, but
+ * $crypt_use_gpgme is unset.
+ */
+ if (msg->security && !crypt_has_module_backend(msg->security))
+ {
+ mutt_error(_(
+ "No crypto backend configured. Disabling message security setting."));
+ mutt_sleep(1);
+ msg->security = 0;
+ }
+
/* specify a default fcc. if we are in batchmode, only save a copy of
* the message if the value of $copy is yes or ask-yes */