mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-15 17:57:12 +00:00
Merge branch '3.0'
This commit is contained in:
commit
5ea7be57da
@ -1695,9 +1695,6 @@ class SFTP extends SSH2
|
||||
}
|
||||
|
||||
$dir = $this->realpath($dir);
|
||||
// by not providing any permissions, hopefully the server will use the logged in users umask - their
|
||||
// default permissions.
|
||||
$attr = $mode == -1 ? "\0\0\0\0" : pack('N2', NET_SFTP_ATTR_PERMISSIONS, $mode & 07777);
|
||||
|
||||
if ($recursive) {
|
||||
$dirs = explode('/', preg_replace('#/(?=/)|/$#', '', $dir));
|
||||
@ -1708,12 +1705,12 @@ class SFTP extends SSH2
|
||||
for ($i = 0; $i < count($dirs); $i++) {
|
||||
$temp = array_slice($dirs, 0, $i + 1);
|
||||
$temp = implode('/', $temp);
|
||||
$result = $this->mkdir_helper($temp, $attr);
|
||||
$result = $this->mkdir_helper($temp, $mode);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $this->mkdir_helper($dir, $attr);
|
||||
return $this->mkdir_helper($dir, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1724,9 +1721,10 @@ class SFTP extends SSH2
|
||||
* @return bool
|
||||
* @access private
|
||||
*/
|
||||
private function mkdir_helper($dir, $attr)
|
||||
private function mkdir_helper($dir, $mode)
|
||||
{
|
||||
if (!$this->send_sftp_packet(NET_SFTP_MKDIR, Strings::packSSH2('s', $dir) . $attr)) {
|
||||
// send SSH_FXP_MKDIR without any attributes (that's what the \0\0\0\0 is doing)
|
||||
if (!$this->send_sftp_packet(NET_SFTP_MKDIR, Strings::packSSH2('s', $dir) . "\0\0\0\0")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1742,6 +1740,10 @@ class SFTP extends SSH2
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($mode !== -1) {
|
||||
$this->chmod($mode, $dir);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user