diff options
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/channels.c b/channels.c index bd8c337ee..f833e1bb9 100644 --- a/channels.c +++ b/channels.c | |||
@@ -17,7 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include "includes.h" | 19 | #include "includes.h" |
20 | RCSID("$Id: channels.c,v 1.28 2000/05/01 23:23:45 damien Exp $"); | 20 | RCSID("$Id: channels.c,v 1.29 2000/05/07 02:03:15 damien Exp $"); |
21 | 21 | ||
22 | #include "ssh.h" | 22 | #include "ssh.h" |
23 | #include "packet.h" | 23 | #include "packet.h" |
@@ -147,8 +147,25 @@ channel_lookup(int id) | |||
147 | return c; | 147 | return c; |
148 | } | 148 | } |
149 | 149 | ||
150 | void | ||
151 | set_nonblock(int fd) | ||
152 | { | ||
153 | int val; | ||
154 | val = fcntl(fd, F_GETFL, 0); | ||
155 | if (val < 0) { | ||
156 | error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno)); | ||
157 | return; | ||
158 | } | ||
159 | if (val & O_NONBLOCK) | ||
160 | return; | ||
161 | debug("fd %d setting O_NONBLOCK", fd); | ||
162 | val |= O_NONBLOCK; | ||
163 | if (fcntl(fd, F_SETFL, val) == -1) | ||
164 | error("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd, strerror(errno)); | ||
165 | } | ||
166 | |||
150 | /* | 167 | /* |
151 | * register filedescriptors for a channel, used when allocating a channel or | 168 | * Register filedescriptors for a channel, used when allocating a channel or |
152 | * when the channel consumer/producer is ready, e.g. shell exec'd | 169 | * when the channel consumer/producer is ready, e.g. shell exec'd |
153 | */ | 170 | */ |
154 | 171 | ||
@@ -163,11 +180,18 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd, int extusage) | |||
163 | if (efd > channel_max_fd_value) | 180 | if (efd > channel_max_fd_value) |
164 | channel_max_fd_value = efd; | 181 | channel_max_fd_value = efd; |
165 | /* XXX set close-on-exec -markus */ | 182 | /* XXX set close-on-exec -markus */ |
183 | |||
166 | c->rfd = rfd; | 184 | c->rfd = rfd; |
167 | c->wfd = wfd; | 185 | c->wfd = wfd; |
168 | c->sock = (rfd == wfd) ? rfd : -1; | 186 | c->sock = (rfd == wfd) ? rfd : -1; |
169 | c->efd = efd; | 187 | c->efd = efd; |
170 | c->extended_usage = extusage; | 188 | c->extended_usage = extusage; |
189 | if (rfd != -1) | ||
190 | set_nonblock(rfd); | ||
191 | if (wfd != -1) | ||
192 | set_nonblock(wfd); | ||
193 | if (efd != -1) | ||
194 | set_nonblock(efd); | ||
171 | } | 195 | } |
172 | 196 | ||
173 | /* | 197 | /* |
@@ -1532,7 +1556,7 @@ channel_request_remote_forwarding(u_short listen_port, const char *host_to_conne | |||
1532 | */ | 1556 | */ |
1533 | 1557 | ||
1534 | void | 1558 | void |
1535 | channel_input_port_forward_request(int is_root) | 1559 | channel_input_port_forward_request(int is_root, int gateway_ports) |
1536 | { | 1560 | { |
1537 | u_short port, host_port; | 1561 | u_short port, host_port; |
1538 | char *hostname; | 1562 | char *hostname; |
@@ -1551,9 +1575,8 @@ channel_input_port_forward_request(int is_root) | |||
1551 | port); | 1575 | port); |
1552 | /* | 1576 | /* |
1553 | * Initiate forwarding, | 1577 | * Initiate forwarding, |
1554 | * bind port to localhost only (gateway ports == 0). | ||
1555 | */ | 1578 | */ |
1556 | channel_request_local_forwarding(port, hostname, host_port, 0); | 1579 | channel_request_local_forwarding(port, hostname, host_port, gateway_ports); |
1557 | 1580 | ||
1558 | /* Free the argument string. */ | 1581 | /* Free the argument string. */ |
1559 | xfree(hostname); | 1582 | xfree(hostname); |