This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.

--0-2119602733-1136411342=:11012
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN
Content-Transfer-Encoding: QUOTED-PRINTABLE

Please don't send HTML mail.

On Wed, 4 Jan 2006, Fr=E9d=E9ric Olivi=E9 wrote:

> Hi,
>=20
> I tested and reviewed the last CVS release.
>=20
> The patch which fixed this problem is wrong (sorry) for many reasons :
>=20
> 1) Doing a this sanitize_fd() like it is at the beginning of the main() i=

s
> plain wrong. What happens in this specific case is that fd 0 is closed at=

exec
> time, but fd 1 and 2 are opened. And we definitely need one of them so th=

at
> ssh-agent can send it's environment vars on stdout.


Please try this diff:

Index: misc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D
RCS file: /cvs/src/usr.bin/ssh/misc.c,v
retrieving revision 1.40
diff -u -p -r1.40 misc.c
--- misc.c=092 Jan 2006 07:53:44 -0000=091.40
+++ misc.c=094 Jan 2006 21:45:34 -0000
@@ -601,18 +601,21 @@ tun_open(int tun, int mode)
void
sanitise_stdfd(void)
{
-=09int nullfd;
+=09int nullfd, dupfd;
=20
-=09if ((nullfd =3D open(_PATH_DEVNULL, O_RDWR)) =3D=3D -1) {
+=09if ((nullfd =3D dupfd =3D open(_PATH_DEVNULL, O_RDWR)) =3D=3D -1) {
=09=09fprintf(stderr, "Couldn't open /dev/null: %s", strerror(errno));
=09=09exit(1);
=09}
-=09while (nullfd < 2) {
-=09=09if (dup2(nullfd, nullfd + 1) =3D=3D -1) {
+=09while (dupfd < 2) {
+=09=09/* Only clobber closed fds */
+=09=09if (fcntl(dupfd, F_GETFL, 0) >=3D 0)
+=09=09=09continue;
+=09=09if (dup2(nullfd, dupfd) =3D=3D -1) {
=09=09=09fprintf(stderr, "dup2: %s", strerror(errno));
=09=09=09exit(1);
=09=09}
-=09=09nullfd++;
+=09=09dupfd++;
=09}
=09if (nullfd > 2)
=09=09close(nullfd);


--0-2119602733-1136411342=:11012
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
http://www.mindrot.org/mailman/listi...enssh-unix-dev

--0-2119602733-1136411342=:11012--