From: Kevin McCarthy Date: Tue, 18 Apr 2017 19:25:17 +0000 (-0700) Subject: Fix GPG_TTY to be added to envlist. (closes #3931) X-Git-Tag: mutt-1-8-2-rel~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5bd9444eba9bb251a3d025aad2be03089084f916;p=mutt Fix GPG_TTY to be added to envlist. (closes #3931) 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. --- diff --git a/filter.c b/filter.c index a10dcd2a..331d5425 100644 --- 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 2a22e087..d0026e5a 100644 --- 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 6a6f3c91..5b28713c 100644 --- 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; } diff --git a/protos.h b/protos.h index 37bfe6df..08c22510 100644 --- 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 *);