phpseclib/phpseclib — pull request #264 by terrafrost (2014-02-03 06:07:09+00:00)
Title: SSH2: ignore exit_status channel requests

Fixes #258 I think.

First, both logs show that an exit-status channel request was sent to the client from the server. The client (phpseclib) then closed the connection. The server still sent some info, however, before finally closing the connection off.

Ultimately, I think this problem, in turn, stems from an RFC ([RFC4254](http://tools.ietf.org/html/rfc4254#section-6.10)) that imho is unnecessary vague at some points. Quoting it...

```
When the command running at the other end terminates, the following
message can be sent to return the exit status of the command.
Returning the status is RECOMMENDED. No acknowledgement is sent for
this message. The channel needs to be closed with
SSH_MSG_CHANNEL_CLOSE after this message.

The client MAY ignore these messages.

byte SSH_MSG_CHANNEL_REQUEST
uint32 recipient channel
string "exit-status"
boolean FALSE
uint32 exit_status
```

It says the channel needs to be closed but it doesn't say by whom. phpseclib had been doing the closing but now I'm wondering if the subtext (since "the client MAY ignore these messages") is that it's the server that should be doing the closing and not the client.

That's what this commit does.

I was able to duplicate the problem described in #258 by uploading a file containing the letter a 1024 * 1024 times and this fix fixed it for me.