diff options
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/channels.c b/channels.c index e5b2b8c51..65a6a7f00 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.193 2003/07/02 14:51:16 markus Exp $"); | 42 | RCSID("$OpenBSD: channels.c,v 1.194 2003/08/29 10:04:36 markus Exp $"); |
43 | 43 | ||
44 | #include "ssh.h" | 44 | #include "ssh.h" |
45 | #include "ssh1.h" | 45 | #include "ssh1.h" |
@@ -177,7 +177,7 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd, | |||
177 | 177 | ||
178 | /* XXX ugly hack: nonblock is only set by the server */ | 178 | /* XXX ugly hack: nonblock is only set by the server */ |
179 | if (nonblock && isatty(c->rfd)) { | 179 | if (nonblock && isatty(c->rfd)) { |
180 | debug("channel %d: rfd %d isatty", c->self, c->rfd); | 180 | debug2("channel %d: rfd %d isatty", c->self, c->rfd); |
181 | c->isatty = 1; | 181 | c->isatty = 1; |
182 | if (!isatty(c->wfd)) { | 182 | if (!isatty(c->wfd)) { |
183 | error("channel %d: wfd %d is not a tty?", | 183 | error("channel %d: wfd %d is not a tty?", |
@@ -304,7 +304,7 @@ channel_close_fd(int *fdp) | |||
304 | static void | 304 | static void |
305 | channel_close_fds(Channel *c) | 305 | channel_close_fds(Channel *c) |
306 | { | 306 | { |
307 | debug3("channel_close_fds: channel %d: r %d w %d e %d", | 307 | debug3("channel %d: close_fds r %d w %d e %d", |
308 | c->self, c->rfd, c->wfd, c->efd); | 308 | c->self, c->rfd, c->wfd, c->efd); |
309 | 309 | ||
310 | channel_close_fd(&c->sock); | 310 | channel_close_fd(&c->sock); |
@@ -324,11 +324,11 @@ channel_free(Channel *c) | |||
324 | for (n = 0, i = 0; i < channels_alloc; i++) | 324 | for (n = 0, i = 0; i < channels_alloc; i++) |
325 | if (channels[i]) | 325 | if (channels[i]) |
326 | n++; | 326 | n++; |
327 | debug("channel_free: channel %d: %s, nchannels %d", c->self, | 327 | debug("channel %d: free: %s, nchannels %d", c->self, |
328 | c->remote_name ? c->remote_name : "???", n); | 328 | c->remote_name ? c->remote_name : "???", n); |
329 | 329 | ||
330 | s = channel_open_message(); | 330 | s = channel_open_message(); |
331 | debug3("channel_free: status: %s", s); | 331 | debug3("channel %d: status: %s", c->self, s); |
332 | xfree(s); | 332 | xfree(s); |
333 | 333 | ||
334 | if (c->sock != -1) | 334 | if (c->sock != -1) |
@@ -596,7 +596,7 @@ channel_request_start(int id, char *service, int wantconfirm) | |||
596 | logit("channel_request_start: %d: unknown channel id", id); | 596 | logit("channel_request_start: %d: unknown channel id", id); |
597 | return; | 597 | return; |
598 | } | 598 | } |
599 | debug("channel %d: request %s", id, service) ; | 599 | debug2("channel %d: request %s", id, service) ; |
600 | packet_start(SSH2_MSG_CHANNEL_REQUEST); | 600 | packet_start(SSH2_MSG_CHANNEL_REQUEST); |
601 | packet_put_int(c->remote_id); | 601 | packet_put_int(c->remote_id); |
602 | packet_put_cstring(service); | 602 | packet_put_cstring(service); |
@@ -739,7 +739,7 @@ channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) | |||
739 | packet_put_int(c->remote_id); | 739 | packet_put_int(c->remote_id); |
740 | packet_send(); | 740 | packet_send(); |
741 | c->type = SSH_CHANNEL_CLOSED; | 741 | c->type = SSH_CHANNEL_CLOSED; |
742 | debug("channel %d: closing after input drain.", c->self); | 742 | debug2("channel %d: closing after input drain.", c->self); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
@@ -780,7 +780,7 @@ x11_open_helper(Buffer *b) | |||
780 | proto_len = ucp[6] + 256 * ucp[7]; | 780 | proto_len = ucp[6] + 256 * ucp[7]; |
781 | data_len = ucp[8] + 256 * ucp[9]; | 781 | data_len = ucp[8] + 256 * ucp[9]; |
782 | } else { | 782 | } else { |
783 | debug("Initial X11 packet contains bad byte order byte: 0x%x", | 783 | debug2("Initial X11 packet contains bad byte order byte: 0x%x", |
784 | ucp[0]); | 784 | ucp[0]); |
785 | return -1; | 785 | return -1; |
786 | } | 786 | } |
@@ -793,14 +793,14 @@ x11_open_helper(Buffer *b) | |||
793 | /* Check if authentication protocol matches. */ | 793 | /* Check if authentication protocol matches. */ |
794 | if (proto_len != strlen(x11_saved_proto) || | 794 | if (proto_len != strlen(x11_saved_proto) || |
795 | memcmp(ucp + 12, x11_saved_proto, proto_len) != 0) { | 795 | memcmp(ucp + 12, x11_saved_proto, proto_len) != 0) { |
796 | debug("X11 connection uses different authentication protocol."); | 796 | debug2("X11 connection uses different authentication protocol."); |
797 | return -1; | 797 | return -1; |
798 | } | 798 | } |
799 | /* Check if authentication data matches our fake data. */ | 799 | /* Check if authentication data matches our fake data. */ |
800 | if (data_len != x11_fake_data_len || | 800 | if (data_len != x11_fake_data_len || |
801 | memcmp(ucp + 12 + ((proto_len + 3) & ~3), | 801 | memcmp(ucp + 12 + ((proto_len + 3) & ~3), |
802 | x11_fake_data, x11_fake_data_len) != 0) { | 802 | x11_fake_data, x11_fake_data_len) != 0) { |
803 | debug("X11 auth data does not match fake data."); | 803 | debug2("X11 auth data does not match fake data."); |
804 | return -1; | 804 | return -1; |
805 | } | 805 | } |
806 | /* Check fake data length */ | 806 | /* Check fake data length */ |
@@ -857,7 +857,7 @@ channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) | |||
857 | channel_pre_open(c, readset, writeset); | 857 | channel_pre_open(c, readset, writeset); |
858 | } else if (ret == -1) { | 858 | } else if (ret == -1) { |
859 | logit("X11 connection rejected because of wrong authentication."); | 859 | logit("X11 connection rejected because of wrong authentication."); |
860 | debug("X11 rejected %d i%d/o%d", c->self, c->istate, c->ostate); | 860 | debug2("X11 rejected %d i%d/o%d", c->self, c->istate, c->ostate); |
861 | chan_read_failed(c); | 861 | chan_read_failed(c); |
862 | buffer_clear(&c->input); | 862 | buffer_clear(&c->input); |
863 | chan_ibuf_empty(c); | 863 | chan_ibuf_empty(c); |
@@ -867,7 +867,7 @@ channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) | |||
867 | chan_write_failed(c); | 867 | chan_write_failed(c); |
868 | else | 868 | else |
869 | c->type = SSH_CHANNEL_OPEN; | 869 | c->type = SSH_CHANNEL_OPEN; |
870 | debug("X11 closed %d i%d/o%d", c->self, c->istate, c->ostate); | 870 | debug2("X11 closed %d i%d/o%d", c->self, c->istate, c->ostate); |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
@@ -925,7 +925,7 @@ channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) | |||
925 | strlcpy(c->path, host, sizeof(c->path)); | 925 | strlcpy(c->path, host, sizeof(c->path)); |
926 | c->host_port = ntohs(s4_req.dest_port); | 926 | c->host_port = ntohs(s4_req.dest_port); |
927 | 927 | ||
928 | debug("channel %d: dynamic request: socks4 host %s port %u command %u", | 928 | debug2("channel %d: dynamic request: socks4 host %s port %u command %u", |
929 | c->self, host, c->host_port, s4_req.command); | 929 | c->self, host, c->host_port, s4_req.command); |
930 | 930 | ||
931 | if (s4_req.command != 1) { | 931 | if (s4_req.command != 1) { |
@@ -1002,7 +1002,7 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) | |||
1002 | if (s5_req.version != 0x05 || | 1002 | if (s5_req.version != 0x05 || |
1003 | s5_req.command != SSH_SOCKS5_CONNECT || | 1003 | s5_req.command != SSH_SOCKS5_CONNECT || |
1004 | s5_req.reserved != 0x00) { | 1004 | s5_req.reserved != 0x00) { |
1005 | debug("channel %d: only socks5 connect supported", c->self); | 1005 | debug2("channel %d: only socks5 connect supported", c->self); |
1006 | return -1; | 1006 | return -1; |
1007 | } | 1007 | } |
1008 | switch(s5_req.atyp){ | 1008 | switch(s5_req.atyp){ |
@@ -1019,7 +1019,7 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) | |||
1019 | af = AF_INET6; | 1019 | af = AF_INET6; |
1020 | break; | 1020 | break; |
1021 | default: | 1021 | default: |
1022 | debug("channel %d: bad socks5 atyp %d", c->self, s5_req.atyp); | 1022 | debug2("channel %d: bad socks5 atyp %d", c->self, s5_req.atyp); |
1023 | return -1; | 1023 | return -1; |
1024 | } | 1024 | } |
1025 | if (have < 4 + addrlen + 2) | 1025 | if (have < 4 + addrlen + 2) |
@@ -1036,7 +1036,7 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) | |||
1036 | return -1; | 1036 | return -1; |
1037 | c->host_port = ntohs(dest_port); | 1037 | c->host_port = ntohs(dest_port); |
1038 | 1038 | ||
1039 | debug("channel %d: dynamic request: socks5 host %s port %u command %u", | 1039 | debug2("channel %d: dynamic request: socks5 host %s port %u command %u", |
1040 | c->self, c->path, c->host_port, s5_req.command); | 1040 | c->self, c->path, c->host_port, s5_req.command); |
1041 | 1041 | ||
1042 | s5_rsp.version = 0x05; | 1042 | s5_rsp.version = 0x05; |
@@ -1111,7 +1111,7 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
1111 | addrlen = sizeof(addr); | 1111 | addrlen = sizeof(addr); |
1112 | newsock = accept(c->sock, &addr, &addrlen); | 1112 | newsock = accept(c->sock, &addr, &addrlen); |
1113 | if (c->single_connection) { | 1113 | if (c->single_connection) { |
1114 | debug("single_connection: closing X11 listener."); | 1114 | debug2("single_connection: closing X11 listener."); |
1115 | channel_close_fd(&c->sock); | 1115 | channel_close_fd(&c->sock); |
1116 | chan_mark_dead(c); | 1116 | chan_mark_dead(c); |
1117 | } | 1117 | } |
@@ -1137,7 +1137,7 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
1137 | /* originator ipaddr and port */ | 1137 | /* originator ipaddr and port */ |
1138 | packet_put_cstring(remote_ipaddr); | 1138 | packet_put_cstring(remote_ipaddr); |
1139 | if (datafellows & SSH_BUG_X11FWD) { | 1139 | if (datafellows & SSH_BUG_X11FWD) { |
1140 | debug("ssh2 x11 bug compat mode"); | 1140 | debug2("ssh2 x11 bug compat mode"); |
1141 | } else { | 1141 | } else { |
1142 | packet_put_int(remote_port); | 1142 | packet_put_int(remote_port); |
1143 | } | 1143 | } |
@@ -1356,16 +1356,16 @@ channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1356 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) | 1356 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) |
1357 | return 1; | 1357 | return 1; |
1358 | if (len <= 0) { | 1358 | if (len <= 0) { |
1359 | debug("channel %d: read<=0 rfd %d len %d", | 1359 | debug2("channel %d: read<=0 rfd %d len %d", |
1360 | c->self, c->rfd, len); | 1360 | c->self, c->rfd, len); |
1361 | if (c->type != SSH_CHANNEL_OPEN) { | 1361 | if (c->type != SSH_CHANNEL_OPEN) { |
1362 | debug("channel %d: not open", c->self); | 1362 | debug2("channel %d: not open", c->self); |
1363 | chan_mark_dead(c); | 1363 | chan_mark_dead(c); |
1364 | return -1; | 1364 | return -1; |
1365 | } else if (compat13) { | 1365 | } else if (compat13) { |
1366 | buffer_clear(&c->output); | 1366 | buffer_clear(&c->output); |
1367 | c->type = SSH_CHANNEL_INPUT_DRAINING; | 1367 | c->type = SSH_CHANNEL_INPUT_DRAINING; |
1368 | debug("channel %d: input draining.", c->self); | 1368 | debug2("channel %d: input draining.", c->self); |
1369 | } else { | 1369 | } else { |
1370 | chan_read_failed(c); | 1370 | chan_read_failed(c); |
1371 | } | 1371 | } |
@@ -1373,7 +1373,7 @@ channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1373 | } | 1373 | } |
1374 | if (c->input_filter != NULL) { | 1374 | if (c->input_filter != NULL) { |
1375 | if (c->input_filter(c, buf, len) == -1) { | 1375 | if (c->input_filter(c, buf, len) == -1) { |
1376 | debug("channel %d: filter stops", c->self); | 1376 | debug2("channel %d: filter stops", c->self); |
1377 | chan_read_failed(c); | 1377 | chan_read_failed(c); |
1378 | } | 1378 | } |
1379 | } else { | 1379 | } else { |
@@ -1406,12 +1406,12 @@ channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1406 | return 1; | 1406 | return 1; |
1407 | if (len <= 0) { | 1407 | if (len <= 0) { |
1408 | if (c->type != SSH_CHANNEL_OPEN) { | 1408 | if (c->type != SSH_CHANNEL_OPEN) { |
1409 | debug("channel %d: not open", c->self); | 1409 | debug2("channel %d: not open", c->self); |
1410 | chan_mark_dead(c); | 1410 | chan_mark_dead(c); |
1411 | return -1; | 1411 | return -1; |
1412 | } else if (compat13) { | 1412 | } else if (compat13) { |
1413 | buffer_clear(&c->output); | 1413 | buffer_clear(&c->output); |
1414 | debug("channel %d: input draining.", c->self); | 1414 | debug2("channel %d: input draining.", c->self); |
1415 | c->type = SSH_CHANNEL_INPUT_DRAINING; | 1415 | c->type = SSH_CHANNEL_INPUT_DRAINING; |
1416 | } else { | 1416 | } else { |
1417 | chan_write_failed(c); | 1417 | chan_write_failed(c); |
@@ -1618,16 +1618,16 @@ channel_garbage_collect(Channel *c) | |||
1618 | if (c->detach_user != NULL) { | 1618 | if (c->detach_user != NULL) { |
1619 | if (!chan_is_dead(c, 0)) | 1619 | if (!chan_is_dead(c, 0)) |
1620 | return; | 1620 | return; |
1621 | debug("channel %d: gc: notify user", c->self); | 1621 | debug2("channel %d: gc: notify user", c->self); |
1622 | c->detach_user(c->self, NULL); | 1622 | c->detach_user(c->self, NULL); |
1623 | /* if we still have a callback */ | 1623 | /* if we still have a callback */ |
1624 | if (c->detach_user != NULL) | 1624 | if (c->detach_user != NULL) |
1625 | return; | 1625 | return; |
1626 | debug("channel %d: gc: user detached", c->self); | 1626 | debug2("channel %d: gc: user detached", c->self); |
1627 | } | 1627 | } |
1628 | if (!chan_is_dead(c, 1)) | 1628 | if (!chan_is_dead(c, 1)) |
1629 | return; | 1629 | return; |
1630 | debug("channel %d: garbage collecting", c->self); | 1630 | debug2("channel %d: garbage collecting", c->self); |
1631 | channel_free(c); | 1631 | channel_free(c); |
1632 | } | 1632 | } |
1633 | 1633 | ||
@@ -2002,7 +2002,7 @@ channel_input_open_confirmation(int type, u_int32_t seq, void *ctxt) | |||
2002 | c->confirm(c->self, NULL); | 2002 | c->confirm(c->self, NULL); |
2003 | debug2("callback done"); | 2003 | debug2("callback done"); |
2004 | } | 2004 | } |
2005 | debug("channel %d: open confirm rwindow %u rmax %u", c->self, | 2005 | debug2("channel %d: open confirm rwindow %u rmax %u", c->self, |
2006 | c->remote_window, c->remote_maxpacket); | 2006 | c->remote_window, c->remote_maxpacket); |
2007 | } | 2007 | } |
2008 | packet_check_eom(); | 2008 | packet_check_eom(); |
@@ -2514,7 +2514,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost, | |||
2514 | } | 2514 | } |
2515 | #endif | 2515 | #endif |
2516 | if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) { | 2516 | if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) { |
2517 | debug("bind port %d: %.100s", port, strerror(errno)); | 2517 | debug2("bind port %d: %.100s", port, strerror(errno)); |
2518 | close(sock); | 2518 | close(sock); |
2519 | 2519 | ||
2520 | if (ai->ai_next) | 2520 | if (ai->ai_next) |
@@ -2663,12 +2663,12 @@ x11_connect_display(void) | |||
2663 | /* Create a socket. */ | 2663 | /* Create a socket. */ |
2664 | sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); | 2664 | sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); |
2665 | if (sock < 0) { | 2665 | if (sock < 0) { |
2666 | debug("socket: %.100s", strerror(errno)); | 2666 | debug2("socket: %.100s", strerror(errno)); |
2667 | continue; | 2667 | continue; |
2668 | } | 2668 | } |
2669 | /* Connect it to the display. */ | 2669 | /* Connect it to the display. */ |
2670 | if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0) { | 2670 | if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0) { |
2671 | debug("connect %.100s port %d: %.100s", buf, | 2671 | debug2("connect %.100s port %d: %.100s", buf, |
2672 | 6000 + display_number, strerror(errno)); | 2672 | 6000 + display_number, strerror(errno)); |
2673 | close(sock); | 2673 | close(sock); |
2674 | continue; | 2674 | continue; |