Added extra checks for ext storage class
This commit is contained in:
parent
952584e9c7
commit
9e9a5b9ea1
|
@ -277,15 +277,21 @@ class OC_Mount_Config {
|
||||||
$mountType,
|
$mountType,
|
||||||
$applicable,
|
$applicable,
|
||||||
$isPersonal = false) {
|
$isPersonal = false) {
|
||||||
|
$backends = self::getBackends();
|
||||||
$mountPoint = OC\Files\Filesystem::normalizePath($mountPoint);
|
$mountPoint = OC\Files\Filesystem::normalizePath($mountPoint);
|
||||||
if ($mountPoint === '' || $mountPoint === '/' || $mountPoint == '/Shared') {
|
if ($mountPoint === '' || $mountPoint === '/' || $mountPoint == '/Shared') {
|
||||||
// can't mount at root or "Shared" folder
|
// can't mount at root or "Shared" folder
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($backends[$class])) {
|
||||||
|
// invalid backend
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if ($isPersonal) {
|
if ($isPersonal) {
|
||||||
// Verify that the mount point applies for the current user
|
// Verify that the mount point applies for the current user
|
||||||
// Prevent non-admin users from mounting local storage
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
$mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/');
|
$mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/');
|
||||||
|
|
|
@ -48,4 +48,28 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals(false, OC_Mount_Config::addMountPoint('/Shared', $storageClass, array(), $mountType, $applicable, $isPersonal));
|
$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
|
||||||
|
$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));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue