From b26f14e5feab0f7181f44a7a94772a7b80bc8e0f Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 17 Dec 2016 16:09:48 -0600 Subject: [PATCH 1/2] SSH2: make it so disabling PTY closes exec() channel if it's open --- phpseclib/Net/SSH2.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 8bf9a805..68de7fbc 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2601,6 +2601,11 @@ class Net_SSH2 return false; } + if ($this->in_request_pty_exec) { + user_error('If you want to run multiple exec()\'s you will need to disable (and re-enable if appropriate) a PTY for each one.'); + return false; + } + // RFC4254 defines the (client) window size as "bytes the other party can send before it must wait for the window to // be adjusted". 0x7FFFFFFF is, at 2GB, the max size. technically, it should probably be decremented, but, // honestly, if you're transferring more than 2GB, you probably shouldn't be using phpseclib, anyway. @@ -3408,6 +3413,10 @@ class Net_SSH2 */ function disablePTY() { + if ($this->in_request_pty_exec) { + $this->_close_channel(NET_SSH2_CHANNEL_EXEC); + $this->in_request_pty_exec = false; + } $this->request_pty = false; } From 95335f95608a152c1490e3c3e3086eaa86eb93e5 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 24 Dec 2016 21:20:13 -0600 Subject: [PATCH 2/2] SSH2: update PTY changes for 2.0 branch --- phpseclib/Net/SSH2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index ed506c29..b6aed420 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -3312,7 +3312,7 @@ class SSH2 function disablePTY() { if ($this->in_request_pty_exec) { - $this->_close_channel(NET_SSH2_CHANNEL_EXEC); + $this->_close_channel(self::CHANNEL_EXEC); $this->in_request_pty_exec = false; } $this->request_pty = false;