]> granicus.if.org Git - neomutt/commitdiff
Remove GPG_AGENT_INFO check for GnuPG 2.1 compatibility. (closes #3715)
authorKevin McCarthy <kevin@8t8.us>
Mon, 26 Jan 2015 02:09:56 +0000 (18:09 -0800)
committerKevin McCarthy <kevin@8t8.us>
Mon, 26 Jan 2015 02:09:56 +0000 (18:09 -0800)
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
init.h
pgp.c

index 94d9db49e47a1683c6a89b4d33530b434d234050..875b580b4682b4e31830b90a2bf0c0153b9c4c56 100644 (file)
@@ -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 cbd707513ca9159e2f4226ec09714379ec981183..2bcb6700dd4517cb734b5261eb3187d1d14710c1 100644 (file)
--- 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 c8ac07fdb44fabcb5f88a251c985bdd3db74643a..ee9751f024270dd6d645d4698c283fe08a7f17a5 100644 (file)
--- 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)))