]> granicus.if.org Git - neomutt/commitdiff
Fix GPG_TTY to be added to envlist. (closes #3931)
authorKevin McCarthy <kevin@8t8.us>
Tue, 18 Apr 2017 19:25:17 +0000 (12:25 -0700)
committerKevin McCarthy <kevin@8t8.us>
Tue, 18 Apr 2017 19:25:17 +0000 (12:25 -0700)
Changeset 37209157e33c converted filters to use the envlist.
Unfortunately, I missed that pgp.c sets GPG_TTY when using the GnuPG
agent.  Convert to add GPG_TTY to the envlist too.

filter.c
init.c
pgp.c
protos.h

index a10dcd2a6c6906908c68f3cb308fff99e7eb0a49..331d5425682ef8f1f96903dbbf72b6243afc7588 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -122,7 +122,7 @@ mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
     if (MuttIndexWindow && (MuttIndexWindow->cols > 0))
     {
       snprintf (columns, sizeof (columns), "%d", MuttIndexWindow->cols);
-      mutt_envlist_set ("COLUMNS", columns);
+      mutt_envlist_set ("COLUMNS", columns, 1);
     }
 
     execle (EXECSHELL, "sh", "-c", cmd, NULL, mutt_envlist ());
diff --git a/init.c b/init.c
index 2a22e08723d21903e63f6c66aeedee5270681185..d0026e5a30b72843910c30a6c88e025f59ebd8bf 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1894,7 +1894,7 @@ char **mutt_envlist (void)
  * It's broken out because some other parts of mutt (filter.c) need
  * to set/overwrite environment variables in envlist before execing.
  */
-void mutt_envlist_set (const char *name, const char *value)
+void mutt_envlist_set (const char *name, const char *value, int overwrite)
 {
   char **envp = envlist;
   char work[LONG_STRING];
@@ -1907,7 +1907,11 @@ void mutt_envlist_set (const char *name, const char *value)
   while (envp && *envp)
   {
     if (!mutt_strncmp (name, *envp, len) && (*envp)[len] == '=')
+    {
+      if (!overwrite)
+        return;
       break;
+    }
     envp++;
     count++;
   }
@@ -2022,7 +2026,7 @@ static int parse_setenv(BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
 
   name = safe_strdup (tmp->data);
   mutt_extract_token (tmp, s, 0);
-  mutt_envlist_set (name, tmp->data);
+  mutt_envlist_set (name, tmp->data, 1);
   FREE (&name);
 
   return 0;
diff --git a/pgp.c b/pgp.c
index 6a6f3c91b5fc11c47bb3437af58d7e37f107a810..5b28713cf6a17db6f1ebd94641342a734acf9b05 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -114,7 +114,10 @@ int pgp_use_gpg_agent (void)
     return 0;
 
   if ((tty = ttyname(0)))
+  {
     setenv("GPG_TTY", tty, 0);
+    mutt_envlist_set ("GPG_TTY", tty, 0);
+  }
 
   return 1;
 }
index 37bfe6df6bed16f8ec609be0e88e580f9b4efcc6..08c22510e4600a6bac20417f5ce73d2c3fa108d3 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -186,7 +186,7 @@ void mutt_edit_content_type (HEADER *, BODY *, FILE *);
 void mutt_edit_file (const char *, const char *);
 void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t);
 char **mutt_envlist (void);
-void mutt_envlist_set (const char *name, const char *value);
+void mutt_envlist_set (const char *name, const char *value, int overwrite);
 int mutt_filter_unprintable (char **);
 int mutt_label_message (HEADER *);
 void mutt_make_label_hash (CONTEXT *);