Merge branch '3.0'

This commit is contained in:
terrafrost 2024-09-15 14:05:38 -05:00
commit 702ec756f4

View File

@ -3245,15 +3245,6 @@ class SFTP extends SSH2
return false; return false;
} }
$testA = $this->version >= 5;
$testB = isset($this->extensions['posix-rename@openssh.com']) && $this->extensions['posix-rename@openssh.com'] === '1';
if (!$testA && !$testB) {
throw new RuntimeException(
"Extension 'posix-rename@openssh.com' is not supported by the server. " .
"Call getSupportedVersions() to see a list of supported extension"
);
}
$oldname = $this->realpath($oldname); $oldname = $this->realpath($oldname);
$newname = $this->realpath($newname); $newname = $this->realpath($newname);
if ($oldname === false || $newname === false) { if ($oldname === false || $newname === false) {
@ -3263,9 +3254,14 @@ class SFTP extends SSH2
if ($this->version >= 5) { if ($this->version >= 5) {
$packet = Strings::packSSH2('ssN', $oldname, $newname, 2); // 2 = SSH_FXP_RENAME_ATOMIC $packet = Strings::packSSH2('ssN', $oldname, $newname, 2); // 2 = SSH_FXP_RENAME_ATOMIC
$this->send_sftp_packet(PacketType::RENAME, $packet); $this->send_sftp_packet(PacketType::RENAME, $packet);
} else { } elseif (isset($this->extensions['posix-rename@openssh.com']) && $this->extensions['posix-rename@openssh.com'] === '1') {
$packet = Strings::packSSH2('sss', 'posix-rename@openssh.com', $oldname, $newname); $packet = Strings::packSSH2('sss', 'posix-rename@openssh.com', $oldname, $newname);
$this->send_sftp_packet(PacketType::EXTENDED, $packet); $this->send_sftp_packet(PacketType::EXTENDED, $packet);
} else {
throw new RuntimeException(
"Extension 'posix-rename@openssh.com' is not supported by the server. " .
"Call getSupportedVersions() to see a list of supported extension"
);
} }
$response = $this->get_sftp_packet(); $response = $this->get_sftp_packet();