summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-03-19 22:05:04 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-04-04 12:02:37 +0200
commit5a74b9cb999d6563b6b6f97cd3232bebe2ec3e57 (patch)
tree4d73bf7b1362141dd0ae3dfc19b3f43855e63861
parente95184ee258d4d089f7edeae12fd5d465d03d620 (diff)
downloadnextcloud-server-5a74b9cb999d6563b6b6f97cd3232bebe2ec3e57.tar.gz
nextcloud-server-5a74b9cb999d6563b6b6f97cd3232bebe2ec3e57.zip
Fix proper permissions for multiple file access
Fixes #8890 In case you have access to a file via multiple ways, for example: 1. the file is shared with you with permission read only 2. the folder containing the file is shared with your read/write Requesting the getById function on the userFolder would give back two entries but both with the same permissions. Depending on the node you picked this is not right. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r--lib/private/Files/Node/Folder.php21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index fcadbe27393..95ceeee3698 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -302,18 +302,15 @@ class Folder extends Node implements \OCP\Files\Folder {
return [];
}
- // we only need to get the cache info once, since all mounts we found point to the same storage
-
- $mount = $folderMounts[$mountsContainingFile[0]->getMountPoint()];
- $cacheEntry = $mount->getStorage()->getCache()->get((int)$id);
- if (!$cacheEntry) {
- return [];
- }
- // cache jails will hide the "true" internal path
- $internalPath = ltrim($mountsContainingFile[0]->getRootInternalPath() . '/' . $cacheEntry->getPath(), '/');
-
- $nodes = array_map(function (ICachedMountInfo $cachedMountInfo) use ($cacheEntry, $folderMounts, $internalPath) {
+ $nodes = array_map(function (ICachedMountInfo $cachedMountInfo) use ($folderMounts, $id) {
$mount = $folderMounts[$cachedMountInfo->getMountPoint()];
+ $cacheEntry = $mount->getStorage()->getCache()->get((int)$id);
+ if (!$cacheEntry) {
+ return null;
+ }
+
+ // cache jails will hide the "true" internal path
+ $internalPath = ltrim($cachedMountInfo->getRootInternalPath() . '/' . $cacheEntry->getPath(), '/');
$pathRelativeToMount = substr($internalPath, strlen($cachedMountInfo->getRootInternalPath()));
$pathRelativeToMount = ltrim($pathRelativeToMount, '/');
$absolutePath = $cachedMountInfo->getMountPoint() . $pathRelativeToMount;
@@ -323,6 +320,8 @@ class Folder extends Node implements \OCP\Files\Folder {
));
}, $mountsContainingFile);
+ $nodes = array_filter($nodes);
+
return array_filter($nodes, function (Node $node) {
return $this->getRelativePath($node->getPath());
});