[Pkg-owncloud-commits] [owncloud] 127/145: Added extra checks for ext storage class

David Prévot taffit at moszumanska.debian.org
Wed Feb 26 16:27:47 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 928947f1c3594e88f6562f6b6cd2574d81c272ff
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Wed Feb 19 19:08:28 2014 +0100

    Added extra checks for ext storage class
---
 apps/files_external/lib/config.php        |  8 +++++++-
 apps/files_external/tests/mountconfig.php | 25 +++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 6d6e9a1..9896429 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -267,15 +267,21 @@ class OC_Mount_Config {
 										 $mountType,
 										 $applicable,
 										 $isPersonal = false) {
+		$backends = self::getBackends();
 		$mountPoint = OC\Files\Filesystem::normalizePath($mountPoint);
 		if ($mountPoint === '' || $mountPoint === '/' || $mountPoint == '/Shared') {
 			// can't mount at root or "Shared" folder
 			return false;
 		}
+
+		if (!isset($backends[$class])) {
+			// invalid backend
+			return false;
+		}	
 		if ($isPersonal) {
 			// Verify that the mount point applies for the current user
 			// Prevent non-admin users from mounting local storage
-			if ($applicable != OCP\User::getUser() || $class == '\OC\Files\Storage\Local') {
+			if ($applicable !== OCP\User::getUser() || strtolower($class) === '\oc\files\storage\local') {
 				return false;
 			}
 			$mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/');
diff --git a/apps/files_external/tests/mountconfig.php b/apps/files_external/tests/mountconfig.php
index 941aec6..24ebcf5 100644
--- a/apps/files_external/tests/mountconfig.php
+++ b/apps/files_external/tests/mountconfig.php
@@ -48,4 +48,29 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
 		$this->assertEquals(false, OC_Mount_Config::addMountPoint('/Shared', $storageClass, array(), $mountType, $applicable, $isPersonal));
 
 	}
+
+	public function testAddMountPointSingleUser() {
+		\OC_User::setUserId('test');
+		$mountType = 'user';
+		$applicable = 'test';
+		$isPersonal = true;
+		// local
+		$this->assertEquals(false, OC_Mount_Config::addMountPoint('/ext', '\OC\Files\storage\local', array(), $mountType, $applicable, $isPersonal));
+		// non-local
+		// FIXME: can't test this yet as the class (write operation) is not mockable
+		// $this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', array(), $mountType, $applicable, $isPersonal));
+
+	}
+
+	public function testAddMountPointUnexistClass() {
+		\OC_User::setUserId('test');
+		$storageClass = 'Unexist_Storage';
+		$mountType = 'user';
+		$applicable = 'test';
+		$isPersonal = true;
+		// local
+		// non-local
+		$this->assertEquals(false, OC_Mount_Config::addMountPoint('/ext', $storageClass, array(), $mountType, $applicable, $isPersonal));
+
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list