aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-04-22 13:32:20 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-04-22 13:32:20 +0200
commite0514d2c042b6148f3fe1a20208d025ca0c34b20 (patch)
tree28e4b383cf443290d493f077b50cc16c84b4a783
parent2c4ef370254fbe4bf9e6d7bbd67e5be2d3238d14 (diff)
parent085bcd7da27e82e4695ff1a2cf961e9b6a820712 (diff)
downloadnextcloud-server-e0514d2c042b6148f3fe1a20208d025ca0c34b20.tar.gz
nextcloud-server-e0514d2c042b6148f3fe1a20208d025ca0c34b20.zip
Merge pull request #24186 from owncloud/fs-initmountpoint-nulluser
Throw NoUserException when attempting to init mount point for null user
-rw-r--r--lib/private/files/filesystem.php3
-rw-r--r--tests/lib/files/filesystem.php22
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index a9138b0d2d7..ec9b537a358 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -372,6 +372,9 @@ class Filesystem {
if ($user == '') {
$user = \OC_User::getUser();
}
+ if ($user === null || $user === false || $user === '') {
+ throw new \OC\User\NoUserException('Attempted to initialize mount points for null user and no user in session');
+ }
if (isset(self::$usersSetup[$user])) {
return;
}
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index db1f22f894a..8245af0ace1 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -320,6 +320,28 @@ class Filesystem extends \Test\TestCase {
}
/**
+ * @expectedException \OC\User\NoUserException
+ */
+ public function testNullUserThrows() {
+ \OC\Files\Filesystem::initMountPoints(null);
+ }
+
+ public function testNullUserThrowsTwice() {
+ $thrown = 0;
+ try {
+ \OC\Files\Filesystem::initMountPoints(null);
+ } catch (NoUserException $e) {
+ $thrown++;
+ }
+ try {
+ \OC\Files\Filesystem::initMountPoints(null);
+ } catch (NoUserException $e) {
+ $thrown++;
+ }
+ $this->assertEquals(2, $thrown);
+ }
+
+ /**
* Tests that the home storage is used for the user's mount point
*/
public function testHomeMount() {