summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--channels.c60
2 files changed, 21 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index 84864f78a..aff63e72c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -103,6 +103,9 @@
103 - markus@cvs.openbsd.org 2002/01/09 13:49:27 103 - markus@cvs.openbsd.org 2002/01/09 13:49:27
104 [ssh-keygen.c] 104 [ssh-keygen.c]
105 append \n only for public keys 105 append \n only for public keys
106 - markus@cvs.openbsd.org 2002/01/09 17:16:00
107 [channels.c]
108 merge channel_pre_open_15/channel_pre_open_20; ok provos@
106 109
107 110
10820020121 11120020121
@@ -7251,4 +7254,4 @@
7251 - Wrote replacements for strlcpy and mkdtemp 7254 - Wrote replacements for strlcpy and mkdtemp
7252 - Released 1.0pre1 7255 - Released 1.0pre1
7253 7256
7254$Id: ChangeLog,v 1.1752 2002/01/22 12:20:15 djm Exp $ 7257$Id: ChangeLog,v 1.1753 2002/01/22 12:20:40 djm Exp $
diff --git a/channels.c b/channels.c
index fe1db03ab..a053b0337 100644
--- a/channels.c
+++ b/channels.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: channels.c,v 1.156 2002/01/05 10:43:40 markus Exp $"); 42RCSID("$OpenBSD: channels.c,v 1.157 2002/01/09 17:16:00 markus Exp $");
43 43
44#include "ssh.h" 44#include "ssh.h"
45#include "ssh1.h" 45#include "ssh1.h"
@@ -703,28 +703,13 @@ channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset)
703} 703}
704 704
705static void 705static void
706channel_pre_open_15(Channel *c, fd_set * readset, fd_set * writeset) 706channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset)
707{ 707{
708 /* test whether sockets are 'alive' for read/write */ 708 u_int limit = compat20 ? c->remote_window : packet_get_maxsize();
709 if (c->istate == CHAN_INPUT_OPEN)
710 if (buffer_len(&c->input) < packet_get_maxsize())
711 FD_SET(c->sock, readset);
712 if (c->ostate == CHAN_OUTPUT_OPEN ||
713 c->ostate == CHAN_OUTPUT_WAIT_DRAIN) {
714 if (buffer_len(&c->output) > 0) {
715 FD_SET(c->sock, writeset);
716 } else if (c->ostate == CHAN_OUTPUT_WAIT_DRAIN) {
717 chan_obuf_empty(c);
718 }
719 }
720}
721 709
722static void
723channel_pre_open_20(Channel *c, fd_set * readset, fd_set * writeset)
724{
725 if (c->istate == CHAN_INPUT_OPEN && 710 if (c->istate == CHAN_INPUT_OPEN &&
726 c->remote_window > 0 && 711 limit > 0 &&
727 buffer_len(&c->input) < c->remote_window) 712 buffer_len(&c->input) < limit)
728 FD_SET(c->rfd, readset); 713 FD_SET(c->rfd, readset);
729 if (c->ostate == CHAN_OUTPUT_OPEN || 714 if (c->ostate == CHAN_OUTPUT_OPEN ||
730 c->ostate == CHAN_OUTPUT_WAIT_DRAIN) { 715 c->ostate == CHAN_OUTPUT_WAIT_DRAIN) {
@@ -735,7 +720,7 @@ channel_pre_open_20(Channel *c, fd_set * readset, fd_set * writeset)
735 } 720 }
736 } 721 }
737 /** XXX check close conditions, too */ 722 /** XXX check close conditions, too */
738 if (c->efd != -1) { 723 if (compat20 && c->efd != -1) {
739 if (c->extended_usage == CHAN_EXTENDED_WRITE && 724 if (c->extended_usage == CHAN_EXTENDED_WRITE &&
740 buffer_len(&c->extended) > 0) 725 buffer_len(&c->extended) > 0)
741 FD_SET(c->efd, writeset); 726 FD_SET(c->efd, writeset);
@@ -867,10 +852,7 @@ channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset)
867 852
868 if (ret == 1) { 853 if (ret == 1) {
869 c->type = SSH_CHANNEL_OPEN; 854 c->type = SSH_CHANNEL_OPEN;
870 if (compat20) 855 channel_pre_open(c, readset, writeset);
871 channel_pre_open_20(c, readset, writeset);
872 else
873 channel_pre_open_15(c, readset, writeset);
874 } else if (ret == -1) { 856 } else if (ret == -1) {
875 log("X11 connection rejected because of wrong authentication."); 857 log("X11 connection rejected because of wrong authentication.");
876 debug("X11 rejected %d i%d/o%d", c->self, c->istate, c->ostate); 858 debug("X11 rejected %d i%d/o%d", c->self, c->istate, c->ostate);
@@ -1422,23 +1404,15 @@ channel_check_window(Channel *c)
1422} 1404}
1423 1405
1424static void 1406static void
1425channel_post_open_1(Channel *c, fd_set * readset, fd_set * writeset) 1407channel_post_open(Channel *c, fd_set * readset, fd_set * writeset)
1426{ 1408{
1427 if (c->delayed) 1409 if (c->delayed)
1428 return; 1410 return;
1429 channel_handle_rfd(c, readset, writeset); 1411 channel_handle_rfd(c, readset, writeset);
1430 channel_handle_wfd(c, readset, writeset); 1412 channel_handle_wfd(c, readset, writeset);
1431} 1413 if (!compat20)
1432
1433static void
1434channel_post_open_2(Channel *c, fd_set * readset, fd_set * writeset)
1435{
1436 if (c->delayed)
1437 return; 1414 return;
1438 channel_handle_rfd(c, readset, writeset);
1439 channel_handle_wfd(c, readset, writeset);
1440 channel_handle_efd(c, readset, writeset); 1415 channel_handle_efd(c, readset, writeset);
1441
1442 channel_check_window(c); 1416 channel_check_window(c);
1443} 1417}
1444 1418
@@ -1460,7 +1434,7 @@ channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset)
1460static void 1434static void
1461channel_handler_init_20(void) 1435channel_handler_init_20(void)
1462{ 1436{
1463 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_20; 1437 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open;
1464 channel_pre[SSH_CHANNEL_X11_OPEN] = &channel_pre_x11_open; 1438 channel_pre[SSH_CHANNEL_X11_OPEN] = &channel_pre_x11_open;
1465 channel_pre[SSH_CHANNEL_PORT_LISTENER] = &channel_pre_listener; 1439 channel_pre[SSH_CHANNEL_PORT_LISTENER] = &channel_pre_listener;
1466 channel_pre[SSH_CHANNEL_RPORT_LISTENER] = &channel_pre_listener; 1440 channel_pre[SSH_CHANNEL_RPORT_LISTENER] = &channel_pre_listener;
@@ -1469,13 +1443,13 @@ channel_handler_init_20(void)
1469 channel_pre[SSH_CHANNEL_CONNECTING] = &channel_pre_connecting; 1443 channel_pre[SSH_CHANNEL_CONNECTING] = &channel_pre_connecting;
1470 channel_pre[SSH_CHANNEL_DYNAMIC] = &channel_pre_dynamic; 1444 channel_pre[SSH_CHANNEL_DYNAMIC] = &channel_pre_dynamic;
1471 1445
1472 channel_post[SSH_CHANNEL_OPEN] = &channel_post_open_2; 1446 channel_post[SSH_CHANNEL_OPEN] = &channel_post_open;
1473 channel_post[SSH_CHANNEL_PORT_LISTENER] = &channel_post_port_listener; 1447 channel_post[SSH_CHANNEL_PORT_LISTENER] = &channel_post_port_listener;
1474 channel_post[SSH_CHANNEL_RPORT_LISTENER] = &channel_post_port_listener; 1448 channel_post[SSH_CHANNEL_RPORT_LISTENER] = &channel_post_port_listener;
1475 channel_post[SSH_CHANNEL_X11_LISTENER] = &channel_post_x11_listener; 1449 channel_post[SSH_CHANNEL_X11_LISTENER] = &channel_post_x11_listener;
1476 channel_post[SSH_CHANNEL_AUTH_SOCKET] = &channel_post_auth_listener; 1450 channel_post[SSH_CHANNEL_AUTH_SOCKET] = &channel_post_auth_listener;
1477 channel_post[SSH_CHANNEL_CONNECTING] = &channel_post_connecting; 1451 channel_post[SSH_CHANNEL_CONNECTING] = &channel_post_connecting;
1478 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_2; 1452 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open;
1479} 1453}
1480 1454
1481static void 1455static void
@@ -1491,19 +1465,19 @@ channel_handler_init_13(void)
1491 channel_pre[SSH_CHANNEL_CONNECTING] = &channel_pre_connecting; 1465 channel_pre[SSH_CHANNEL_CONNECTING] = &channel_pre_connecting;
1492 channel_pre[SSH_CHANNEL_DYNAMIC] = &channel_pre_dynamic; 1466 channel_pre[SSH_CHANNEL_DYNAMIC] = &channel_pre_dynamic;
1493 1467
1494 channel_post[SSH_CHANNEL_OPEN] = &channel_post_open_1; 1468 channel_post[SSH_CHANNEL_OPEN] = &channel_post_open;
1495 channel_post[SSH_CHANNEL_X11_LISTENER] = &channel_post_x11_listener; 1469 channel_post[SSH_CHANNEL_X11_LISTENER] = &channel_post_x11_listener;
1496 channel_post[SSH_CHANNEL_PORT_LISTENER] = &channel_post_port_listener; 1470 channel_post[SSH_CHANNEL_PORT_LISTENER] = &channel_post_port_listener;
1497 channel_post[SSH_CHANNEL_AUTH_SOCKET] = &channel_post_auth_listener; 1471 channel_post[SSH_CHANNEL_AUTH_SOCKET] = &channel_post_auth_listener;
1498 channel_post[SSH_CHANNEL_OUTPUT_DRAINING] = &channel_post_output_drain_13; 1472 channel_post[SSH_CHANNEL_OUTPUT_DRAINING] = &channel_post_output_drain_13;
1499 channel_post[SSH_CHANNEL_CONNECTING] = &channel_post_connecting; 1473 channel_post[SSH_CHANNEL_CONNECTING] = &channel_post_connecting;
1500 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1; 1474 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open;
1501} 1475}
1502 1476
1503static void 1477static void
1504channel_handler_init_15(void) 1478channel_handler_init_15(void)
1505{ 1479{
1506 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_15; 1480 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open;
1507 channel_pre[SSH_CHANNEL_X11_OPEN] = &channel_pre_x11_open; 1481 channel_pre[SSH_CHANNEL_X11_OPEN] = &channel_pre_x11_open;
1508 channel_pre[SSH_CHANNEL_X11_LISTENER] = &channel_pre_listener; 1482 channel_pre[SSH_CHANNEL_X11_LISTENER] = &channel_pre_listener;
1509 channel_pre[SSH_CHANNEL_PORT_LISTENER] = &channel_pre_listener; 1483 channel_pre[SSH_CHANNEL_PORT_LISTENER] = &channel_pre_listener;
@@ -1514,9 +1488,9 @@ channel_handler_init_15(void)
1514 channel_post[SSH_CHANNEL_X11_LISTENER] = &channel_post_x11_listener; 1488 channel_post[SSH_CHANNEL_X11_LISTENER] = &channel_post_x11_listener;
1515 channel_post[SSH_CHANNEL_PORT_LISTENER] = &channel_post_port_listener; 1489 channel_post[SSH_CHANNEL_PORT_LISTENER] = &channel_post_port_listener;
1516 channel_post[SSH_CHANNEL_AUTH_SOCKET] = &channel_post_auth_listener; 1490 channel_post[SSH_CHANNEL_AUTH_SOCKET] = &channel_post_auth_listener;
1517 channel_post[SSH_CHANNEL_OPEN] = &channel_post_open_1; 1491 channel_post[SSH_CHANNEL_OPEN] = &channel_post_open;
1518 channel_post[SSH_CHANNEL_CONNECTING] = &channel_post_connecting; 1492 channel_post[SSH_CHANNEL_CONNECTING] = &channel_post_connecting;
1519 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1; 1493 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open;
1520} 1494}
1521 1495
1522static void 1496static void