summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-07-20 15:08:21 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-07-20 15:08:21 +0200
commit2b0de142ab773af1f0c72a851cb66a9011830fb4 (patch)
tree3a7679fb00440af91cc45e294f100b5207b030e0 /apps
parent558f1ec1ec8f901f47f0c44158661aa94ece2f50 (diff)
parent535e4296b5b901c0edea0b97389e41154d1d4395 (diff)
downloadnextcloud-server-2b0de142ab773af1f0c72a851cb66a9011830fb4.tar.gz
nextcloud-server-2b0de142ab773af1f0c72a851cb66a9011830fb4.zip
Merge pull request #17688 from owncloud/stable8-publiclinksystemwidemountwithapplicable
[stable8] Pass owner to isSystemWideMountPoint to make it work for public links
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/lib/hooks.php2
-rw-r--r--apps/files_encryption/lib/keymanager.php2
-rw-r--r--apps/files_encryption/lib/util.php9
-rwxr-xr-xapps/files_encryption/tests/util.php7
-rw-r--r--apps/files_trashbin/lib/trashbin.php4
5 files changed, 12 insertions, 12 deletions
diff --git a/apps/files_encryption/lib/hooks.php b/apps/files_encryption/lib/hooks.php
index 1ffcee5e74a..27ae4fc7522 100644
--- a/apps/files_encryption/lib/hooks.php
+++ b/apps/files_encryption/lib/hooks.php
@@ -478,7 +478,7 @@ class Hooks {
list($ownerNew, $pathNew) = $util->getUidAndFilename($params['newpath']);
- if ($util->isSystemWideMountPoint($pathNew)) {
+ if ($util->isSystemWideMountPoint($pathNew, $ownerNew)) {
$newKeysPath = 'files_encryption/keys/' . $pathNew;
} else {
$newKeysPath = $ownerNew . '/files_encryption/keys/' . $pathNew;
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 9ccf0705b28..4fec2b7f2d1 100644
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -187,7 +187,7 @@ class Keymanager {
$filePath_f = ltrim($filename, '/');
// in case of system wide mount points the keys are stored directly in the data directory
- if ($util->isSystemWideMountPoint($filename)) {
+ if ($util->isSystemWideMountPoint($filename, $owner)) {
$keyPath = self::$keys_base_dir . $filePath_f . '/';
} else {
$keyPath = '/' . $owner . self::$keys_base_dir . $filePath_f . '/';
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 106ed3b2f08..8e69889f763 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1617,15 +1617,16 @@ class Util {
/**
* check if the file is stored on a system wide mount point
* @param string $path relative to /data/user with leading '/'
+ * @param string $uid
* @return boolean
*/
- public function isSystemWideMountPoint($path) {
+ public function isSystemWideMountPoint($path, $uid) {
$normalizedPath = ltrim($path, '/');
if (\OCP\App::isEnabled("files_external")) {
$mounts = \OC_Mount_Config::getSystemMountPoints();
foreach ($mounts as $mount) {
if ($mount['mountpoint'] == substr($normalizedPath, 0, strlen($mount['mountpoint']))) {
- if ($this->isMountPointApplicableToUser($mount)) {
+ if ($this->isMountPointApplicableToUser($mount, $uid)) {
return true;
}
}
@@ -1638,10 +1639,10 @@ class Util {
* check if mount point is applicable to user
*
* @param array $mount contains $mount['applicable']['users'], $mount['applicable']['groups']
+ * @param string $uid
* @return boolean
*/
- protected function isMountPointApplicableToUser($mount) {
- $uid = \OCP\User::getUser();
+ protected function isMountPointApplicableToUser($mount, $uid) {
$acceptedUids = array('all', $uid);
// check if mount point is applicable for the user
$intersection = array_intersect($acceptedUids, $mount['applicable']['users']);
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index f9ee005e95f..526dcbfc812 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -587,9 +587,8 @@ class Util extends TestCase {
* @dataProvider dataProviderFortestIsMountPointApplicableToUser
*/
function testIsMountPointApplicableToUser($mount, $expectedResult) {
- self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1);
$dummyClass = new DummyUtilClass($this->view, self::TEST_ENCRYPTION_UTIL_USER1);
- $result = $dummyClass->testIsMountPointApplicableToUser($mount);
+ $result = $dummyClass->testIsMountPointApplicableToUser($mount, self::TEST_ENCRYPTION_UTIL_USER1);
$this->assertSame($expectedResult, $result);
}
@@ -663,7 +662,7 @@ class Util extends TestCase {
* dummy class extends \OCA\Files_Encryption\Util to access protected methods for testing
*/
class DummyUtilClass extends \OCA\Files_Encryption\Util {
- public function testIsMountPointApplicableToUser($mount) {
- return $this->isMountPointApplicableToUser($mount);
+ public function testIsMountPointApplicableToUser($mount, $uid) {
+ return $this->isMountPointApplicableToUser($mount, $uid);
}
}
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index e17f261de83..2898f849da4 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -299,7 +299,7 @@ class Trashbin {
$util = new \OCA\Files_Encryption\Util($rootView, $user);
$baseDir = '/files_encryption/';
- if (!$util->isSystemWideMountPoint($ownerPath)) {
+ if (!$util->isSystemWideMountPoint($ownerPath, $owner)) {
$baseDir = $owner . $baseDir;
}
@@ -473,7 +473,7 @@ class Trashbin {
$util = new \OCA\Files_Encryption\Util($rootView, $user);
$baseDir = '/files_encryption/';
- if (!$util->isSystemWideMountPoint($ownerPath)) {
+ if (!$util->isSystemWideMountPoint($ownerPath, $owner)) {
$baseDir = $owner . $baseDir;
}