From: David Champion <dgc@uchicago.edu>
[apps/madmutt.git] / pgp.c
diff --git a/pgp.c b/pgp.c
index 45f7cf7..74f73a9 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -104,13 +104,16 @@ void pgp_forget_passphrase (void)
 }
 
 int pgp_use_gpg_agent (void) {
-  char *tty;
+  char *tty, *ttybuf;
 
   if (!option (OPTUSEGPGAGENT) || !getenv ("GPG_AGENT_INFO"))
     return 0;
 
-  if ((tty = ttyname(0)))
-    setenv("GPG_TTY", tty, 0);
+  if ((tty = ttyname(0)) && 
+      ((ttybuf = mem_malloc (sizeof("GPG_TTY") + strlen(tty) + 1)))) {
+      snprintf (ttybuf, sizeof (ttybuf), "GPG_TTY=%s", tty);
+      putenv (ttybuf);
+  }
 
   return 1;
 }