diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-08-05 15:25:52 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-08-12 21:14:22 +0200 |
commit | da1feafc7859b334959bb6cf1676d866b52c6ca7 (patch) | |
tree | f6ab5a27f11e94d4324a591e6ae948e2e7fc464d /apps/files_encryption/lib | |
parent | 174805f5e35131c891a4b0fa8db3fea3526cfcdb (diff) | |
download | nextcloud-server-da1feafc7859b334959bb6cf1676d866b52c6ca7.tar.gz nextcloud-server-da1feafc7859b334959bb6cf1676d866b52c6ca7.zip |
fix detection of system wide mount points
Diffstat (limited to 'apps/files_encryption/lib')
-rw-r--r-- | apps/files_encryption/lib/util.php | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index e44a8bd3dda..3786a465411 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -993,10 +993,10 @@ class Util { // check if it is a group mount if (\OCP\App::isEnabled("files_external")) { - $mount = \OC_Mount_Config::getSystemMountPoints(); - foreach ($mount as $mountPoint => $data) { - if ($mountPoint == substr($ownerPath, 1, strlen($mountPoint))) { - $userIds = array_merge($userIds, $this->getUserWithAccessToMountPoint($data['applicable']['users'], $data['applicable']['groups'])); + $mounts = \OC_Mount_Config::getSystemMountPoints(); + foreach ($mounts as $mount) { + if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) { + $userIds = array_merge($userIds, $this->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups'])); } } } @@ -1454,10 +1454,12 @@ class Util { public function isSystemWideMountPoint($path) { $normalizedPath = ltrim($path, '/'); if (\OCP\App::isEnabled("files_external")) { - $mount = \OC_Mount_Config::getSystemMountPoints(); - foreach ($mount as $mountPoint => $data) { - if ($mountPoint == substr($normalizedPath, 0, strlen($mountPoint))) { - return true; + $mounts = \OC_Mount_Config::getSystemMountPoints(); + foreach ($mounts as $mount) { + if ($mount['mountpoint'] == substr($normalizedPath, 0, strlen($mount['mountpoint']))) { + if ($this->isMountPointApplicableToUser($mount)) { + return true; + } } } } @@ -1465,6 +1467,29 @@ class Util { } /** + * check if mount point is applicable to user + * + * @param array $mount contains $mount['applicable']['users'], $mount['applicable']['groups'] + * @return boolean + */ + protected function isMountPointApplicableToUser($mount) { + $uid = \OCP\User::getUser(); + $acceptedUids = array('all', $uid); + // check if mount point is applicable for the user + $intersection = array_intersect($acceptedUids, $mount['applicable']['users']); + if (!empty($intersection)) { + return true; + } + // check if mount point is applicable for group where the user is a member + foreach ($mount['applicable']['groups'] as $gid) { + if (\OC_Group::inGroup($uid, $gid)) { + return true; + } + } + return false; + } + + /** * decrypt private key and add it to the current session * @param array $params with 'uid' and 'password' * @return mixed session or false |