aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Encryption
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-03-26 15:07:39 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2021-06-16 13:55:19 +0200
commit1052feabede4b9054047f60aaa6fe4e04e89c434 (patch)
tree7f87fd18601f2f0648f85c5f066dcc0647c05910 /lib/private/Encryption
parent7917f4cf763a3f35f81f500b5f5b5135cd136518 (diff)
downloadnextcloud-server-1052feabede4b9054047f60aaa6fe4e04e89c434.tar.gz
nextcloud-server-1052feabede4b9054047f60aaa6fe4e04e89c434.zip
remove depricated methods from MountConfig
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Encryption')
-rw-r--r--lib/private/Encryption/File.php11
-rw-r--r--lib/private/Encryption/Util.php28
2 files changed, 24 insertions, 15 deletions
diff --git a/lib/private/Encryption/File.php b/lib/private/Encryption/File.php
index 76d8900a40e..2c486dfade6 100644
--- a/lib/private/Encryption/File.php
+++ b/lib/private/Encryption/File.php
@@ -28,6 +28,7 @@
namespace OC\Encryption;
use OC\Cache\CappedMemoryCache;
+use OCA\Files_External\Service\GlobalStoragesService;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Share\IManager;
@@ -110,10 +111,12 @@ class File implements \OCP\Encryption\IFile {
// check if it is a group mount
if (\OCP\App::isEnabled("files_external")) {
- $mounts = \OCA\Files_External\MountConfig::getSystemMountPoints();
- foreach ($mounts as $mount) {
- if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) {
- $mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']);
+ /** @var GlobalStoragesService $storageService */
+ $storageService = \OC::$server->get(GlobalStoragesService::class);
+ $storages = $storageService->getAllStorages();
+ foreach ($storages as $storage) {
+ if ($storage->getMountPoint() == substr($ownerPath, 0, strlen($storage->getMountPoint()))) {
+ $mountedFor = $this->util->getUserWithAccessToMountPoint($storage->getApplicableUsers(), $storage->getApplicableGroups());
$userIds = array_merge($userIds, $mountedFor);
}
}
diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php
index e1f03e2fff1..dc878ba8fc1 100644
--- a/lib/private/Encryption/Util.php
+++ b/lib/private/Encryption/Util.php
@@ -32,6 +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\Encryption\IEncryptionModule;
use OCP\IConfig;
use OCP\IUser;
@@ -265,7 +267,7 @@ class Util {
public function getUserWithAccessToMountPoint($users, $groups) {
$result = [];
- if (in_array('all', $users)) {
+ if ($users === [] && $groups === []) {
$users = $this->userManager->search('', null, null);
$result = array_map(function (IUser $user) {
return $user->getUID();
@@ -298,10 +300,12 @@ class Util {
*/
public function isSystemWideMountPoint($path, $uid) {
if (\OCP\App::isEnabled("files_external")) {
- $mounts = \OCA\Files_External\MountConfig::getSystemMountPoints();
- foreach ($mounts as $mount) {
- if (strpos($path, '/files/' . $mount['mountpoint']) === 0) {
- if ($this->isMountPointApplicableToUser($mount, $uid)) {
+ /** @var GlobalStoragesService $storageService */
+ $storageService = \OC::$server->get(GlobalStoragesService::class);
+ $storages = $storageService->getAllStorages();
+ foreach ($storages as $storage) {
+ if (strpos($path, '/files/' . $storage->getMountPoint()) === 0) {
+ if ($this->isMountPointApplicableToUser($storage, $uid)) {
return true;
}
}
@@ -313,19 +317,21 @@ class Util {
/**
* check if mount point is applicable to user
*
- * @param array $mount contains $mount['applicable']['users'], $mount['applicable']['groups']
+ * @param StorageConfig $mount
* @param string $uid
* @return boolean
*/
- private function isMountPointApplicableToUser($mount, $uid) {
- $acceptedUids = ['all', $uid];
+ 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
- $intersection = array_intersect($acceptedUids, $mount['applicable']['users']);
- if (!empty($intersection)) {
+ 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['applicable']['groups'] as $gid) {
+ foreach ($mount->getApplicableGroups() as $gid) {
if ($this->groupManager->isInGroup($uid, $gid)) {
return true;
}