diff options
author | Colin Watson <cjwatson@debian.org> | 2003-09-01 02:05:26 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2003-09-01 02:05:26 +0000 |
commit | 6d5a72bc1d98a42ba42f082e50a22e911c1d82d3 (patch) | |
tree | 1bf23174bdb6fc71e2846dda0eca195a418484e7 /channels.c | |
parent | 2ee26b431f98cf1dc0e4fb9809ad1e0c879b8c08 (diff) | |
parent | 58657d96514cd6f16d82add8d6f4adbb36765758 (diff) |
Debian release 3.5p1-1.
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/channels.c b/channels.c index 29eaee7c4..6ff9e2583 100644 --- a/channels.c +++ b/channels.c | |||
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "includes.h" | 41 | #include "includes.h" |
42 | RCSID("$OpenBSD: channels.c,v 1.179 2002/06/26 08:55:02 markus Exp $"); | 42 | RCSID("$OpenBSD: channels.c,v 1.183 2002/09/17 07:47:02 itojun Exp $"); |
43 | 43 | ||
44 | #include "ssh.h" | 44 | #include "ssh.h" |
45 | #include "ssh1.h" | 45 | #include "ssh1.h" |
@@ -186,6 +186,7 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd, | |||
186 | } else { | 186 | } else { |
187 | c->isatty = 0; | 187 | c->isatty = 0; |
188 | } | 188 | } |
189 | c->wfd_isatty = isatty(c->wfd); | ||
189 | 190 | ||
190 | /* enable nonblocking mode */ | 191 | /* enable nonblocking mode */ |
191 | if (nonblock) { | 192 | if (nonblock) { |
@@ -572,6 +573,7 @@ void | |||
572 | channel_send_open(int id) | 573 | channel_send_open(int id) |
573 | { | 574 | { |
574 | Channel *c = channel_lookup(id); | 575 | Channel *c = channel_lookup(id); |
576 | |||
575 | if (c == NULL) { | 577 | if (c == NULL) { |
576 | log("channel_send_open: %d: bad id", id); | 578 | log("channel_send_open: %d: bad id", id); |
577 | return; | 579 | return; |
@@ -589,6 +591,7 @@ void | |||
589 | channel_request_start(int local_id, char *service, int wantconfirm) | 591 | channel_request_start(int local_id, char *service, int wantconfirm) |
590 | { | 592 | { |
591 | Channel *c = channel_lookup(local_id); | 593 | Channel *c = channel_lookup(local_id); |
594 | |||
592 | if (c == NULL) { | 595 | if (c == NULL) { |
593 | log("channel_request_start: %d: unknown channel id", local_id); | 596 | log("channel_request_start: %d: unknown channel id", local_id); |
594 | return; | 597 | return; |
@@ -603,6 +606,7 @@ void | |||
603 | channel_register_confirm(int id, channel_callback_fn *fn) | 606 | channel_register_confirm(int id, channel_callback_fn *fn) |
604 | { | 607 | { |
605 | Channel *c = channel_lookup(id); | 608 | Channel *c = channel_lookup(id); |
609 | |||
606 | if (c == NULL) { | 610 | if (c == NULL) { |
607 | log("channel_register_comfirm: %d: bad id", id); | 611 | log("channel_register_comfirm: %d: bad id", id); |
608 | return; | 612 | return; |
@@ -613,6 +617,7 @@ void | |||
613 | channel_register_cleanup(int id, channel_callback_fn *fn) | 617 | channel_register_cleanup(int id, channel_callback_fn *fn) |
614 | { | 618 | { |
615 | Channel *c = channel_lookup(id); | 619 | Channel *c = channel_lookup(id); |
620 | |||
616 | if (c == NULL) { | 621 | if (c == NULL) { |
617 | log("channel_register_cleanup: %d: bad id", id); | 622 | log("channel_register_cleanup: %d: bad id", id); |
618 | return; | 623 | return; |
@@ -623,6 +628,7 @@ void | |||
623 | channel_cancel_cleanup(int id) | 628 | channel_cancel_cleanup(int id) |
624 | { | 629 | { |
625 | Channel *c = channel_lookup(id); | 630 | Channel *c = channel_lookup(id); |
631 | |||
626 | if (c == NULL) { | 632 | if (c == NULL) { |
627 | log("channel_cancel_cleanup: %d: bad id", id); | 633 | log("channel_cancel_cleanup: %d: bad id", id); |
628 | return; | 634 | return; |
@@ -633,6 +639,7 @@ void | |||
633 | channel_register_filter(int id, channel_filter_fn *fn) | 639 | channel_register_filter(int id, channel_filter_fn *fn) |
634 | { | 640 | { |
635 | Channel *c = channel_lookup(id); | 641 | Channel *c = channel_lookup(id); |
642 | |||
636 | if (c == NULL) { | 643 | if (c == NULL) { |
637 | log("channel_register_filter: %d: bad id", id); | 644 | log("channel_register_filter: %d: bad id", id); |
638 | return; | 645 | return; |
@@ -645,6 +652,7 @@ channel_set_fds(int id, int rfd, int wfd, int efd, | |||
645 | int extusage, int nonblock, u_int window_max) | 652 | int extusage, int nonblock, u_int window_max) |
646 | { | 653 | { |
647 | Channel *c = channel_lookup(id); | 654 | Channel *c = channel_lookup(id); |
655 | |||
648 | if (c == NULL || c->type != SSH_CHANNEL_LARVAL) | 656 | if (c == NULL || c->type != SSH_CHANNEL_LARVAL) |
649 | fatal("channel_activate for non-larval channel %d.", id); | 657 | fatal("channel_activate for non-larval channel %d.", id); |
650 | channel_register_fds(c, rfd, wfd, efd, extusage, nonblock); | 658 | channel_register_fds(c, rfd, wfd, efd, extusage, nonblock); |
@@ -815,6 +823,7 @@ static void | |||
815 | channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) | 823 | channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) |
816 | { | 824 | { |
817 | int ret = x11_open_helper(&c->output); | 825 | int ret = x11_open_helper(&c->output); |
826 | |||
818 | if (ret == 1) { | 827 | if (ret == 1) { |
819 | /* Start normal processing for the channel. */ | 828 | /* Start normal processing for the channel. */ |
820 | c->type = SSH_CHANNEL_OPEN; | 829 | c->type = SSH_CHANNEL_OPEN; |
@@ -866,7 +875,7 @@ channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) | |||
866 | static int | 875 | static int |
867 | channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) | 876 | channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) |
868 | { | 877 | { |
869 | u_char *p, *host; | 878 | char *p, *host; |
870 | int len, have, i, found; | 879 | int len, have, i, found; |
871 | char username[256]; | 880 | char username[256]; |
872 | struct { | 881 | struct { |
@@ -1278,6 +1287,11 @@ channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1278 | buffer_len(&c->output) > 0) { | 1287 | buffer_len(&c->output) > 0) { |
1279 | data = buffer_ptr(&c->output); | 1288 | data = buffer_ptr(&c->output); |
1280 | dlen = buffer_len(&c->output); | 1289 | dlen = buffer_len(&c->output); |
1290 | #ifdef _AIX | ||
1291 | /* XXX: Later AIX versions can't push as much data to tty */ | ||
1292 | if (compat20 && c->wfd_isatty && dlen > 8*1024) | ||
1293 | dlen = 8*1024; | ||
1294 | #endif | ||
1281 | len = write(c->wfd, data, dlen); | 1295 | len = write(c->wfd, data, dlen); |
1282 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) | 1296 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) |
1283 | return 1; | 1297 | return 1; |
@@ -1395,6 +1409,7 @@ static void | |||
1395 | channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) | 1409 | channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) |
1396 | { | 1410 | { |
1397 | int len; | 1411 | int len; |
1412 | |||
1398 | /* Send buffered output data to the socket. */ | 1413 | /* Send buffered output data to the socket. */ |
1399 | if (FD_ISSET(c->sock, writeset) && buffer_len(&c->output) > 0) { | 1414 | if (FD_ISSET(c->sock, writeset) && buffer_len(&c->output) > 0) { |
1400 | len = write(c->sock, buffer_ptr(&c->output), | 1415 | len = write(c->sock, buffer_ptr(&c->output), |
@@ -1472,6 +1487,7 @@ static void | |||
1472 | channel_handler_init(void) | 1487 | channel_handler_init(void) |
1473 | { | 1488 | { |
1474 | int i; | 1489 | int i; |
1490 | |||
1475 | for (i = 0; i < SSH_CHANNEL_MAX_TYPE; i++) { | 1491 | for (i = 0; i < SSH_CHANNEL_MAX_TYPE; i++) { |
1476 | channel_pre[i] = NULL; | 1492 | channel_pre[i] = NULL; |
1477 | channel_post[i] = NULL; | 1493 | channel_post[i] = NULL; |
@@ -2006,7 +2022,6 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por | |||
2006 | struct addrinfo hints, *ai, *aitop; | 2022 | struct addrinfo hints, *ai, *aitop; |
2007 | const char *host; | 2023 | const char *host; |
2008 | char ntop[NI_MAXHOST], strport[NI_MAXSERV]; | 2024 | char ntop[NI_MAXHOST], strport[NI_MAXSERV]; |
2009 | struct linger linger; | ||
2010 | 2025 | ||
2011 | success = 0; | 2026 | success = 0; |
2012 | host = (type == SSH_CHANNEL_RPORT_LISTENER) ? | 2027 | host = (type == SSH_CHANNEL_RPORT_LISTENER) ? |
@@ -2049,13 +2064,13 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por | |||
2049 | continue; | 2064 | continue; |
2050 | } | 2065 | } |
2051 | /* | 2066 | /* |
2052 | * Set socket options. We would like the socket to disappear | 2067 | * Set socket options. |
2053 | * as soon as it has been closed for whatever reason. | 2068 | * Allow local port reuse in TIME_WAIT. |
2054 | */ | 2069 | */ |
2055 | setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); | 2070 | if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, |
2056 | linger.l_onoff = 1; | 2071 | sizeof(on)) == -1) |
2057 | linger.l_linger = 5; | 2072 | error("setsockopt SO_REUSEADDR: %s", strerror(errno)); |
2058 | setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger)); | 2073 | |
2059 | debug("Local forwarding listening on %s port %s.", ntop, strport); | 2074 | debug("Local forwarding listening on %s port %s.", ntop, strport); |
2060 | 2075 | ||
2061 | /* Bind the socket to the address. */ | 2076 | /* Bind the socket to the address. */ |
@@ -2605,6 +2620,7 @@ void | |||
2605 | deny_input_open(int type, u_int32_t seq, void *ctxt) | 2620 | deny_input_open(int type, u_int32_t seq, void *ctxt) |
2606 | { | 2621 | { |
2607 | int rchan = packet_get_int(); | 2622 | int rchan = packet_get_int(); |
2623 | |||
2608 | switch (type) { | 2624 | switch (type) { |
2609 | case SSH_SMSG_AGENT_OPEN: | 2625 | case SSH_SMSG_AGENT_OPEN: |
2610 | error("Warning: ssh server tried agent forwarding."); | 2626 | error("Warning: ssh server tried agent forwarding."); |