Skip to content
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

fix: Pass the mountpoint target user to storages without owner #44294

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/files_external/lib/Config/ConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) {
throw new \InvalidArgumentException('Invalid object store');
}
$storage->setBackendOption('objectstore', new $objectClass($objectStore));

Check failure on line 75 in apps/files_external/lib/Config/ConfigAdapter.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedCallable

apps/files_external/lib/Config/ConfigAdapter.php:75:50: TaintedCallable: Detected tainted text (see https://psalm.dev/243)
}

$storage->getAuthMechanism()->manipulateStorageConfig($storage, $user);
Expand Down Expand Up @@ -140,6 +140,7 @@
}, $storages, $storageConfigs);

$mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
$storage->setOwner($user->getUID());
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAL) {
return new PersonalMount(
$this->userStoragesService,
Expand Down
13 changes: 13 additions & 0 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,19 @@ public function setAvailability($isAvailable) {
$this->getStorageCache()->setAvailability($isAvailable);
}

/**
* Allow setting the storage owner
*
* This can be used for storages that do not have a dedicated owner, where we want to
* pass the user that we setup the mountpoint for along to the storage layer
*
* @param string|null $user
* @return void
*/
public function setOwner(?string $user): void {
$this->owner = $user;
}

/**
* @return bool
*/
Expand Down
4 changes: 4 additions & 0 deletions lib/private/Files/Storage/Wrapper/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,4 +674,8 @@ public function isWrapperOf(IStorage $storage) {
}
return false;
}

public function setOwner(?string $user): void {
$this->getWrapperStorage()->setOwner($user);
}
}
12 changes: 12 additions & 0 deletions lib/public/Files/Storage/IStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,16 @@ public function getUpdater();
* @since 9.0.0
*/
public function getWatcher();

/**
* Allow setting the storage owner
*
* This can be used for storages that do not have a dedicated owner, where we want to
* pass the user that we setup the mountpoint for along to the storage layer
*
* @param string|null $user Owner user id
* @return void
* @since 29.0.0
artonge marked this conversation as resolved.
Show resolved Hide resolved
*/
public function setOwner(?string $user): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
Loading