mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-03 18:18:05 +01:00
SFTP: reopen channel on channel closure
This commit is contained in:
parent
b07738814e
commit
9c47b0a696
@ -310,6 +310,16 @@ class Net_SFTP extends Net_SSH2
|
||||
*/
|
||||
var $preserveTime = false;
|
||||
|
||||
/**
|
||||
* Was the last packet due to the channels being closed or not?
|
||||
*
|
||||
* @see self::get()
|
||||
* @see self::get_sftp_packet()
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $channel_close = false;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
@ -484,6 +494,17 @@ class Net_SFTP extends Net_SSH2
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->_init_sftp_connection();
|
||||
}
|
||||
|
||||
/**
|
||||
* (Re)initializes the SFTP channel
|
||||
*
|
||||
* @return bool
|
||||
* @access private
|
||||
*/
|
||||
function _init_sftp_connection()
|
||||
{
|
||||
$this->window_size_server_to_client[NET_SFTP_CHANNEL] = $this->window_size;
|
||||
|
||||
$packet = pack(
|
||||
@ -2354,7 +2375,13 @@ class Net_SFTP extends Net_SSH2
|
||||
if ($fclose_check) {
|
||||
fclose($fp);
|
||||
}
|
||||
user_error('Expected SSH_FX_DATA or SSH_FXP_STATUS');
|
||||
// maybe the file was successfully transferred, maybe it wasn't
|
||||
if ($this->channel_close) {
|
||||
$this->_init_sftp_connection();
|
||||
return false;
|
||||
} else {
|
||||
user_error('Expected SSH_FX_DATA or SSH_FXP_STATUS');
|
||||
}
|
||||
}
|
||||
$response = null;
|
||||
}
|
||||
@ -3116,6 +3143,8 @@ class Net_SFTP extends Net_SSH2
|
||||
*/
|
||||
function _get_sftp_packet($request_id = null)
|
||||
{
|
||||
$this->channel_close = false;
|
||||
|
||||
if (isset($request_id) && isset($this->requestBuffer[$request_id])) {
|
||||
$this->packet_type = $this->requestBuffer[$request_id]['packet_type'];
|
||||
$temp = $this->requestBuffer[$request_id]['packet'];
|
||||
@ -3132,7 +3161,10 @@ class Net_SFTP extends Net_SSH2
|
||||
// SFTP packet length
|
||||
while (strlen($this->packet_buffer) < 4) {
|
||||
$temp = $this->_get_channel_packet(NET_SFTP_CHANNEL, true);
|
||||
if (is_bool($temp)) {
|
||||
if ($temp === true) {
|
||||
if ($this->channel_status[NET_SFTP_CHANNEL] === NET_SSH2_MSG_CHANNEL_CLOSE) {
|
||||
$this->channel_close = true;
|
||||
}
|
||||
$this->packet_type = false;
|
||||
$this->packet_buffer = '';
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user