Merge branch '3.0-openchannel' into master-openchannel

This commit is contained in:
terrafrost 2023-05-07 11:35:24 -05:00
commit e6f86e1770
2 changed files with 10 additions and 4 deletions

View File

@ -349,8 +349,6 @@ class SFTP extends SSH2
*/
private function partial_init_sftp_connection(): bool
{
$this->window_size_server_to_client[self::CHANNEL] = $this->window_size;
$response = $this->openChannel(self::CHANNEL, true);
if ($response === true && $this->isTimeout()) {
return false;

View File

@ -2754,6 +2754,10 @@ class SSH2
*/
public function read(string $expect = '', int $mode = self::READ_SIMPLE, int $channel = null)
{
if (!$this->isAuthenticated()) {
throw new InsufficientSetupException('Operation disallowed prior to login()');
}
$this->curTimeout = $this->timeout;
$this->is_timeout = false;
@ -2761,7 +2765,7 @@ class SSH2
$channel = $this->get_interactive_channel();
}
if (!$this->isInteractiveChannelOpen($channel) && empty($this->channel_buffers[$channel])) {
if (!$this->is_channel_status_data($channel) && empty($this->channel_buffers[$channel])) {
if ($channel != self::CHANNEL_SHELL) {
throw new InsufficientSetupException('Data is not available on channel');
} elseif (!$this->openShell()) {
@ -2809,11 +2813,15 @@ class SSH2
*/
public function write(string $cmd, int $channel = null): void
{
if (!$this->isAuthenticated()) {
throw new InsufficientSetupException('Operation disallowed prior to login()');
}
if ($channel === null) {
$channel = $this->get_interactive_channel();
}
if (!$this->isInteractiveChannelOpen($channel)) {
if (!$this->is_channel_status_data($channel)) {
if ($channel != self::CHANNEL_SHELL) {
throw new InsufficientSetupException('Data is not available on channel');
} elseif (!$this->openShell()) {