1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-14 18:15:39 +01:00

Merge branch '3.0'

This commit is contained in:
terrafrost 2021-04-02 10:28:04 -05:00
commit 62c69d8372

View File

@ -2774,11 +2774,11 @@ class SSH2
$terminal_modes = pack('C', NET_SSH2_TTY_OP_END);
$packet = Strings::packSSH2(
'CNsCsN4s',
'CNsbsN4s',
NET_SSH2_MSG_CHANNEL_REQUEST,
$this->server_channels[self::CHANNEL_SHELL],
'pty-req',
1,
true, // want reply
$this->term,
$this->windowColumns,
$this->windowRows,
@ -2789,24 +2789,6 @@ class SSH2
$this->send_binary_packet($packet);
$response = $this->get_binary_packet();
if ($response === false) {
$this->disconnect_helper(NET_SSH2_DISCONNECT_CONNECTION_LOST);
throw new ConnectionClosedException('Connection closed by server');
}
list($type) = Strings::unpackSSH2('C', $response);
switch ($type) {
case NET_SSH2_MSG_CHANNEL_SUCCESS:
// if a pty can't be opened maybe commands can still be executed
case NET_SSH2_MSG_CHANNEL_FAILURE:
break;
default:
$this->disconnect_helper(NET_SSH2_DISCONNECT_BY_APPLICATION);
throw new \UnexpectedValueException('Unable to request pseudo-terminal');
}
$packet = Strings::packSSH2(
'CNsb',
NET_SSH2_MSG_CHANNEL_REQUEST,
@ -2816,14 +2798,7 @@ class SSH2
);
$this->send_binary_packet($packet);
$this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_REQUEST;
$response = $this->get_channel_packet(self::CHANNEL_SHELL);
if ($response === false) {
return false;
}
$this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_DATA;
$this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_IGNORE;
$this->bitmap |= self::MASK_SHELL;
@ -3830,6 +3805,16 @@ class SSH2
throw new \RuntimeException('Unable to open channel');
}
break;
case NET_SSH2_MSG_IGNORE:
switch ($type) {
case NET_SSH2_MSG_CHANNEL_SUCCESS:
//$this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_DATA;
continue 3;
case NET_SSH2_MSG_CHANNEL_FAILURE:
$this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
throw new \RuntimeException('Error opening channel');
}
break;
case NET_SSH2_MSG_CHANNEL_REQUEST:
switch ($type) {
case NET_SSH2_MSG_CHANNEL_SUCCESS:
@ -3849,6 +3834,10 @@ class SSH2
switch ($type) {
case NET_SSH2_MSG_CHANNEL_DATA:
//if ($this->channel_status[$channel] == NET_SSH2_MSG_IGNORE) {
// $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_DATA;
//}
/*
if ($channel == self::CHANNEL_EXEC) {
// SCP requires null packets, such as this, be sent. further, in the case of the ssh.com SSH server