Subject: Re: Who's at fault here?

From: der Mouse <[email-masked]>
Date: Thu, 1 Dec 2005 00:41:39 -0500 (EST)

>>> The thing is, the implementation I'm talking to (which is bannering
>>> as "SSH-1.99-OpenSSH_3.4 NetBSD_Secure_Shell-20020626") is logging
>>> "Received window adjust for non-open channel 0." in response to
>>> this.
>> This sort of thing can happen with "window-change" channel requests
>> received before the shell/exec/subsystem channel requests on the
>> same channel.

That was my own conclusion after some grubbing around in the OpenSSH
source code (modulo the exact wording; see below).  Looking at my debug
traces, that sure seems to be exactly what's happening, and looking
over my code, I can see how and when it happens.

> But it shouldn't, should it?

> My reading of the draft has always been it is legal to send a window
> adjust any time the channel is open.

That's my reading too, which is why I suspected this of being a bug in
OpenSSH rather than in my code.

> Wait... did you say "window-change" ?  As in the size of the screen
> changed message.

I can't attribute that to anything but a mistake by Nicolas.  There are
no "window-change" SSH_MSG_CHANNEL_REQUEST messages involved in the
cases I've looked at; SSH_MSG_CHANNEL_WINDOW_ADJUST messages are what I
was talking about.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       [email-masked]
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

---

From: Nicolas Williams <[email-masked]>
Date: Thu, 1 Dec 2005 00:53:35 -0600

On Wed, Nov 30, 2005 at 09:30:51PM -0700, Joseph Galbraith wrote:
> Nicolas Williams wrote:
> > On Fri, Oct 21, 2005 at 12:26:29AM -0400, der Mouse wrote:
> >> The thing is, the implementation I'm talking to (which is bannering as
> >> "SSH-1.99-OpenSSH_3.4 NetBSD_Secure_Shell-20020626") is logging
> >> "Received window adjust for non-open channel 0." in response to this.
> > 
> > received before the shell/exec/subsystem channel requests on the same
> > channel.
> 

Indeed, it shouldn't, by my reading.

> My reading of the draft has always been it is legal to send a
> window adjust any time the channel is open.
> 
> Wait... did you say "window-change" ?  As in the size of the
> screen changed message.  Are you saying the error is ...

I meant that this type of error happens when "window-change" channel
requests...  Not that that very same error message message is elicited.

> unclear ... and should really read "Received window-change
> for non-open channel 0?" and it occurs because a "window-change"
> was sent before pty has been allocated?

The issue is that the window-change request may be sent before the
shell/exec/subsystem request but after the pty-req request.

Our bug ID for it is:

6336266 ssh SIGWINCH handling races; some servers are very unforgiving

Nico
--

---

From: Nicolas Williams <[email-masked]>
Date: Thu, 1 Dec 2005 01:02:22 -0600

> cases I've looked at; SSH_MSG_CHANNEL_WINDOW_ADJUST messages are what I

There are in cases I've seen that are similar to what you described,
only involving window-change instead of window adjusts (oof, confusing
terms).

Nico
--

---

From: der Mouse <[email-masked]>
Date: Thu, 1 Dec 2005 10:27:36 -0500 (EST)

>>> Wait... did you say "window-change" ?
>> I can't attribute that to anything but a mistake by Nicolas.  [...]
> only involving window-change instead of window adjusts

Aha.  My apologies for thinking it was a mistake you made, then.  Given
what I saw of the OpenSSH code, though, it's not surprising, since it
doesn't seem to consider session channels "real" until the
shell/exec/etc request has come in - I would expect a lot of things to
fail when applied to such channels.  (I didn't dig into it enough to
know exactly what things.)

> (oof, confusing terms).

Quite.  Too many "window"s floating around.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign

---

From: Nicolas Williams <[email-masked]>
Date: Thu, 1 Dec 2005 11:20:03 -0600

> know exactly what things.)

Well, recent versions of the OpenSSH server do the right thing, IIRC,
older versions didn't.  The client still sends window-change requests
too soon for broken servers, but the client could be smarter about this.

Hmmm, delaying a window-change request until after the shell/exec/
subsystem request might lead to the app starting to draw with the wrong
window size -- not pretty, but the app will get the size change
notification eventually.  Not delaying it can cause broken servers to
disconnect -- worse than not pretty.

A job for the compat db?  Sigh.

> Quite.  Too many "window"s floating around.

Yes.  Wish that had been "terminal-size-change" -- but it is what it is.

Nico
--