diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-09-10 16:19:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 16:19:04 +0200 |
commit | e269f15d565caf1956df046dff3a170c4347ed00 (patch) | |
tree | 62fd20f3d3d4f1440c8a06ce7d5ec7486a3cae54 /lib/private/Share20 | |
parent | 3d61f7b258e3413fb112c6157fe172c7d29662be (diff) | |
parent | 52eff4ae7c08f093df39e121639b7c6ad6b721fd (diff) | |
download | nextcloud-server-e269f15d565caf1956df046dff3a170c4347ed00.tar.gz nextcloud-server-e269f15d565caf1956df046dff3a170c4347ed00.zip |
Merge pull request #22234 from nextcloud/bugfix/noid/reshare-mount
Use user mount with matching shared storage only
Diffstat (limited to 'lib/private/Share20')
-rw-r--r-- | lib/private/Share20/Manager.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 04442afcf93..1b1818a6e48 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -43,6 +43,7 @@ use OC\Cache\CappedMemoryCache; use OC\Files\Mount\MoveableMount; use OC\HintException; use OC\Share20\Exception\ProviderException; +use OCA\Files_Sharing\ISharedStorage; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\File; use OCP\Files\Folder; @@ -299,10 +300,17 @@ class Manager implements IManager { $isFederatedShare = $share->getNode()->getStorage()->instanceOfStorage('\OCA\Files_Sharing\External\Storage'); $permissions = 0; - $userMounts = $userFolder->getById($share->getNode()->getId()); - $userMount = array_shift($userMounts); - $mount = $userMount->getMountPoint(); if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) { + $userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) { + // We need to filter since there might be other mountpoints that contain the file + // e.g. if the user has access to the same external storage that the file is originating from + return $mount->getStorage()->instanceOfStorage(ISharedStorage::class); + }); + $userMount = array_shift($userMounts); + if ($userMount === null) { + throw new GenericShareException('Could not get proper share mount for ' . $share->getNode()->getId() . '. Failing since else the next calls are called with null'); + } + $mount = $userMount->getMountPoint(); // When it's a reshare use the parent share permissions as maximum $userMountPointId = $mount->getStorageRootId(); $userMountPoints = $userFolder->getById($userMountPointId); @@ -331,7 +339,7 @@ class Manager implements IManager { * while we 'most likely' do have that on the storage. */ $permissions = $share->getNode()->getPermissions(); - if (!($mount instanceof MoveableMount)) { + if (!($share->getNode()->getMountPoint() instanceof MoveableMount)) { $permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE; } } |