-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[stable28] fix: improve checks for moving shares/storages into other mounts #50160
base: stable28
Are you sure you want to change the base?
Conversation
Signed-off-by: Robin Appelman <[email protected]>
Signed-off-by: Christopher Ng <[email protected]>
Signed-off-by: Robin Appelman <[email protected]>
Signed-off-by: nextcloud-command <[email protected]>
Signed-off-by: Robin Appelman <[email protected]> [skip ci]
/compile / |
Signed-off-by: nextcloud-command <[email protected]>
@@ -95,6 +96,7 @@ | |||
private bool $updaterEnabled = true; | |||
private UserManager $userManager; | |||
private LoggerInterface $logger; | |||
private IL10N $l10n; |
Check failure
Code scanning / Psalm
UndefinedClass Error
@@ -109,6 +111,7 @@ | |||
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider); | |||
$this->userManager = \OC::$server->getUserManager(); | |||
$this->logger = \OC::$server->get(LoggerInterface::class); | |||
$this->l10n = \OC::$server->get(IFactory::class)->get('files'); |
Check failure
Code scanning / Psalm
UndefinedClass Error
@@ -788,6 +794,12 @@ | |||
try { | |||
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true); | |||
|
|||
if ($checkSubMounts) { | |||
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source)); |
Check failure
Code scanning / Psalm
UndefinedVariable Error
@@ -806,13 +818,19 @@ | |||
} | |||
// moving a file/folder within the same mount point | |||
} elseif ($storage1 === $storage2) { | |||
if (count($movedMounts) > 0) { | |||
$this->validateMountMove($movedMounts, $mount1, $mount2, !$this->targetIsNotShared($targetUser, $absolutePath2)); |
Check failure
Code scanning / Psalm
UndefinedVariable Error
if ($storage1) { | ||
$result = $storage1->rename($internalPath1, $internalPath2); | ||
} else { | ||
$result = false; | ||
} | ||
// moving a file/folder between storages (from $storage1 to $storage2) | ||
} else { | ||
if (count($movedMounts) > 0) { | ||
$this->validateMountMove($movedMounts, $mount1, $mount2, !$this->targetIsNotShared($targetUser, $absolutePath2)); |
Check failure
Code scanning / Psalm
UndefinedVariable Error
if ($sourceMount instanceof SharedMount) { | ||
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false); | ||
} else { | ||
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false); |
Check failure
Code scanning / Psalm
UndefinedClass Error
if ($sourceMount !== $targetMount) { | ||
if ($sourceMount instanceof SharedMount) { | ||
if ($targetMount instanceof SharedMount) { | ||
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false); |
Check failure
Code scanning / Psalm
UndefinedClass Error
if ($targetMount instanceof SharedMount) { | ||
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false); | ||
} else { | ||
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false); |
Check failure
Code scanning / Psalm
UndefinedClass Error
} | ||
} else { | ||
if ($targetMount instanceof SharedMount) { | ||
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false); |
Check failure
Code scanning / Psalm
UndefinedClass Error
if ($targetMount instanceof SharedMount) { | ||
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false); | ||
} else { | ||
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false); |
Check failure
Code scanning / Psalm
UndefinedClass Error
Backport of #49552
Warning, This backport's changes differ from the original and might be incomplete⚠️
Todo
Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.