Merge branch '3.0'

This commit is contained in:
terrafrost 2024-05-18 20:47:14 -05:00
commit 60373f724c

View File

@ -858,7 +858,7 @@ class SSH2
/**
* Should we try to re-connect to re-establish keys?
*/
private bool $retry_connect = false;
private bool $login_credentials_finalized = false;
/**
* Binary Packet Buffer
@ -1938,7 +1938,7 @@ class SSH2
*/
public function login(string $username, ...$args): bool
{
if (!$this->retry_connect) {
if (!$this->login_credentials_finalized) {
$this->auth[] = func_get_args();
}
@ -2042,6 +2042,7 @@ class SSH2
foreach ($newargs as $arg) {
if ($this->login_helper($username, $arg)) {
$this->login_credentials_finalized = true;
return true;
}
}
@ -2069,10 +2070,14 @@ class SSH2
$this->send_binary_packet($packet);
try {
$bad_key_size_fix = $this->bad_key_size_fix;
$response = $this->get_binary_packet();
} catch (\Exception $e) {
if ($this->retry_connect) {
$this->retry_connect = false;
// bad_key_size_fix is only ever re-assigned to true
// under certain conditions. when it's newly set we'll
// retry the connection with that new setting but we'll
// only try it once.
if ($bad_key_size_fix != $this->bad_key_size_fix) {
$this->connect();
return $this->login_helper($username, $password);
}
@ -3136,7 +3141,6 @@ class SSH2
private function reconnect(): bool
{
$this->reset_connection(DisconnectReason::CONNECTION_LOST);
$this->retry_connect = true;
$this->connect();
foreach ($this->auth as $auth) {
$result = $this->login(...$auth);
@ -3155,7 +3159,6 @@ class SSH2
$this->hmac_check = $this->hmac_create = false;
$this->hmac_size = false;
$this->session_id = false;
$this->retry_connect = true;
$this->get_seq_no = $this->send_seq_no = 0;
$this->channel_status = [];
$this->channel_id_last_interactive = 0;