diff options
author | Robin Appelman <robin@icewind.nl> | 2022-08-10 13:58:09 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-08-25 13:55:53 +0200 |
commit | c2b206db645bd9a7b69f2485b9d75b1252271795 (patch) | |
tree | c46fa3d3fb7650646055e5e3070677d676307542 /lib/private/Encryption | |
parent | b6265a825560b57d635f23075de5d21282dc1c27 (diff) | |
download | nextcloud-server-c2b206db645bd9a7b69f2485b9d75b1252271795.tar.gz nextcloud-server-c2b206db645bd9a7b69f2485b9d75b1252271795.zip |
add marker interface to mark system mount points for encryption
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Encryption')
-rw-r--r-- | lib/private/Encryption/Util.php | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php index 410ea19da81..bf7bbce8ad7 100644 --- a/lib/private/Encryption/Util.php +++ b/lib/private/Encryption/Util.php @@ -32,10 +32,8 @@ use OC\Encryption\Exceptions\EncryptionHeaderToLargeException; use OC\Encryption\Exceptions\ModuleDoesNotExistsException; use OC\Files\Filesystem; use OC\Files\View; -use OCA\Files_External\Lib\StorageConfig; -use OCA\Files_External\Service\GlobalStoragesService; -use OCP\App\IAppManager; use OCP\Encryption\IEncryptionModule; +use OCP\Files\Mount\ISystemMountPoint; use OCP\IConfig; use OCP\IGroupManager; use OCP\IUser; @@ -295,46 +293,9 @@ class Util { * @param string $uid * @return boolean */ - public function isSystemWideMountPoint($path, $uid) { - // No DI here as this initialise the db too soon - if (\OCP\Server::get(IAppManager::class)->isEnabledForUser("files_external")) { - /** @var GlobalStoragesService $storageService */ - $storageService = \OC::$server->get(GlobalStoragesService::class); - $storages = $storageService->getAllStorages(); - foreach ($storages as $storage) { - if (strpos($path, '/files/' . ltrim($storage->getMountPoint(), '/')) === 0) { - if ($this->isMountPointApplicableToUser($storage, $uid)) { - return true; - } - } - } - } - return false; - } - - /** - * check if mount point is applicable to user - * - * @param StorageConfig $mount - * @param string $uid - * @return boolean - */ - private function isMountPointApplicableToUser(StorageConfig $mount, string $uid) { - if ($mount->getApplicableUsers() === [] && $mount->getApplicableGroups() === []) { - // applicable for everyone - return true; - } - // check if mount point is applicable for the user - if (array_search($uid, $mount->getApplicableUsers()) !== false) { - return true; - } - // check if mount point is applicable for group where the user is a member - foreach ($mount->getApplicableGroups() as $gid) { - if ($this->groupManager->isInGroup($uid, $gid)) { - return true; - } - } - return false; + public function isSystemWideMountPoint(string $path, string $uid) { + $mount = Filesystem::getMountManager()->find('/' . $uid . $path); + return $mount instanceof ISystemMountPoint; } /** |