summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-08-05 15:25:52 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-08-12 17:52:40 +0200
commit6af1a2d9143fb1b4a6e139c96807d4a4f1a0021a (patch)
tree96da3a15d00dcfaab94ab3ed8db5578ad32ca56f /apps
parent3432b2e3866a559c377f61f193d8159a39053466 (diff)
downloadnextcloud-server-6af1a2d9143fb1b4a6e139c96807d4a4f1a0021a.tar.gz
nextcloud-server-6af1a2d9143fb1b4a6e139c96807d4a4f1a0021a.zip
fix detection of system wide mount points
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/lib/util.php41
1 files changed, 33 insertions, 8 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 21a0a72d0da..e98dea5e16a 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1041,10 +1041,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']));
}
}
}
@@ -1502,10 +1502,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;
+ }
}
}
}
@@ -1513,6 +1515,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