On 2017-04-22 22:35:04 +0200, Vincent Lefevre wrote:
> On 2017-04-22 12:41:36 -0500, Derek Martin wrote:
> > On Tue, Apr 18, 2017 at 12:27:32PM -0700, Brendan Cully wrote:
> > > changeset: 7013:33995363e723
> > > user: Kevin McCarthy <[email protected]>
> > > date: Tue Apr 18 12:25:17 2017 -0700
> > > link: http://dev.mutt.org/hg/mutt/rev/33995363e723
> > >
> > > 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.
> >
> > So wait, what? Mutt is now filtering out environment variables when
> > it spawns MIME handlers, filters, etc.? That seems pretty broken.
>
> This is not what Kevin said. A setenv() *in Mutt* is not sufficient
> to export the variable to child processes. The envlist needs to be
> updated too. See:
>
> https://dev.mutt.org/trac/ticket/3922
I'm wondering. Is the call to setenv() useful any longer?
I mean, GPG_TTY needs to be set only for child processes, not
for Mutt itself. This would mean that
setenv("GPG_TTY", tty, 0);
could be removed. And that setenv() should no longer be used,
so that anything related to it could be removed. What about
the attached patch?
--
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
diff -r 69df899cdfa9 configure.ac
--- a/configure.ac Tue Apr 18 16:18:10 2017 -0700
+++ b/configure.ac Sat Apr 22 22:50:50 2017 +0200
@@ -374,7 +374,7 @@
AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror)
-AC_REPLACE_FUNCS([setenv strcasecmp strdup strsep strtok_r wcscasecmp])
+AC_REPLACE_FUNCS([strcasecmp strdup strsep strtok_r wcscasecmp])
AC_REPLACE_FUNCS([strcasestr mkdtemp])
AC_CHECK_FUNC(getopt)
diff -r 69df899cdfa9 m4/gettext.m4
--- a/m4/gettext.m4 Tue Apr 18 16:18:10 2017 -0700
+++ b/m4/gettext.m4 Sat Apr 22 22:50:50 2017 +0200
@@ -318,7 +318,7 @@
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
stdlib.h string.h unistd.h sys/param.h])
AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
-getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
+getgid getuid mempcpy munmap putenv setlocale stpcpy strchr strcasecmp \
strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
MUTT_AM_ICONV
diff -r 69df899cdfa9 pgp.c
--- a/pgp.c Tue Apr 18 16:18:10 2017 -0700
+++ b/pgp.c Sat Apr 22 22:50:50 2017 +0200
@@ -114,10 +114,7 @@
return 0;
if ((tty = ttyname(0)))
- {
- setenv("GPG_TTY", tty, 0);
mutt_envlist_set ("GPG_TTY", tty, 0);
- }
return 1;
}
diff -r 69df899cdfa9 protos.h
--- a/protos.h Tue Apr 18 16:18:10 2017 -0700
+++ b/protos.h Sat Apr 22 22:50:50 2017 +0200
@@ -543,10 +543,6 @@
/* prototypes for compatibility functions */
-#ifndef HAVE_SETENV
-int setenv (const char *, const char *, int);
-#endif
-
#ifndef HAVE_STRCASECMP
int strcasecmp (char *, char *);
int strncasecmp (char *, char *, size_t);
diff -r 69df899cdfa9 setenv.c
--- a/setenv.c Tue Apr 18 16:18:10 2017 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/* Replacement for a missing setenv.
-**
-** Written by Russ Allbery <[email protected]>
-** This work is hereby placed in the public domain by its author.
-**
-** Provides the same functionality as the standard library routine setenv
-** for those platforms that don't have it.
-*/
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-int
-setenv(const char *name, const char *value, int overwrite)
-{
- char *envstring;
-
- if (!overwrite && getenv(name) != NULL)
- return 0;
-
- /* Allocate memory for the environment string. We intentionally don't
- use concat here, or the xmalloc family of allocation routines, since
- the intention is to provide a replacement for the standard library
- function which sets errno and returns in the event of a memory
- allocation failure. */
- envstring = malloc(strlen(name) + 1 + strlen(value) + 1); /*
__MEM_CHECKED__ */
- if (envstring == NULL)
- return -1;
-
- /* Build the environment string and add it to the environment using
- putenv. Systems without putenv lose, but XPG4 requires it. */
- strcpy(envstring, name); /* __STRCPY_CHECKED__ */
- strcat(envstring, "="); /* __STRCAT_CHECKED__ */
- strcat(envstring, value); /* __STRCAT_CHECKED__ */
- return putenv(envstring);
-
- /* Note that the memory allocated is not freed. This is intentional;
- many implementations of putenv assume that the string passed to
- putenv will never be freed and don't make a copy of it. Repeated use
- of this function will therefore leak memory, since most
- implementations of putenv also don't free strings removed from the
- environment (due to being overwritten). */
-}