In fact, even this in compat.h might be enough (Solaris has closefrom I
believe):
#ifndef HAVE_CLOSEFROM
#include <fcntl.h>
#define closefrom(fd) fcntl(fd, F_CLOSEM)
#endif
Of course AIX might need something different but currently tmux doesn't
work there anyway and I don't have time and access to an AIX box to
figure out why.
On Sun, Oct 24, 2010 at 05:00:01PM +0100, Nicholas Marriott wrote:
> Hi
>
> Thanks, but closefrom() needs to be done as a compat/closefrom.c file
> (maybe want to look at the one from openssh) rather than scattering the
> same HAVE_* all over the place.
>
> Cheers
>
>
> On Sun, Oct 24, 2010 at 02:03:30PM +0200, Martti Kühne wrote:
> > hello there
> >
> > the patch below does the job here on linux. :-)
> >
> > regards
> > mar77i
> >
> >
> > diff -ru tmux/client.c tmux_new/client.c
> > --- tmux/client.c 2010-10-24 03:31:08.000000000 +0200
> > +++ tmux_new/client.c 2010-10-24 13:54:54.000000000 +0200
> > @@ -157,7 +157,9 @@
> > }
> >
> > /* Set process title, log and signals now this is the client. */
> > +#ifdef HAVE_SETPROCTITLE
> > setproctitle("client (%s)", socket_path);
> > +#endif
> > logfile("client");
> >
> > /* Create imsg. */
> > diff -ru tmux/cmd-pipe-pane.c tmux_new/cmd-pipe-pane.c
> > --- tmux/cmd-pipe-pane.c 2010-10-24 02:45:57.000000000 +0200
> > +++ tmux_new/cmd-pipe-pane.c 2010-10-24 13:52:36.000000000 +0200
> > @@ -111,7 +111,13 @@
> > if (null_fd != STDOUT_FILENO && null_fd != STDERR_FILENO)
> > close(null_fd);
> >
> > - closefrom(STDERR_FILENO + 1);
> > +#if HAVE_FCNTL_F_CLOSEM
> > + fcntl(STDERR_FILENO + 1, F_CLOSEM);
> > +#elif HAVE_CLOSEFROM
> > + closefrom(STDERR_FILENO + 1);
> > +#else
> > +#warning This platform has no secure close-before-exec support
> > +#endif
> >
> > command = status_replace(c, NULL, data->arg, time(NULL), 0);
> > execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
> > diff -ru tmux/job.c tmux_new/job.c
> > --- tmux/job.c 2010-10-24 02:45:57.000000000 +0200
> > +++ tmux_new/job.c 2010-10-24 13:52:38.000000000 +0200
> > @@ -168,7 +168,13 @@
> > if (nullfd != STDIN_FILENO && nullfd != STDERR_FILENO)
> > close(nullfd);
> >
> > - closefrom(STDERR_FILENO + 1);
> > +#if HAVE_FCNTL_F_CLOSEM
> > + fcntl(STDERR_FILENO + 1, F_CLOSEM);
> > +#elif HAVE_CLOSEFROM
> > + closefrom(STDERR_FILENO + 1);
> > +#else
> > +#warning This platform has no secure close-before-exec support
> > +#endif
> >
> > execl(_PATH_BSHELL, "sh", "-c", job->cmd, (char *) NULL);
> > fatal("execl failed");
> > diff -ru tmux/server.c tmux_new/server.c
> > --- tmux/server.c 2010-10-24 03:31:08.000000000 +0200
> > +++ tmux_new/server.c 2010-10-24 13:55:27.000000000 +0200
> > @@ -155,7 +155,9 @@
> >
> > start_time = time(NULL);
> > log_debug("socket path %s", socket_path);
> > +#ifdef HAVE_SETPROCTITLE
> > setproctitle("server (%s)", socket_path);
> > +#endif
> >
> > server_fd = server_create_socket();
> > server_client_create(pair[1]);
> > diff -ru tmux/tmux.c tmux_new/tmux.c
> > --- tmux/tmux.c 2010-10-24 03:31:08.000000000 +0200
> > +++ tmux_new/tmux.c 2010-10-24 13:55:11.000000000 +0200
> > @@ -221,7 +221,14 @@
> > fcntl(STDOUT_FILENO, F_SETFL, mode & ~O_NONBLOCK);
> > if ((mode = fcntl(STDERR_FILENO, F_GETFL)) != -1)
> > fcntl(STDERR_FILENO, F_SETFL, mode & ~O_NONBLOCK);
> > - closefrom(STDERR_FILENO + 1);
> > +#if HAVE_FCNTL_F_CLOSEM
> > + fcntl(STDERR_FILENO + 1, F_CLOSEM);
> > +#elif HAVE_CLOSEFROM
> > + closefrom(STDERR_FILENO + 1);
> > +#else
> > +#warning This platform has no secure close-before-exec support
> > +#endif
> >
> > execl(shell, argv0, "-c", shellcmd, (char *) NULL);
> > fatal("execl failed");
> > @@ -472,7 +479,9 @@
> > xfree(path);
> >
> > /* Set process title. */
> > +#ifdef HAVE_SETPROCTITLE
> > setproctitle("%s (%s)", __progname, socket_path);
> > +#endif
> >
> > /* Pass control to the client. */
> > #ifdef HAVE_BROKEN_KQUEUE
> > diff -ru tmux/window.c tmux_new/window.c
> > --- tmux/window.c 2010-10-24 03:34:30.000000000 +0200
> > +++ tmux_new/window.c 2010-10-24 13:52:34.000000000 +0200
> > @@ -578,7 +578,13 @@
> > if (tcsetattr(STDIN_FILENO, TCSANOW, &tio2) != 0)
> > fatal("tcgetattr failed");
> >
> > - closefrom(STDERR_FILENO + 1);
> > +#if HAVE_FCNTL_F_CLOSEM
> > + fcntl(STDERR_FILENO + 1, F_CLOSEM);
> > +#elif HAVE_CLOSEFROM
> > + closefrom(STDERR_FILENO + 1);
> > +#else
> > +#warning This platform has no secure close-before-exec support
> > +#endif
> >
> > environ_push(env);
> >
> > ------------------------------------------------------------------------------
> > Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
> > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> > http://p.sf.net/sfu/nokia-dev2dev
> > _______________________________________________
> > tmux-cvs mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/tmux-cvs
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> tmux-cvs mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tmux-cvs
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs