]> andersk Git - openssh.git/commitdiff
- markus@cvs.openbsd.org 2008/05/09 16:21:13
authordjm <djm>
Mon, 19 May 2008 06:06:47 +0000 (06:06 +0000)
committerdjm <djm>
Mon, 19 May 2008 06:06:47 +0000 (06:06 +0000)
     [channels.h clientloop.c nchan.c serverloop.c]
     unbreak
        ssh -2 localhost od /bin/ls | true
     ignoring SIGPIPE by adding a new channel message (EOW) that signals
     the peer that we're not interested in any data it might send.
     fixes bz #85; discussion, debugging and ok djm@

ChangeLog
channels.h
clientloop.c
nchan.c
serverloop.c

index 0c9e56a7bbff5fc01a75d5fb02bfa6da59aa85b9..702b488408e4a7f20e951969e37f793dfdac377e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      for channels with both in- and output closed, since the channel
      will go away before we call select();
      report, lots of debugging help and ok djm@
+   - markus@cvs.openbsd.org 2008/05/09 16:21:13
+     [channels.h clientloop.c nchan.c serverloop.c]
+     unbreak
+        ssh -2 localhost od /bin/ls | true
+     ignoring SIGPIPE by adding a new channel message (EOW) that signals
+     the peer that we're not interested in any data it might send.
+     fixes bz #85; discussion, debugging and ok djm@
 
 20080403
  - (djm) [openbsd-compat/bsd-poll.c] Include stdlib.h to avoid compile-
index d4ac24a5129e2dc408a1f31315dbbf369e3fc5c6..ec2435df0dc1f9b24e5e3b003177d55d774b20de 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: channels.h,v 1.91 2008/05/09 04:55:56 djm Exp $ */
+/* $OpenBSD: channels.h,v 1.92 2008/05/09 16:21:13 markus Exp $ */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -267,6 +267,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 *);
 
index c87aa5a0a2f2b4e11fe6a08db917cbdf8a42dbc7..584afb76ae5cd048830ffdd3e20dae2c676e0a39 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.c,v 1.192 2008/05/09 14:18:44 djm Exp $ */
+/* $OpenBSD: clientloop.c,v 1.193 2008/05/09 16:21:13 markus Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * 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)
                error("client_input_channel_req: request for channel -1");
        } else if ((c = channel_lookup(id)) == 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) {
                exitval = packet_get_int();
                if (id == session_ident) {
diff --git a/nchan.c b/nchan.c
index 0d0faddb3d889dea9aa3e53cfebc0e7cf2ac0abb..a4a456eab8f456f304d5f2608e8c2cd58f97d811 100644 (file)
--- a/nchan.c
+++ b/nchan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nchan.c,v 1.58 2008/05/08 12:02:23 djm Exp $ */
+/* $OpenBSD: nchan.c,v 1.59 2008/05/09 16:21:13 markus Exp $ */
 /*
  * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl.  All rights reserved.
  *
@@ -78,6 +78,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 *);
@@ -306,6 +307,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)
 {
@@ -322,6 +334,7 @@ chan_write_failed2(Channel *c)
        case CHAN_OUTPUT_OPEN:
        case CHAN_OUTPUT_WAIT_DRAIN:
                chan_shutdown_write(c);
+               chan_send_eow2(c);
                chan_set_ostate(c, CHAN_OUTPUT_CLOSED);
                break;
        default:
@@ -364,6 +377,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 */
 
index 2142f38098b00ba12a88ec1bb62d29662ec4f1db..6bc140f8bc6602f2f4fac4f33b53a709f23a55c5 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: serverloop.c,v 1.150 2008/05/09 04:55:56 djm Exp $ */
+/* $OpenBSD: serverloop.c,v 1.151 2008/05/09 16:21:13 markus Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * 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)
        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 ?
This page took 0.05357 seconds and 5 git commands to generate.