]> granicus.if.org Git - mutt/commitdiff
When using GPG agent in classic mode, set GPG_TTY if it isn't already set
authorAdeodato Simó <asp16@alu.ua.es>
Wed, 21 Sep 2005 04:50:31 +0000 (04:50 +0000)
committerAdeodato Simó <asp16@alu.ua.es>
Wed, 21 Sep 2005 04:50:31 +0000 (04:50 +0000)
instead of bailing out. Closes: #2072.

pgp.c

diff --git a/pgp.c b/pgp.c
index 56042a9936fe87afd1373ddd1b1c3e0518c6d39f..f8dc677125cdc41dd66a212970d613a52e2c7ea8 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -106,7 +106,15 @@ void pgp_forget_passphrase (void)
 
 int pgp_use_gpg_agent (void)
 {
-  return option (OPTUSEGPGAGENT) && getenv ("GPG_TTY") && getenv ("GPG_AGENT_INFO");
+  char *tty;
+
+  if (!option (OPTUSEGPGAGENT) || !getenv ("GPG_AGENT_INFO"))
+    return 0;
+
+  if ((tty = ttyname(0)))
+    setenv("GPG_TTY", tty, 0);
+
+  return 1;
 }
 
 char *pgp_keyid(pgp_key_t k)