From 88f5e8839714eabe6b09abf99f8d28e2369ae76e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Nov 2023 17:36:57 +0100 Subject: [PATCH 1/2] don't apply acls when scanning Signed-off-by: Robin Appelman --- lib/Mount/GroupFolderStorage.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/Mount/GroupFolderStorage.php b/lib/Mount/GroupFolderStorage.php index 901360ce2..c6718bb14 100644 --- a/lib/Mount/GroupFolderStorage.php +++ b/lib/Mount/GroupFolderStorage.php @@ -24,7 +24,10 @@ use OC\Files\Cache\Scanner; use OC\Files\ObjectStore\NoopScanner; use OC\Files\ObjectStore\ObjectStoreStorage; +use OC\Files\Storage\Wrapper\Jail; use OC\Files\Storage\Wrapper\Quota; +use OC\Files\Storage\Wrapper\Wrapper; +use OCA\GroupFolders\ACL\ACLStorageWrapper; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Storage\IDisableEncryptionStorage; use OCP\IUser; @@ -71,10 +74,32 @@ public function getCache($path = '', $storage = null) { } public function getScanner($path = '', $storage = null) { - /** @var \OC\Files\Storage\Storage $storage */ - if (!$storage) { - $storage = $this; + // note that we explicitly don't used the passed in storage + // as we want to perform the scan on the underlying filesystem + // without any of the group folder permissions applied + + /** @var Wrapper $storage */ + $storage = $this->storage; + + // we want to scan without ACLs applied + if ($storage->instanceOfStorage(ACLStorageWrapper::class)) { + // sanity check in case the code setting up the wrapper hierarchy is changed without updating this + if (!$this->storage instanceof Jail) { + throw new \Exception("groupfolder storage layout changed unexpectedly"); + } + + $jailRoot = $this->storage->getUnjailedPath(''); + $aclStorage = $this->storage->getUnjailedStorage(); + + if (!$aclStorage instanceof ACLStorageWrapper) { + throw new \Exception("groupfolder storage layout changed unexpectedly"); + } + $storage = new Jail([ + 'storage' => $aclStorage->getWrapperStorage(), + 'root' => $jailRoot, + ]); } + if ($storage->instanceOfStorage(ObjectStoreStorage::class)) { $storage->scanner = new NoopScanner($storage); } elseif (!isset($storage->scanner)) { From c2e5e9b5be3bae69a0c8b702fdb84b114289393d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 22 Jan 2024 18:50:21 +0100 Subject: [PATCH 2/2] update stubs Signed-off-by: Robin Appelman --- tests/stub.phpstub | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/stub.phpstub b/tests/stub.phpstub index 5ca31e862..2f601f6ec 100644 --- a/tests/stub.phpstub +++ b/tests/stub.phpstub @@ -932,6 +932,7 @@ namespace OC\Files\Storage\Wrapper{ class Jail extends Wrapper { public function getUnjailedPath(string $path): string {} + public function getUnjailedStorage(): IStorage {} } class Quota extends Wrapper {