diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-07-16 18:11:40 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-07-16 18:11:40 +0200 |
commit | 535e4296b5b901c0edea0b97389e41154d1d4395 (patch) | |
tree | d8fd811529988831e44f4948f02c5311f98f5f2e | |
parent | 3bd5f5eb4cd43fda85f97d1caa216abb213ffaf0 (diff) | |
download | nextcloud-server-535e4296b5b901c0edea0b97389e41154d1d4395.tar.gz nextcloud-server-535e4296b5b901c0edea0b97389e41154d1d4395.zip |
Pass owner to isSystemWideMountPoint to make it work for public links
Public links did not have the correct owner so could not properly detect
system wide mount points.
This is a manual backport of b25c06f5769fbcd90a780cbce90998a38c112043 from 8.1
-rw-r--r-- | apps/files_encryption/lib/hooks.php | 2 | ||||
-rw-r--r-- | apps/files_encryption/lib/keymanager.php | 2 | ||||
-rw-r--r-- | apps/files_encryption/lib/util.php | 9 | ||||
-rwxr-xr-x | apps/files_encryption/tests/util.php | 7 | ||||
-rw-r--r-- | apps/files_trashbin/lib/trashbin.php | 4 |
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; } |