From 64e3796557cfe91873bc7953c48c1a3d96688f3d Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 25 Jan 2015 18:09:56 -0800 Subject: [PATCH] Remove GPG_AGENT_INFO check for GnuPG 2.1 compatibility. (closes #3715) GnuPG version 2.1 stops exporting the GPG_AGENT_INFO environment variable, so mutt can't check for the presence of that to ensure the agent is running. For GPGME, we can check for the OpenPGP protocol being present. For classic pgp, we have to trust the user setting. This patch is based on the patches sent by CustaiCo and muffins. Thank you both for reporting the problem and creating a patch. --- crypt-gpgme.c | 33 +++++++++++++++++++++------------ init.h | 2 ++ pgp.c | 3 ++- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 94d9db49e..875b580b4 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -4548,27 +4548,36 @@ static void init_common(void) } } -/* Initialization. */ -static void init_gpgme (void) +static void init_pgp (void) { - /* Make sure that gpg-agent is running. */ - if (! getenv ("GPG_AGENT_INFO")) - { - mutt_error (_("\nUsing GPGME backend, although no gpg-agent is running")); - if (mutt_any_key_to_continue (NULL) == -1) - mutt_exit(1); - } + if (gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP) != GPG_ERR_NO_ERROR) + { + mutt_error (_("GPGME: OpenPGP protocol not available")); + if (mutt_any_key_to_continue (NULL) == -1) + mutt_exit(1); + } +} + +static void init_smime (void) +{ + if (gpgme_engine_check_version (GPGME_PROTOCOL_CMS) != GPG_ERR_NO_ERROR) + { + mutt_error (_("GPGME: CMS protocol not available")); + if (mutt_any_key_to_continue (NULL) == -1) + mutt_exit(1); + } } void pgp_gpgme_init (void) { - init_common(); - init_gpgme (); + init_common (); + init_pgp (); } void smime_gpgme_init (void) { - init_common(); + init_common (); + init_smime (); } static int gpgme_send_menu (HEADER *msg, int *redraw, int is_smime) diff --git a/init.h b/init.h index cbd707513..2bcb6700d 100644 --- a/init.h +++ b/init.h @@ -1970,6 +1970,8 @@ struct option_t MuttVars[] = { /* ** .pp ** If \fIset\fP, mutt will use a possibly-running \fCgpg-agent(1)\fP process. + ** Note that as of version 2.1, GnuPG no longer exports GPG_AGENT_INFO, so + ** mutt no longer verifies if the agent is running. ** (PGP only) */ { "pgp_verify_command", DT_STR, R_NONE, UL &PgpVerifyCommand, 0}, diff --git a/pgp.c b/pgp.c index c8ac07fdb..ee9751f02 100644 --- a/pgp.c +++ b/pgp.c @@ -108,7 +108,8 @@ int pgp_use_gpg_agent (void) { char *tty; - if (!option (OPTUSEGPGAGENT) || !getenv ("GPG_AGENT_INFO")) + /* GnuPG 2.1 no longer exports GPG_AGENT_INFO */ + if (!option (OPTUSEGPGAGENT)) return 0; if ((tty = ttyname(0))) -- 2.50.1