1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-11 16:49:42 +01:00

SFTP: rm NO_REALPATH changes

This commit is contained in:
terrafrost 2017-06-05 01:30:30 -05:00
parent 55623933f3
commit 0bb6c9b974

View File

@ -96,29 +96,25 @@ define('NET_SFTP_CHANNEL', 0x100);
/**
* Reads data from a local file.
*/
define('NET_SFTP_LOCAL_FILE', 0x1);
define('NET_SFTP_LOCAL_FILE', 1);
/**
* Reads data from a string.
*/
// this value isn't really used anymore but i'm keeping it reserved for historical reasons
define('NET_SFTP_STRING', 0x2);
define('NET_SFTP_STRING', 2);
/**
* Reads data from callback:
* function callback($length) returns string to proceed, null for EOF
*/
define('NET_SFTP_CALLBACK', 0x10);
define('NET_SFTP_CALLBACK', 16);
/**
* Resumes an upload
*/
define('NET_SFTP_RESUME', 0x4);
define('NET_SFTP_RESUME', 4);
/**
* Append a local file to an already existing remote file
*/
define('NET_SFTP_RESUME_START', 0x8);
/**
* Skip canonicalizing the remote path
*/
define('NET_SFTP_NO_REALPATH', 0x20);
define('NET_SFTP_RESUME_START', 8);
/**#@-*/
/**
@ -1891,9 +1887,8 @@ class Net_SFTP extends Net_SSH2
* Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take
* care of that, yourself.
*
* $mode can take three additional parameters - NET_SFTP_RESUME, NET_SFTP_RESUME_START and NET_SFTP_NO_REALPATH. These
* are bitwise AND'd with $mode. So if you want to resume upload of a 300mb file on the local file system you'd set $mode
* to the following:
* $mode can take an additional two parameters - NET_SFTP_RESUME and NET_SFTP_RESUME_START. These are bitwise AND'd with
* $mode. So if you want to resume upload of a 300mb file on the local file system you'd set $mode to the following:
*
* NET_SFTP_LOCAL_FILE | NET_SFTP_RESUME
*
@ -1909,9 +1904,6 @@ class Net_SFTP extends Net_SSH2
*
* Setting $local_start to > 0 or $mode | NET_SFTP_RESUME_START doesn't do anything unless $mode | NET_SFTP_LOCAL_FILE.
*
* Passing self::NO_REALPATH skips canonicalization of the remote path; $remote_file will be passed verbatim to the
* remote host.
*
* @param string $remote_file
* @param string|resource $data
* @param int $mode
@ -1928,11 +1920,9 @@ class Net_SFTP extends Net_SSH2
return false;
}
if (!($mode & NET_SFTP_NO_REALPATH)) {
$remote_file = $this->_realpath($remote_file);
if ($remote_file === false) {
return false;
}
$remote_file = $this->_realpath($remote_file);
if ($remote_file === false) {
return false;
}
$this->_remove_from_stat_cache($remote_file);
@ -2163,11 +2153,9 @@ class Net_SFTP extends Net_SSH2
return false;
}
if (!($mode & NET_SFTP_NO_REALPATH)) {
$remote_file = $this->_realpath($remote_file);
if ($remote_file === false) {
return false;
}
$remote_file = $this->_realpath($remote_file);
if ($remote_file === false) {
return false;
}
$packet = pack('Na*N2', strlen($remote_file), $remote_file, NET_SFTP_OPEN_READ, 0);