Skip to content

Commit 4d3ddbf

Browse files
committed
Use user mount with matching shared storage only
Signed-off-by: Julius Härtl <[email protected]>
1 parent ad6a421 commit 4d3ddbf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/private/Share20/Manager.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use OC\Files\Mount\MoveableMount;
4444
use OC\HintException;
4545
use OC\Share20\Exception\ProviderException;
46+
use OCA\Files_Sharing\ISharedStorage;
4647
use OCP\EventDispatcher\IEventDispatcher;
4748
use OCP\Files\File;
4849
use OCP\Files\Folder;
@@ -299,8 +300,15 @@ protected function generalCreateChecks(IShare $share) {
299300
$isFederatedShare = $share->getNode()->getStorage()->instanceOfStorage('\OCA\Files_Sharing\External\Storage');
300301
$permissions = 0;
301302

302-
$userMounts = $userFolder->getById($share->getNode()->getId());
303+
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function($mount) {
304+
// We need to filter since there might be other mountpoints that contain the file
305+
// e.g. if the user has access to the same external storage that the file is originating from
306+
return $mount->getStorage()->instanceOfStorage(ISharedStorage::class);
307+
});
303308
$userMount = array_shift($userMounts);
309+
if ($userMount === null) {
310+
throw new GenericShareException('Could not get proper share mount for ' . $share->getNode()->getId() . '. Failing since else the next calls are called with null');
311+
}
304312
$mount = $userMount->getMountPoint();
305313
if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) {
306314
// When it's a reshare use the parent share permissions as maximum

0 commit comments

Comments
 (0)