As mentioned in the patch, this is based off of CustaiCo and muffins
patch.

Since GnuPG 2.1 no longer exports GPG_AGENT_INFO, mutt shouldn't check
that environment variable and issue an error message (for gpgme) or
disable pgp_use_gpg_agent (for pgp classic).  There may be some other
ways we can verify things, but for now at least, this will allow proper
usage with gpg 2.1.

-Kevin
# HG changeset patch
# User Kevin McCarthy <[email protected]>
# Date 1422238196 28800
#      Sun Jan 25 18:09:56 2015 -0800
# Node ID 102cff54d97ba4369221e59a053c959c5902e49e
# Parent  ec93761e3e129e7ff7d81c892a69c5b2a89a832d
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.

diff --git a/crypt-gpgme.c b/crypt-gpgme.c
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -4543,37 +4543,46 @@
 #ifdef ENABLE_NLS
     gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
 #endif
     has_run = 1; /* note use of 1 here is intentional to avoid requiring "true"
                    to be defined.  see #3657 */
   }
 }
 
-/* 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)
 {
   crypt_key_t *p;
   char input_signas[SHORT_STRING];
   int choice;
 
diff --git a/init.h b/init.h
--- a/init.h
+++ b/init.h
@@ -1965,16 +1965,18 @@
   ** The number of seconds after which a cached passphrase will expire if
   ** not used.
   ** (PGP only)
   */
   { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
   /*
   ** .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},
   /*
   ** .pp
   ** This command is used to verify PGP signatures.
   ** .pp
   ** This is a format string, see the $$pgp_decode_command command for
diff --git a/pgp.c b/pgp.c
--- a/pgp.c
+++ b/pgp.c
@@ -103,17 +103,18 @@
   pgp_void_passphrase ();
   mutt_message _("PGP passphrase forgotten.");
 }
 
 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)))
     setenv("GPG_TTY", tty, 0);
 
   return 1;
 }
 

Attachment: signature.asc
Description: PGP signature

Reply via email to