summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--channels.h3
-rw-r--r--clientloop.c5
-rw-r--r--nchan.c30
-rw-r--r--serverloop.c7
5 files changed, 48 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index fd75c3404..7d9b0f853 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -133,6 +133,13 @@
133 for channels with both in- and output closed, since the channel 133 for channels with both in- and output closed, since the channel
134 will go away before we call select(); 134 will go away before we call select();
135 report, lots of debugging help and ok djm@ 135 report, lots of debugging help and ok djm@
136 - markus@cvs.openbsd.org 2008/05/09 16:21:13
137 [channels.h clientloop.c nchan.c serverloop.c]
138 unbreak
139 ssh -2 localhost od /bin/ls | true
140 ignoring SIGPIPE by adding a new channel message (EOW) that signals
141 the peer that we're not interested in any data it might send.
142 fixes bz #85; discussion, debugging and ok djm@
136 143
13720080403 14420080403
138 - (djm) [openbsd-compat/bsd-poll.c] Include stdlib.h to avoid compile- 145 - (djm) [openbsd-compat/bsd-poll.c] Include stdlib.h to avoid compile-
@@ -3993,4 +4000,4 @@
3993 OpenServer 6 and add osr5bigcrypt support so when someone migrates 4000 OpenServer 6 and add osr5bigcrypt support so when someone migrates
3994 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 4001 passwords between UnixWare and OpenServer they will still work. OK dtucker@
3995 4002
3996$Id: ChangeLog,v 1.4929 2008/05/19 06:05:41 djm Exp $ 4003$Id: ChangeLog,v 1.4930 2008/05/19 06:06:47 djm Exp $
diff --git a/channels.h b/channels.h
index d4ac24a51..ec2435df0 100644
--- a/channels.h
+++ b/channels.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.h,v 1.91 2008/05/09 04:55:56 djm Exp $ */ 1/* $OpenBSD: channels.h,v 1.92 2008/05/09 16:21:13 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -267,6 +267,7 @@ void chan_mark_dead(Channel *);
267/* channel events */ 267/* channel events */
268 268
269void chan_rcvd_oclose(Channel *); 269void chan_rcvd_oclose(Channel *);
270void chan_rcvd_eow(Channel *); /* SSH2-only */
270void chan_read_failed(Channel *); 271void chan_read_failed(Channel *);
271void chan_ibuf_empty(Channel *); 272void chan_ibuf_empty(Channel *);
272 273
diff --git a/clientloop.c b/clientloop.c
index c87aa5a0a..584afb76a 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.192 2008/05/09 14:18:44 djm Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.193 2008/05/09 16:21:13 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1666,6 +1666,9 @@ client_input_channel_req(int type, u_int32_t seq, void *ctxt)
1666 error("client_input_channel_req: request for channel -1"); 1666 error("client_input_channel_req: request for channel -1");
1667 } else if ((c = channel_lookup(id)) == NULL) { 1667 } else if ((c = channel_lookup(id)) == NULL) {
1668 error("client_input_channel_req: channel %d: unknown channel", id); 1668 error("client_input_channel_req: channel %d: unknown channel", id);
1669 } else if (strcmp(rtype, "eow@openssh.com") == 0) {
1670 packet_check_eom();
1671 chan_rcvd_eow(c);
1669 } else if (strcmp(rtype, "exit-status") == 0) { 1672 } else if (strcmp(rtype, "exit-status") == 0) {
1670 exitval = packet_get_int(); 1673 exitval = packet_get_int();
1671 if (id == session_ident) { 1674 if (id == session_ident) {
diff --git a/nchan.c b/nchan.c
index 0d0faddb3..a4a456eab 100644
--- a/nchan.c
+++ b/nchan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: nchan.c,v 1.58 2008/05/08 12:02:23 djm Exp $ */ 1/* $OpenBSD: nchan.c,v 1.59 2008/05/09 16:21:13 markus Exp $ */
2/* 2/*
3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved. 3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
4 * 4 *
@@ -78,6 +78,7 @@ static void chan_send_ieof1(Channel *);
78static void chan_send_oclose1(Channel *); 78static void chan_send_oclose1(Channel *);
79static void chan_send_close2(Channel *); 79static void chan_send_close2(Channel *);
80static void chan_send_eof2(Channel *); 80static void chan_send_eof2(Channel *);
81static void chan_send_eow2(Channel *);
81 82
82/* helper */ 83/* helper */
83static void chan_shutdown_write(Channel *); 84static void chan_shutdown_write(Channel *);
@@ -306,6 +307,17 @@ chan_rcvd_close2(Channel *c)
306 break; 307 break;
307 } 308 }
308} 309}
310void
311chan_rcvd_eow(Channel *c)
312{
313 debug2("channel %d: rcvd eow", c->self);
314 switch (c->istate) {
315 case CHAN_INPUT_OPEN:
316 chan_shutdown_read(c);
317 chan_set_istate(c, CHAN_INPUT_CLOSED);
318 break;
319 }
320}
309static void 321static void
310chan_rcvd_eof2(Channel *c) 322chan_rcvd_eof2(Channel *c)
311{ 323{
@@ -322,6 +334,7 @@ chan_write_failed2(Channel *c)
322 case CHAN_OUTPUT_OPEN: 334 case CHAN_OUTPUT_OPEN:
323 case CHAN_OUTPUT_WAIT_DRAIN: 335 case CHAN_OUTPUT_WAIT_DRAIN:
324 chan_shutdown_write(c); 336 chan_shutdown_write(c);
337 chan_send_eow2(c);
325 chan_set_ostate(c, CHAN_OUTPUT_CLOSED); 338 chan_set_ostate(c, CHAN_OUTPUT_CLOSED);
326 break; 339 break;
327 default: 340 default:
@@ -364,6 +377,21 @@ chan_send_close2(Channel *c)
364 c->flags |= CHAN_CLOSE_SENT; 377 c->flags |= CHAN_CLOSE_SENT;
365 } 378 }
366} 379}
380static void
381chan_send_eow2(Channel *c)
382{
383 debug2("channel %d: send eow", c->self);
384 if (c->ostate == CHAN_OUTPUT_CLOSED) {
385 error("channel %d: must not sent eow on closed output",
386 c->self);
387 return;
388 }
389 packet_start(SSH2_MSG_CHANNEL_REQUEST);
390 packet_put_int(c->remote_id);
391 packet_put_cstring("eow@openssh.com");
392 packet_put_char(0);
393 packet_send();
394}
367 395
368/* shared */ 396/* shared */
369 397
diff --git a/serverloop.c b/serverloop.c
index 2142f3809..6bc140f8b 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: serverloop.c,v 1.150 2008/05/09 04:55:56 djm Exp $ */ 1/* $OpenBSD: serverloop.c,v 1.151 2008/05/09 16:21:13 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1160,7 +1160,10 @@ server_input_channel_req(int type, u_int32_t seq, void *ctxt)
1160 if ((c = channel_lookup(id)) == NULL) 1160 if ((c = channel_lookup(id)) == NULL)
1161 packet_disconnect("server_input_channel_req: " 1161 packet_disconnect("server_input_channel_req: "
1162 "unknown channel %d", id); 1162 "unknown channel %d", id);
1163 if (c->type == SSH_CHANNEL_LARVAL || c->type == SSH_CHANNEL_OPEN) 1163 if (!strcmp(rtype, "eow@openssh.com")) {
1164 packet_check_eom();
1165 chan_rcvd_eow(c);
1166 } else if (c->type == SSH_CHANNEL_LARVAL || c->type == SSH_CHANNEL_OPEN)
1164 success = session_input_channel_req(c, rtype); 1167 success = session_input_channel_req(c, rtype);
1165 if (reply) { 1168 if (reply) {
1166 packet_start(success ? 1169 packet_start(success ?