mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-09-28 07:09:01 +00:00
SFTP: change the mode with a SETSTAT instead of MKDIR
This commit is contained in:
parent
645dc5c817
commit
5e2951f83a
@ -1831,9 +1831,6 @@ class Net_SFTP extends Net_SSH2
|
|||||||
}
|
}
|
||||||
|
|
||||||
$dir = $this->_realpath($dir);
|
$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) {
|
if ($recursive) {
|
||||||
$dirs = explode('/', preg_replace('#/(?=/)|/$#', '', $dir));
|
$dirs = explode('/', preg_replace('#/(?=/)|/$#', '', $dir));
|
||||||
@ -1844,12 +1841,12 @@ class Net_SFTP extends Net_SSH2
|
|||||||
for ($i = 0; $i < count($dirs); $i++) {
|
for ($i = 0; $i < count($dirs); $i++) {
|
||||||
$temp = array_slice($dirs, 0, $i + 1);
|
$temp = array_slice($dirs, 0, $i + 1);
|
||||||
$temp = implode('/', $temp);
|
$temp = implode('/', $temp);
|
||||||
$result = $this->_mkdir_helper($temp, $attr);
|
$result = $this->_mkdir_helper($temp, $mode);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_mkdir_helper($dir, $attr);
|
return $this->_mkdir_helper($dir, $mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1859,9 +1856,10 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _mkdir_helper($dir, $attr)
|
function _mkdir_helper($dir, $mode)
|
||||||
{
|
{
|
||||||
if (!$this->_send_sftp_packet(NET_SFTP_MKDIR, pack('Na*a*', strlen($dir), $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, pack('Na*a*', strlen($dir), $dir, "\0\0\0\0"))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1880,6 +1878,10 @@ class Net_SFTP extends Net_SSH2
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($mode !== -1) {
|
||||||
|
$this->chmod($mode, $dir);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user