Skip to content

Commit 41b0fef

Browse files
committed
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 <[email protected]>
1 parent cfca735 commit 41b0fef

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

apps/files_external/lib/Config/ConfigAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
140140
}, $storages, $storageConfigs);
141141

142142
$mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
143+
$storage->setOwner($user->getUID());
143144
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAL) {
144145
return new PersonalMount(
145146
$this->userStoragesService,

lib/private/Files/Storage/Common.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,19 @@ public function setAvailability($isAvailable) {
867867
$this->getStorageCache()->setAvailability($isAvailable);
868868
}
869869

870+
/**
871+
* Allow setting the storage owner
872+
*
873+
* This can be used for storages that do not have a dedicated owner, where we want to
874+
* pass the user that we setup the mountpoint for along to the storage layer
875+
*
876+
* @param string|null $user
877+
* @return void
878+
*/
879+
public function setOwner(?string $user): void {
880+
$this->owner = $user;
881+
}
882+
870883
/**
871884
* @return bool
872885
*/

lib/private/Files/Storage/Wrapper/Wrapper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,8 @@ public function isWrapperOf(IStorage $storage) {
665665
}
666666
return false;
667667
}
668+
669+
public function setOwner(?string $user): void {
670+
$this->getWrapperStorage()->setOwner($user);
671+
}
668672
}

lib/public/Files/Storage/IStorage.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,16 @@ public function getUpdater();
460460
* @since 9.0.0
461461
*/
462462
public function getWatcher();
463+
464+
/**
465+
* Allow setting the storage owner
466+
*
467+
* This can be used for storages that do not have a dedicated owner, where we want to
468+
* pass the user that we setup the mountpoint for along to the storage layer
469+
*
470+
* @param string|null $user
471+
* @return void
472+
* @since 29.0.0
473+
*/
474+
public function setOwner(?string $user): void;
463475
}

0 commit comments

Comments
 (0)