Re: mutt: 2 new changesets

2017-04-22 Thread Derek Martin
On Tue, Apr 18, 2017 at 12:27:32PM -0700, Brendan Cully wrote:
> changeset: 7013:33995363e723
> user:  Kevin McCarthy 
> 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.
So if I spawn such things that need, just for example, SSH_AUTH_SOCK,
DBUS_SESSION_BUS_ADDRESS, DISPLAY, etc., how do they get at those?

-- 
Derek D. Martinhttp://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.



pgpypyQYm_yiw.pgp
Description: PGP signature


Re: mutt: 2 new changesets

2017-04-22 Thread Vincent Lefevre
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 
> > 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

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Re: mutt: 2 new changesets

2017-04-22 Thread Vincent Lefevre
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 
> > > 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  - Web: 
100% accessible validated (X)HTML - 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 +
@@ -1,45 +0,0 @@
-/*  Replacement for a missing setenv.
-**
-**  Written by Russ Allbery 
-**  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 
-#include 
-
-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
- 

Re: mutt: 2 new changesets

2017-04-22 Thread Vincent Lefevre
On 2017-04-22 22:52:43 +0200, Vincent Lefevre wrote:
> 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?

For consistency, I think that the other execl() / execvp() should
be changed to execle() / execvpe(). Indeed, the Mutt manual says:

7. Managing the Environment

   You can alter the environment that Mutt passes on to its child
   processes using the "setenv" and "unsetenv" operators. (N.B. These
   follow Mutt-style syntax, not shell-style!) You can also query current
   environment values by prefixing a "?" character.
setenv TERM vt100
setenv ORGANIZATION "The Mutt Development Team"
unsetenv DISPLAY
setenv ?LESS

So, *any* process started by Mutt should be affected. New patch
attached.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - 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 23:00:32 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 23:00:32 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 mutt_tunnel.c
--- a/mutt_tunnel.c Tue Apr 18 16:18:10 2017 -0700
+++ b/mutt_tunnel.c Sat Apr 22 23:00:32 2017 +0200
@@ -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 69df899cdfa9 pgp.c
--- a/pgp.c Tue Apr 18 16:18:10 2017 -0700
+++ b/pgp.c Sat Apr 22 23:00:32 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 23:00:32 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 sendlib.c
--- a/sendlib.c Tue Apr 18 16:18:10 2017 -0700
+++ b/sendlib.c Sat Apr 22 23:00:32 2017 +0200
@@ -2240,7 +2240,7 @@
  _exit (S_ERR);
   }
 
-  execvp (path, args);
+  execvpe (path, args, mutt_envlist ());
   _exit (S_ERR);
 }
 else if (pid == -1)
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 +
@@ -1,45 +0,0 @@
-/*  Replacement for a missing setenv.
-**
-**  Written by Russ Allbery 
-**  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 
-#include 
-
-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, va

[Mutt] #3932: from address not changing with sidebar inbox

2017-04-22 Thread Mutt
#3932: from address not changing with sidebar inbox
---+--
 Reporter:  ArchChris  |  Owner:  mutt-dev
 Type:  defect | Status:  new
 Priority:  major  |  Milestone:
Component:  header cache   |Version:  1.8.2
 Keywords:  from address, sidebar  |
---+--
 I've been using mutt for like 1.5 years now without any major issues. I'm
 using Arch Linux and performing upgrades every day. Meaning, I'm pretty
 much up-to-date.

 Right now I'm running Mutt 1.8.2. The lastest version.

 First time on April 14th I noticed, mutt is sending emails using the wrong
 from address. This hasn't changed. I've notived the same problem today.
 Meaning, as far as I've noticed, the problem first occurred in 1.8.1 and
 is still present in 1.8.2

 Closer look: after a few short tests, it seems that the from address
 (which is configured in the according inbox settings) does change, if I
 use key bindings configured in the muttrc. However, if I switch inbox
 using the sidebar, it seems the from address used is alway from the former
 inbox instead of the current one. so, the from address is always one inbox
 switch behind, if i switch inbox in the sidebar. resulting in all emails
 being sent with the wrong from address.

--
Ticket URL: 
Mutt 
The Mutt mail user agent