diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-21 12:57:54 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-26 11:07:01 +0100 |
commit | 77d136cbdffc02fb5c0d36652ca9babfd0283154 (patch) | |
tree | 3f967bb45335572f56e767263a89284b293f7c33 /apps/files_sharing/lib | |
parent | 0fab27f459d3276a2559cdee5693bfec8c2cf1c9 (diff) | |
download | nextcloud-server-77d136cbdffc02fb5c0d36652ca9babfd0283154.tar.gz nextcloud-server-77d136cbdffc02fb5c0d36652ca9babfd0283154.zip |
Apply share permission mask to all files obtained via shareinfo
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareInfoController.php | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php index 5ecf00321fc..5aea32fe064 100644 --- a/apps/files_sharing/lib/Controller/ShareInfoController.php +++ b/apps/files_sharing/lib/Controller/ShareInfoController.php @@ -81,11 +81,7 @@ class ShareInfoController extends ApiController { return new JSONResponse([], Http::STATUS_FORBIDDEN); } - $isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); - if (!$isWritable) { - $this->addROWrapper(); - } - + $permissionMask = $share->getPermissions(); $node = $share->getNode(); if ($dir !== null && $node instanceof Folder) { @@ -96,34 +92,34 @@ class ShareInfoController extends ApiController { } } - return new JSONResponse($this->parseNode($node)); + return new JSONResponse($this->parseNode($node, $permissionMask)); } - private function parseNode(Node $node) { + private function parseNode(Node $node, int $permissionMask) { if ($node instanceof File) { - return $this->parseFile($node); + return $this->parseFile($node, $permissionMask); } - return $this->parseFolder($node); + return $this->parseFolder($node, $permissionMask); } - private function parseFile(File $file) { - return $this->format($file); + private function parseFile(File $file, int $permissionMask) { + return $this->format($file, $permissionMask); } - private function parseFolder(Folder $folder) { - $data = $this->format($folder); + private function parseFolder(Folder $folder, int $permissionMask) { + $data = $this->format($folder, $permissionMask); $data['children'] = []; $nodes = $folder->getDirectoryListing(); foreach ($nodes as $node) { - $data['children'][] = $this->parseNode($node); + $data['children'][] = $this->parseNode($node, $permissionMask); } return $data; } - private function format(Node $node) { + private function format(Node $node, int $permissionMask) { $entry = []; $entry['id'] = $node->getId(); @@ -131,7 +127,7 @@ class ShareInfoController extends ApiController { $entry['mtime'] = $node->getMTime(); $entry['name'] = $node->getName(); - $entry['permissions'] = $node->getPermissions(); + $entry['permissions'] = $node->getPermissions() & $permissionMask; $entry['mimetype'] = $node->getMimetype(); $entry['size'] = $node->getSize(); $entry['type'] = $node->getType(); @@ -139,13 +135,4 @@ class ShareInfoController extends ApiController { return $entry; } - - protected function addROWrapper() { - // FIXME: should not add storage wrappers outside of preSetup, need to find a better way - $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); - \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { - return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); - }); - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); - } } |