From 53d6d60ab919275db8b59f2a835c1dd1953f8dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 19 Mar 2024 09:33:16 +0100 Subject: [PATCH] fix: Pass the mountpoint target user to storages without owner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Storages that do not have a dedicated owner (e.g. groupfolders, external storages) currently always assume the current session user as the owner. This leads to several issues when there is no user session but a node is obtained through a user folder. In order to have the correct user available we need to pass the user that is used to setup a mountpoint along to the storage layer as we generally assume that an owner is available for those. Signed-off-by: Julius Härtl [skip ci] --- lib/private/Files/Storage/Common.php | 13 +++++++++++++ lib/private/Files/Storage/Wrapper/Wrapper.php | 4 ++++ lib/public/Files/Storage/IStorage.php | 12 ++++++++++++ 3 files changed, 29 insertions(+) diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index fe88fb3150f63..87a4a810c0e51 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -861,6 +861,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 */ diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 2c50bbdb11f6b..4998f9b83692c 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -674,4 +674,8 @@ public function isWrapperOf(IStorage $storage) { } return false; } + + public function setOwner(?string $user): void { + $this->getWrapperStorage()->setOwner($user); + } } diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php index 00e98fdfbb6e6..06cd3b70bbb27 100644 --- a/lib/public/Files/Storage/IStorage.php +++ b/lib/public/Files/Storage/IStorage.php @@ -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 + */ + public function setOwner(?string $user): void; }