Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function create(
) {
$canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', false);

if ($backend === 'local' && $canCreateNewLocalStorage === false) {
if (($backend === 'local' || $backend === '\OC\Files\Storage\Local') && $canCreateNewLocalStorage === false) {
return new DataResponse(
null,
Http::STATUS_FORBIDDEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function create(
);
}
$canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', false);
if ($backend === 'local' && $canCreateNewLocalStorage === false) {
if (($backend === 'local' || $backend === '\OC\Files\Storage\Local') && $canCreateNewLocalStorage === false) {
return new DataResponse(
null,
Http::STATUS_FORBIDDEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,38 @@ public function testCreate() {
$this->assertEquals($expectedStorage, $actual);
}

public function testCreateLocal() {
$mount = 'randomMount';
$backend = 'local';
$auth = 'identifier:\Random\Missing\Auth\Class';
$backendOpts = [
'datadir' => '/tmp',
];
$priority = 3;

// there is already a teardown in the parent class setting this value to false
\OC::$server->getSystemConfig()->setValue('files_external_allow_create_new_local', false);

$result = $this->controller->create($mount, $backend, $auth, $backendOpts, [], [], [], $priority);
$this->assertEquals(Http::STATUS_FORBIDDEN, $result->getStatus());
}

public function testCreateLocalClassname() {
$mount = 'randomMount';
$backend = '\OC\Files\Storage\Local';
$auth = 'identifier:\Random\Missing\Auth\Class';
$backendOpts = [
'datadir' => '/tmp',
];
$priority = 3;

// there is already a teardown in the parent class setting this value to false
\OC::$server->getSystemConfig()->setValue('files_external_allow_create_new_local', false);

$result = $this->controller->create($mount, $backend, $auth, $backendOpts, [], [], [], $priority);
$this->assertEquals(Http::STATUS_FORBIDDEN, $result->getStatus());
}

public function testUpdate() {
$mount = 'randomMount';
$backend = 'identifier:\This\Doesnt\Exist';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,38 @@ public function testCreate() {
$this->assertEquals($expectedStorage, $actual);
}

public function testCreateLocal() {
$mount = 'randomMount';
$backend = 'local';
$auth = 'identifier:\Random\Missing\Auth\Class';
$backendOpts = [
'datadir' => '/tmp',
];
$priority = 3;

// there is already a teardown in the parent class setting this value to false
\OC::$server->getSystemConfig()->setValue('files_external_allow_create_new_local', false);

$result = $this->controller->create($mount, $backend, $auth, $backendOpts, [], [], [], $priority);
$this->assertEquals(Http::STATUS_FORBIDDEN, $result->getStatus());
}

public function testCreateLocalClassname() {
$mount = 'randomMount';
$backend = '\OC\Files\Storage\Local';
$auth = 'identifier:\Random\Missing\Auth\Class';
$backendOpts = [
'datadir' => '/tmp',
];
$priority = 3;

// there is already a teardown in the parent class setting this value to false
\OC::$server->getSystemConfig()->setValue('files_external_allow_create_new_local', false);

$result = $this->controller->create($mount, $backend, $auth, $backendOpts, [], [], [], $priority);
$this->assertEquals(Http::STATUS_FORBIDDEN, $result->getStatus());
}

public function testUpdate() {
$mount = 'randomMount';
$backend = 'identifier:\This\Doesnt\Exist';
Expand Down
8 changes: 8 additions & 0 deletions changelog/unreleased/41538
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Prevent mounting local storage if not allowed.

Mounting a local storage was possible if the internal class name was used as
backend, despite local storage not allowed to be mounted. This problem is
fixed and the local storage can't be mounted if is was explicitly disallowed in
the configuration.

https://github.com/owncloud/core/pull/41538
Loading