0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-03-13 07:53:51 +00:00

fix: explicitly ignore nested mounts when transfering ownership

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2025-01-03 17:41:39 +01:00 committed by Andy Scherzinger
parent 6cf97e929b
commit 5d094feee0
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
4 changed files with 12 additions and 6 deletions
apps
dav/tests/unit/Connector/Sabre
files/lib/Service
build/integration/files_features
lib/private/Files

View file

@ -41,7 +41,7 @@ class TestViewDirectory extends \OC\Files\View {
return $this->deletables[$path];
}
public function rename($path1, $path2) {
public function rename($path1, $path2, array $options = []) {
return $this->canRename;
}

View file

@ -397,7 +397,7 @@ class OwnershipTransferService {
$view->mkdir($finalTarget);
$finalTarget = $finalTarget . '/' . basename($sourcePath);
}
if ($view->rename($sourcePath, $finalTarget) === false) {
if ($view->rename($sourcePath, $finalTarget, ['checkSubMounts' => false]) === false) {
throw new TransferOwnershipException("Could not transfer files.", 1);
}
if (!is_dir("$sourceUid/files")) {

View file

@ -514,7 +514,7 @@ Feature: transfer-ownership
And user "user2" accepts last share
When transferring ownership of path "test" from "user0" to "user1"
Then the command failed with exit code 1
And the command output contains the text "Could not transfer files."
And the command error output contains the text "Moving a storage (user0/files/test) into another storage (user1) is not allowed"
Scenario: transferring ownership does not transfer received shares
Given user "user0" exists

View file

@ -693,11 +693,14 @@ class View {
*
* @param string $source source path
* @param string $target target path
* @param array $options
*
* @return bool|mixed
* @throws LockedException
*/
public function rename($source, $target) {
public function rename($source, $target, array $options = []) {
$checkSubMounts = $options['checkSubMounts'] ?? true;
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source));
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target));
@ -765,13 +768,16 @@ class View {
try {
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true);
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
if ($checkSubMounts) {
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
} else {
$movedMounts = [];
}
if ($internalPath1 === '') {
$sourceParentMount = $this->getMount(dirname($source));
$movedMounts[] = $mount1;
$this->validateMountMove($movedMounts, $sourceParentMount, $mount2, !$this->targetIsNotShared($targetUser, $absolutePath2));
/**
* @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1
*/