diff options
author | Stephan Orbaugh <62374139+sorbaugh@users.noreply.github.com> | 2024-03-20 14:56:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-20 14:56:04 +0100 |
commit | a5c0c91caeb565ae9232f476f93f98dda2ba4efe (patch) | |
tree | 3bfbc3fe94afd0925494b9dcb322eb5ceb33af92 | |
parent | b5938db846d1a4b5df55c91c06a008972b152092 (diff) | |
parent | 0fdd3d19a6979e98520aa1978e946db508a8dc76 (diff) | |
download | nextcloud-server-a5c0c91caeb565ae9232f476f93f98dda2ba4efe.tar.gz nextcloud-server-a5c0c91caeb565ae9232f476f93f98dda2ba4efe.zip |
Merge pull request #44349 from nextcloud/backport/44339/stable27
[stable27] fix(share): use share owner to get ownership
-rw-r--r-- | lib/private/Share20/Manager.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index acb104a1ca7..62dfeafe26a 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -212,7 +212,7 @@ class Manager implements IManager { * * @suppress PhanUndeclaredClassMethod */ - protected function generalCreateChecks(IShare $share) { + protected function generalCreateChecks(IShare $share, bool $isUpdate = false) { if ($share->getShareType() === IShare::TYPE_USER) { // We expect a valid user as sharedWith for user shares if (!$this->userManager->userExists($share->getSharedWith())) { @@ -298,8 +298,14 @@ class Manager implements IManager { $isFederatedShare = $share->getNode()->getStorage()->instanceOfStorage('\OCA\Files_Sharing\External\Storage'); $permissions = 0; + + $isReshare = $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy(); + if (!$isReshare && $isUpdate) { + // in case of update on owner-less filesystem, we use share owner to improve reshare detection + $isReshare = $share->getShareOwner() !== $share->getSharedBy(); + } - if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) { + if (!$isFederatedShare && $isReshare) { $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 @@ -997,7 +1003,7 @@ class Manager implements IManager { throw new \InvalidArgumentException('Cannot share with the share owner'); } - $this->generalCreateChecks($share); + $this->generalCreateChecks($share, true); if ($share->getShareType() === IShare::TYPE_USER) { $this->userCreateChecks($share); |