aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2024-03-19 09:33:16 +0100
committerAndy Scherzinger <info@andy-scherzinger.de>2024-09-03 12:23:37 +0200
commit53f92e68e69beb2a788b1fd3ad247f5d9ae295c7 (patch)
tree85d862dd6ec5f6f1998be5bdb1376a32b36a934a
parent2f285ae136a5535e84e9cb3370117408d688657a (diff)
downloadnextcloud-server-53f92e68e69beb2a788b1fd3ad247f5d9ae295c7.tar.gz
nextcloud-server-53f92e68e69beb2a788b1fd3ad247f5d9ae295c7.zip
fix: Pass the mountpoint target user to storages without owner
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 <jus@bitgrid.net>
-rw-r--r--apps/files_external/lib/Config/ConfigAdapter.php1
-rw-r--r--lib/private/Files/Storage/Common.php13
-rw-r--r--lib/private/Files/Storage/Wrapper/Wrapper.php4
-rw-r--r--lib/public/Files/Storage/IStorage.php12
4 files changed, 30 insertions, 0 deletions
diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php
index c06df7765b6..de614f4434e 100644
--- a/apps/files_external/lib/Config/ConfigAdapter.php
+++ b/apps/files_external/lib/Config/ConfigAdapter.php
@@ -140,6 +140,7 @@ class ConfigAdapter implements IMountProvider {
}, $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,
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index fe88fb3150f..87a4a810c0e 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -862,6 +862,19 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
}
/**
+ * 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
*/
public function needsPartFile() {
diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php
index 2c50bbdb11f..4998f9b8369 100644
--- a/lib/private/Files/Storage/Wrapper/Wrapper.php
+++ b/lib/private/Files/Storage/Wrapper/Wrapper.php
@@ -674,4 +674,8 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
}
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 00e98fdfbb6..06cd3b70bbb 100644
--- a/lib/public/Files/Storage/IStorage.php
+++ b/lib/public/Files/Storage/IStorage.php
@@ -460,4 +460,16 @@ interface IStorage {
* @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;
}