summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/ssh/include/channels.h1
-rw-r--r--usr/src/cmd/ssh/libssh/common/nchan.c31
-rw-r--r--usr/src/cmd/ssh/ssh/clientloop.c3
-rw-r--r--usr/src/cmd/ssh/sshd/serverloop.c5
4 files changed, 37 insertions, 3 deletions
diff --git a/usr/src/cmd/ssh/include/channels.h b/usr/src/cmd/ssh/include/channels.h
index 83b41df0dd..4440f1996a 100644
--- a/usr/src/cmd/ssh/include/channels.h
+++ b/usr/src/cmd/ssh/include/channels.h
@@ -248,6 +248,7 @@ void chan_mark_dead(Channel *);
/* channel events */
void chan_rcvd_oclose(Channel *);
+void chan_rcvd_eow(Channel *); /* SSH2-only */
void chan_read_failed(Channel *);
void chan_ibuf_empty(Channel *);
diff --git a/usr/src/cmd/ssh/libssh/common/nchan.c b/usr/src/cmd/ssh/libssh/common/nchan.c
index 97c51fcda8..82a371af5b 100644
--- a/usr/src/cmd/ssh/libssh/common/nchan.c
+++ b/usr/src/cmd/ssh/libssh/common/nchan.c
@@ -25,8 +25,6 @@
#include "includes.h"
RCSID("$OpenBSD: nchan.c,v 1.47 2002/06/19 00:27:55 deraadt Exp $");
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "ssh1.h"
#include "ssh2.h"
#include "buffer.h"
@@ -72,6 +70,7 @@ static void chan_send_ieof1(Channel *);
static void chan_send_oclose1(Channel *);
static void chan_send_close2(Channel *);
static void chan_send_eof2(Channel *);
+static void chan_send_eow2(Channel *);
/* helper */
static void chan_shutdown_write(Channel *);
@@ -300,6 +299,17 @@ chan_rcvd_close2(Channel *c)
break;
}
}
+void
+chan_rcvd_eow(Channel *c)
+{
+ debug2("channel %d: rcvd eow", c->self);
+ switch (c->istate) {
+ case CHAN_INPUT_OPEN:
+ chan_shutdown_read(c);
+ chan_set_istate(c, CHAN_INPUT_CLOSED);
+ break;
+ }
+}
static void
chan_rcvd_eof2(Channel *c)
{
@@ -316,6 +326,8 @@ chan_write_failed2(Channel *c)
case CHAN_OUTPUT_OPEN:
case CHAN_OUTPUT_WAIT_DRAIN:
chan_shutdown_write(c);
+ if (strcmp(c->ctype, "session") == 0)
+ chan_send_eow2(c);
chan_set_ostate(c, CHAN_OUTPUT_CLOSED);
break;
default:
@@ -358,6 +370,21 @@ chan_send_close2(Channel *c)
c->flags |= CHAN_CLOSE_SENT;
}
}
+static void
+chan_send_eow2(Channel *c)
+{
+ debug2("channel %d: send eow", c->self);
+ if (c->ostate == CHAN_OUTPUT_CLOSED) {
+ error("channel %d: must not sent eow on closed output",
+ c->self);
+ return;
+ }
+ packet_start(SSH2_MSG_CHANNEL_REQUEST);
+ packet_put_int(c->remote_id);
+ packet_put_cstring("eow@openssh.com");
+ packet_put_char(0);
+ packet_send();
+}
/* shared */
diff --git a/usr/src/cmd/ssh/ssh/clientloop.c b/usr/src/cmd/ssh/ssh/clientloop.c
index f101c4a6b4..8a9985c632 100644
--- a/usr/src/cmd/ssh/ssh/clientloop.c
+++ b/usr/src/cmd/ssh/ssh/clientloop.c
@@ -1526,6 +1526,9 @@ client_input_channel_req(int type, u_int32_t seq, void *ctxt)
c = channel_lookup(id);
if (c == NULL) {
error("client_input_channel_req: channel %d: unknown channel", id);
+ } else if (strcmp(rtype, "eow@openssh.com") == 0) {
+ packet_check_eom();
+ chan_rcvd_eow(c);
} else if (strcmp(rtype, "exit-status") == 0) {
success = 1;
exit_status = packet_get_int();
diff --git a/usr/src/cmd/ssh/sshd/serverloop.c b/usr/src/cmd/ssh/sshd/serverloop.c
index 4cbb76d875..3dae9b1840 100644
--- a/usr/src/cmd/ssh/sshd/serverloop.c
+++ b/usr/src/cmd/ssh/sshd/serverloop.c
@@ -1229,7 +1229,10 @@ server_input_channel_req(int type, u_int32_t seq, void *ctxt)
if ((c = channel_lookup(id)) == NULL)
packet_disconnect("server_input_channel_req: "
"unknown channel %d", id);
- if (c->type == SSH_CHANNEL_LARVAL || c->type == SSH_CHANNEL_OPEN)
+ if (!strcmp(rtype, "eow@openssh.com")) {
+ packet_check_eom();
+ chan_rcvd_eow(c);
+ } else if (c->type == SSH_CHANNEL_LARVAL || c->type == SSH_CHANNEL_OPEN)
success = session_input_channel_req(c, rtype);
if (reply) {
packet_start(success ?