Skip to content

Commit bf71bd1

Browse files
committed
fix(share): use share owner to confirm reshare
Signed-off-by: Maxence Lange <[email protected]>
1 parent daf7252 commit bf71bd1

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

lib/private/Share20/Manager.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ protected function verifyPassword($password) {
210210
*
211211
* @suppress PhanUndeclaredClassMethod
212212
*/
213-
protected function generalCreateChecks(IShare $share) {
213+
protected function generalCreateChecks(IShare $share, bool $isUpdate = false) {
214214
if ($share->getShareType() === IShare::TYPE_USER) {
215215
// We expect a valid user as sharedWith for user shares
216216
if (!$this->userManager->userExists($share->getSharedWith())) {
@@ -296,8 +296,14 @@ protected function generalCreateChecks(IShare $share) {
296296

297297
$isFederatedShare = $share->getNode()->getStorage()->instanceOfStorage('\OCA\Files_Sharing\External\Storage');
298298
$permissions = 0;
299+
300+
$isReshare = $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy();
301+
if (!$isReshare && $isUpdate) {
302+
// in case of update on owner-less filesystem, we use share owner to improve reshare detection
303+
$isReshare = $share->getShareOwner() !== $share->getSharedBy();
304+
}
299305

300-
if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) {
306+
if (!$isFederatedShare && $isReshare) {
301307
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) {
302308
// We need to filter since there might be other mountpoints that contain the file
303309
// e.g. if the user has access to the same external storage that the file is originating from
@@ -999,7 +1005,7 @@ public function updateShare(IShare $share) {
9991005
throw new \InvalidArgumentException('Cannot share with the share owner');
10001006
}
10011007

1002-
$this->generalCreateChecks($share);
1008+
$this->generalCreateChecks($share, true);
10031009

10041010
if ($share->getShareType() === IShare::TYPE_USER) {
10051011
$this->userCreateChecks($share);

0 commit comments

Comments
 (0)