diff options
author | Juan Pablo Villafáñez <jvillafanez@solidgear.es> | 2017-03-27 08:50:03 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-04-26 16:23:52 +0200 |
commit | 71012b3432239eba6746fdcee0f3fc6fb6622e33 (patch) | |
tree | dd6024cfc72799c08e2c0b93c9abefb5fb589005 /apps | |
parent | 5b5c3a1773dab4960d41aafc4150859a308311b7 (diff) | |
download | nextcloud-server-71012b3432239eba6746fdcee0f3fc6fb6622e33.tar.gz nextcloud-server-71012b3432239eba6746fdcee0f3fc6fb6622e33.zip |
Adjust SMB permissions on the root
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SMB.php | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index cc4cd641ce5..859fceb50aa 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -162,10 +162,48 @@ class SMB extends Common implements INotifyStorage { * @return array */ protected function formatInfo($info) { - return array( + $result = [ 'size' => $info->getSize(), - 'mtime' => $info->getMTime() - ); + 'mtime' => $info->getMTime(), + ]; + if ($info->isDirectory()) { + $result['type'] = 'dir'; + } else { + $result['type'] = 'file'; + } + return $result; + } + + /** + * Rename the files. If the source or the target is the root, the rename won't happen. + * + * @param string $source the old name of the path + * @param string $target the new name of the path + * @return bool true if the rename is successful, false otherwise + */ + public function rename($source, $target) { + $this->log("enter: rename('$source', '$target')", Util::DEBUG); + + if ($this->isRootDir($source) || $this->isRootDir($target)) { + $this->log("refusing to rename \"$source\" to \"$target\""); + return $this->leave(__FUNCTION__, false); + } + + try { + $result = $this->share->rename($this->root . $source, $this->root . $target); + $this->removeFromCache($this->root . $source); + $this->removeFromCache($this->root . $target); + } catch (AlreadyExistsException $e) { + $this->unlink($target); + $result = $this->share->rename($this->root . $source, $this->root . $target); + $this->removeFromCache($this->root . $source); + $this->removeFromCache($this->root . $target); + $this->swallow(__FUNCTION__, $e); + } catch (\Exception $e) { + $this->swallow(__FUNCTION__, $e); + $result = false; + } + return $this->leave(__FUNCTION__, $result); } /** @@ -220,6 +258,13 @@ class SMB extends Common implements INotifyStorage { * @return bool */ public function unlink($path) { + $this->log('enter: '.__FUNCTION__."($path)"); + + if ($this->isRootDir($path)) { + $this->log("refusing to unlink \"$path\""); + return $this->leave(__FUNCTION__, false); + } + try { if ($this->is_dir($path)) { return $this->rmdir($path); @@ -343,6 +388,13 @@ class SMB extends Common implements INotifyStorage { } public function rmdir($path) { + $this->log('enter: '.__FUNCTION__."($path)"); + + if ($this->isRootDir($path)) { + $this->log("refusing to delete \"$path\""); + return $this->leave(__FUNCTION__, false); + } + try { $this->statCache = array(); $content = $this->share->dir($this->buildPath($path)); @@ -439,6 +491,8 @@ class SMB extends Common implements INotifyStorage { } public function isUpdatable($path) { + $this->log('enter: '.__FUNCTION__."($path)"); + $result = false; try { $info = $this->getFileInfo($path); // following windows behaviour for read-only folders: they can be written into @@ -449,9 +503,12 @@ class SMB extends Common implements INotifyStorage { } catch (ForbiddenException $e) { return false; } + return $this->leave(__FUNCTION__, $result); } public function isDeletable($path) { + $this->log('enter: '.__FUNCTION__."($path)"); + $result = false; try { $info = $this->getFileInfo($path); return !$info->isHidden() && !$info->isReadOnly(); |