mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-10 23:58:38 +00:00
SFTP: attempt to utilize SFTP via CLI if subsystem is unavailable
This commit is contained in:
parent
b2262f731d
commit
cb10016291
@ -410,9 +410,26 @@ class Net_SFTP extends Net_SSH2 {
|
|||||||
|
|
||||||
$response = $this->_get_channel_packet(NET_SFTP_CHANNEL);
|
$response = $this->_get_channel_packet(NET_SFTP_CHANNEL);
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
|
// from PuTTY's psftp.exe
|
||||||
|
$command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" .
|
||||||
|
"test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" .
|
||||||
|
"exec sftp-server";
|
||||||
|
// we don't do $this->exec($command, false) because exec() operates on a different channel and plus the SSH_MSG_CHANNEL_OPEN that exec() does
|
||||||
|
// is redundant
|
||||||
|
$packet = pack('CNNa*CNa*',
|
||||||
|
NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SFTP_CHANNEL], strlen('exec'), 'exec', 1, strlen($command), $command);
|
||||||
|
if (!$this->_send_binary_packet($packet)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_REQUEST;
|
||||||
|
|
||||||
|
$response = $this->_get_channel_packet(NET_SFTP_CHANNEL);
|
||||||
|
if ($response === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_DATA;
|
$this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_DATA;
|
||||||
|
|
||||||
if (!$this->_send_sftp_packet(NET_SFTP_INIT, "\0\0\0\3")) {
|
if (!$this->_send_sftp_packet(NET_SFTP_INIT, "\0\0\0\3")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user