View | Details | Raw Unified | Return to bug 1643
Collapse All | Expand All

(-)openssh-5.2p1/channels.c.cloexec (+13 lines)
Lines 60-65 Link Here
60
#include <termios.h>
60
#include <termios.h>
61
#include <unistd.h>
61
#include <unistd.h>
62
#include <stdarg.h>
62
#include <stdarg.h>
63
#include <fcntl.h>
63
64
64
#include "openbsd-compat/sys-queue.h"
65
#include "openbsd-compat/sys-queue.h"
65
#include "xmalloc.h"
66
#include "xmalloc.h"
Lines 230-235 channel_register_fds(Channel *c, int rfd Link Here
230
231
231
	/* XXX set close-on-exec -markus */
232
	/* XXX set close-on-exec -markus */
232
233
234
	if (rfd != -1) {
235
		fcntl(rfd, F_SETFD, FD_CLOEXEC);
236
	}
237
238
	if (wfd != -1 && wfd != rfd) {
239
		fcntl(wfd, F_SETFD, FD_CLOEXEC);
240
	}
241
242
	if (efd != -1 && efd != rfd && efd != wfd) {
243
		fcntl(efd, F_SETFD, FD_CLOEXEC);
244
	}
245
233
	c->rfd = rfd;
246
	c->rfd = rfd;
234
	c->wfd = wfd;
247
	c->wfd = wfd;
235
	c->sock = (rfd == wfd) ? rfd : -1;
248
	c->sock = (rfd == wfd) ? rfd : -1;
(-)openssh-5.2p1/sshconnect2.c.cloexec (+2 lines)
Lines 39-44 Link Here
39
#include <stdio.h>
39
#include <stdio.h>
40
#include <string.h>
40
#include <string.h>
41
#include <unistd.h>
41
#include <unistd.h>
42
#include <fcntl.h>
42
#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H)
43
#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H)
43
#include <vis.h>
44
#include <vis.h>
44
#endif
45
#endif
Lines 1505-1510 ssh_keysign(Key *key, u_char **sigp, u_i Link Here
1505
		return -1;
1506
		return -1;
1506
	}
1507
	}
1507
	if (pid == 0) {
1508
	if (pid == 0) {
1509
		fcntl(packet_get_connection_in(), F_SETFD, 0); /* keep the socket on exec */
1508
		permanently_drop_suid(getuid());
1510
		permanently_drop_suid(getuid());
1509
		close(from[0]);
1511
		close(from[0]);
1510
		if (dup2(from[1], STDOUT_FILENO) < 0)
1512
		if (dup2(from[1], STDOUT_FILENO) < 0)
(-)openssh-5.2p1/sshconnect.c.cloexec (-1 / +5 lines)
Lines 38-43 Link Here
38
#include <stdlib.h>
38
#include <stdlib.h>
39
#include <string.h>
39
#include <string.h>
40
#include <unistd.h>
40
#include <unistd.h>
41
#include <fcntl.h>
41
42
42
#include "xmalloc.h"
43
#include "xmalloc.h"
43
#include "key.h"
44
#include "key.h"
Lines 190-197 ssh_create_socket(int privileged, struct Link Here
190
		return sock;
191
		return sock;
191
	}
192
	}
192
	sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
193
	sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
193
	if (sock < 0)
194
	if (sock < 0) {
194
		error("socket: %.100s", strerror(errno));
195
		error("socket: %.100s", strerror(errno));
196
		return -1;
197
	}
198
	fcntl(sock, F_SETFD, FD_CLOEXEC);
195
199
196
	/* Bind the socket to an alternative local IP address */
200
	/* Bind the socket to an alternative local IP address */
197
	if (options.bind_address == NULL)
201
	if (options.bind_address == NULL)

Return to bug 1643