aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php')
-rw-r--r--vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php52
1 files changed, 6 insertions, 46 deletions
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php
index ade0ea5ca..0c06c35f4 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php
@@ -718,16 +718,7 @@ class SFTP extends SSH2
return false;
}
- $this->pwd = true;
$this->pwd = $this->_realpath('.');
- if ($this->pwd === false) {
- if (!$this->canonicalize_paths) {
- user_error('Unable to canonicalize current working directory');
- return false;
- }
- $this->canonicalize_paths = false;
- $this->_reset_connection(NET_SSH2_DISCONNECT_CONNECTION_LOST);
- }
$this->_update_stat_cache($this->pwd, array());
@@ -775,9 +766,7 @@ class SFTP extends SSH2
}
/**
- * Disable path canonicalization
- *
- * If this is enabled then $sftp->pwd() will not return the canonicalized absolute path
+ * Enable path canonicalization
*
* @access public
*/
@@ -883,37 +872,10 @@ class SFTP extends SSH2
function _realpath($path)
{
if (!$this->canonicalize_paths) {
- if ($this->pwd === true) {
- return '.';
- }
- if (!strlen($path) || $path[0] != '/') {
- $path = $this->pwd . '/' . $path;
- }
-
- $parts = explode('/', $path);
- $afterPWD = $beforePWD = [];
- foreach ($parts as $part) {
- switch ($part) {
- //case '': // some SFTP servers /require/ double /'s. see https://github.com/phpseclib/phpseclib/pull/1137
- case '.':
- break;
- case '..':
- if (!empty($afterPWD)) {
- array_pop($afterPWD);
- } else {
- $beforePWD[] = '..';
- }
- break;
- default:
- $afterPWD[] = $part;
- }
- }
-
- $beforePWD = count($beforePWD) ? implode('/', $beforePWD) : '.';
- return $beforePWD . '/' . implode('/', $afterPWD);
+ return $path;
}
- if ($this->pwd === true) {
+ if ($this->pwd === false) {
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.9
if (!$this->_send_sftp_packet(NET_SFTP_REALPATH, pack('Na*', strlen($path), $path))) {
return false;
@@ -935,6 +897,7 @@ class SFTP extends SSH2
$this->_logError($response);
return false;
default:
+ user_error('Expected SSH_FXP_NAME or SSH_FXP_STATUS');
return false;
}
}
@@ -2310,7 +2273,7 @@ class SFTP extends SSH2
case is_resource($data):
$mode = $mode & ~self::SOURCE_LOCAL_FILE;
$info = stream_get_meta_data($data);
- if (isset($info['wrapper_type']) && $info['wrapper_type'] == 'PHP' && $info['stream_type'] == 'Input') {
+ if ($info['wrapper_type'] == 'PHP' && $info['stream_type'] == 'Input') {
$fp = fopen('php://memory', 'w+');
stream_copy_to_stream($data, $fp);
rewind($fp);
@@ -2746,7 +2709,7 @@ class SFTP extends SSH2
// normally $entries would have at least . and .. but it might not if the directories
// permissions didn't allow reading
if (empty($entries)) {
- $entries = array();
+ return false;
}
unset($entries['.'], $entries['..']);
@@ -3655,9 +3618,6 @@ class SFTP extends SSH2
while ($tempLength > 0) {
$temp = $this->_get_channel_packet(self::CHANNEL, true);
if (is_bool($temp)) {
- if ($temp && $this->channel_status[self::CHANNEL] === NET_SSH2_MSG_CHANNEL_CLOSE) {
- $this->channel_close = true;
- }
$this->packet_type = false;
$this->packet_buffer = '';
return false;