diff options
author | Darren Tucker <dtucker@zip.com.au> | 2010-01-08 17:07:22 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2010-01-08 17:07:22 +1100 |
commit | 6e7fe1c01b8a69099ffc42e653cc478509e84781 (patch) | |
tree | d6636498087a2b9b4fd4651edd4e0f07788e51e1 /channels.c | |
parent | f788a91624601857c586a4dd97c66083946e7781 (diff) |
- dtucker@cvs.openbsd.org 2009/11/10 04:30:45
[sshconnect2.c channels.c sshconnect.c]
Set close-on-exec on various descriptors so they don't get leaked to
child processes. bz #1643, patch from jchadima at redhat, ok deraadt.
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/channels.c b/channels.c index 884c14c99..eb0c61d8b 100644 --- a/channels.c +++ b/channels.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.c,v 1.297 2009/10/28 16:38:18 reyk Exp $ */ | 1 | /* $OpenBSD: channels.c,v 1.298 2009/11/10 04:30:44 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -53,6 +53,7 @@ | |||
53 | #include <arpa/inet.h> | 53 | #include <arpa/inet.h> |
54 | 54 | ||
55 | #include <errno.h> | 55 | #include <errno.h> |
56 | #include <fcntl.h> | ||
56 | #include <netdb.h> | 57 | #include <netdb.h> |
57 | #include <stdio.h> | 58 | #include <stdio.h> |
58 | #include <stdlib.h> | 59 | #include <stdlib.h> |
@@ -231,7 +232,12 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd, | |||
231 | channel_max_fd = MAX(channel_max_fd, wfd); | 232 | channel_max_fd = MAX(channel_max_fd, wfd); |
232 | channel_max_fd = MAX(channel_max_fd, efd); | 233 | channel_max_fd = MAX(channel_max_fd, efd); |
233 | 234 | ||
234 | /* XXX set close-on-exec -markus */ | 235 | if (rfd != -1) |
236 | fcntl(rfd, F_SETFD, FD_CLOEXEC); | ||
237 | if (wfd != -1 && wfd != rfd) | ||
238 | fcntl(wfd, F_SETFD, FD_CLOEXEC); | ||
239 | if (efd != -1 && efd != rfd && efd != wfd) | ||
240 | fcntl(efd, F_SETFD, FD_CLOEXEC); | ||
235 | 241 | ||
236 | c->rfd = rfd; | 242 | c->rfd = rfd; |
237 | c->wfd = wfd; | 243 | c->wfd = wfd; |