changeset: 7024:fa1192803257
user:      Vincent Lefevre <vinc...@vinc17.org>
date:      Sun Apr 30 12:25:08 2017 -0700
link:      http://dev.mutt.org/hg/mutt/rev/fa1192803257

Convert all exec calls to use mutt_envlist(), remove setenv function.

The documentation implies that all children processes will be affected
by the setenv command, so convert all the exec calls to use
mutt_envlist().

The setenv("GPG_TTY") call is no longer needed so remove it.

With that removed, there are no other setenv calls in mutt, so remove
the autoconf check and replacement function.

diffs (125 lines):

diff -r c65d0c23c142 -r fa1192803257 configure.ac
--- a/configure.ac      Thu Apr 27 21:23:25 2017 -0700
+++ b/configure.ac      Sun Apr 30 12:25:08 2017 -0700
@@ -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 c65d0c23c142 -r fa1192803257 m4/gettext.m4
--- a/m4/gettext.m4     Thu Apr 27 21:23:25 2017 -0700
+++ b/m4/gettext.m4     Sun Apr 30 12:25:08 2017 -0700
@@ -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 c65d0c23c142 -r fa1192803257 mutt_tunnel.c
--- a/mutt_tunnel.c     Thu Apr 27 21:23:25 2017 -0700
+++ b/mutt_tunnel.c     Sun Apr 30 12:25:08 2017 -0700
@@ -106,7 +106,7 @@
     /* Don't let the subprocess think it can use the controlling tty */
     setsid ();
 
-    execl (EXECSHELL, "sh", "-c", Tunnel, NULL);
+    execle (EXECSHELL, "sh", "-c", Tunnel, NULL, mutt_envlist ());
     _exit (127);
   }
   mutt_unblock_signals_system (1);
diff -r c65d0c23c142 -r fa1192803257 pgp.c
--- a/pgp.c     Thu Apr 27 21:23:25 2017 -0700
+++ b/pgp.c     Sun Apr 30 12:25:08 2017 -0700
@@ -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 c65d0c23c142 -r fa1192803257 protos.h
--- a/protos.h  Thu Apr 27 21:23:25 2017 -0700
+++ b/protos.h  Sun Apr 30 12:25:08 2017 -0700
@@ -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 c65d0c23c142 -r fa1192803257 sendlib.c
--- a/sendlib.c Thu Apr 27 21:23:25 2017 -0700
+++ b/sendlib.c Sun Apr 30 12:25:08 2017 -0700
@@ -2240,7 +2240,7 @@
          _exit (S_ERR);
       }
 
-      execvp (path, args);
+      execvpe (path, args, mutt_envlist ());
       _exit (S_ERR);
     }
     else if (pid == -1)
diff -r c65d0c23c142 -r fa1192803257 setenv.c
--- a/setenv.c  Thu Apr 27 21:23:25 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 <r...@stanford.edu>
-**  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). */
-}

Reply via email to