summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-04-23 15:28:10 +0200
committerVincent Petry <pvince81@owncloud.com>2015-04-23 15:28:10 +0200
commita672e9d5563998205923b3b388208bb4b8242048 (patch)
tree6c8a255ba4feb3e62a7b99b7d0d7f14a4ce5ae36 /apps
parentd1ef96dc9b90eb72475cecf93960a2701b12ed26 (diff)
parent7a3a8e403266fa5db1250c89cbd9e43e7fe59269 (diff)
downloadnextcloud-server-a672e9d5563998205923b3b388208bb4b8242048.tar.gz
nextcloud-server-a672e9d5563998205923b3b388208bb4b8242048.zip
Merge pull request #15814 from owncloud/public-reshare-webdav
Fix webdav access for public reshare
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/readonlycache.php44
-rw-r--r--apps/files_sharing/lib/readonlywrapper.php5
-rw-r--r--apps/files_sharing/publicwebdav.php3
-rw-r--r--apps/files_sharing/tests/readonlycache.php93
4 files changed, 6 insertions, 139 deletions
diff --git a/apps/files_sharing/lib/readonlycache.php b/apps/files_sharing/lib/readonlycache.php
deleted file mode 100644
index c7640f896f4..00000000000
--- a/apps/files_sharing/lib/readonlycache.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\Files_Sharing;
-
-use OC\Files\Cache\Cache;
-
-class ReadOnlyCache extends Cache {
- public function get($path) {
- $data = parent::get($path);
- if ($data !== false) {
- $data['permissions'] &= (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE);
- }
- return $data;
- }
-
- public function getFolderContents($path) {
- $content = parent::getFolderContents($path);
- foreach ($content as &$data) {
- $data['permissions'] &= (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE);
- }
- return $content;
- }
-}
diff --git a/apps/files_sharing/lib/readonlywrapper.php b/apps/files_sharing/lib/readonlywrapper.php
index 067000ff47c..a5d84f7f5a2 100644
--- a/apps/files_sharing/lib/readonlywrapper.php
+++ b/apps/files_sharing/lib/readonlywrapper.php
@@ -23,7 +23,9 @@
namespace OCA\Files_Sharing;
+use OC\Files\Cache\Wrapper\CachePermissionsMask;
use OC\Files\Storage\Wrapper\Wrapper;
+use OCP\Constants;
class ReadOnlyWrapper extends Wrapper {
public function isUpdatable($path) {
@@ -66,6 +68,7 @@ class ReadOnlyWrapper extends Wrapper {
if (!$storage) {
$storage = $this;
}
- return new ReadOnlyCache($storage);
+ $sourceCache = $this->storage->getCache($path, $storage);
+ return new CachePermissionsMask($sourceCache, Constants::PERMISSION_READ | Constants::PERMISSION_SHARE);
}
}
diff --git a/apps/files_sharing/publicwebdav.php b/apps/files_sharing/publicwebdav.php
index 3a961f5d757..3be464c64f0 100644
--- a/apps/files_sharing/publicwebdav.php
+++ b/apps/files_sharing/publicwebdav.php
@@ -56,7 +56,8 @@ $server->addPlugin(new \OC\Connector\Sabre\ExceptionLoggerPlugin('webdav', \OC::
// wait with registering these until auth is handled and the filesystem is setup
$server->on('beforeMethod', function () use ($server, $objectTree, $authBackend) {
$share = $authBackend->getShare();
- $owner = $share['uid_owner'];
+ $rootShare = \OCP\Share::resolveReShare($share);
+ $owner = $rootShare['uid_owner'];
$isWritable = $share['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
$fileId = $share['file_source'];
diff --git a/apps/files_sharing/tests/readonlycache.php b/apps/files_sharing/tests/readonlycache.php
deleted file mode 100644
index 5da200fa78f..00000000000
--- a/apps/files_sharing/tests/readonlycache.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OCA\Files_Sharing\Tests;
-
-class ReadOnlyCache extends TestCase {
-
- /** @var \OC\Files\Storage\Storage */
- protected $storage;
-
- /** @var \OC\Files\Storage\StorageFactory */
- protected $loader;
-
- /** @var \OC\Files\Mount\MountPoint */
- protected $readOnlyMount;
-
- /** @var \OCA\Files_Sharing\ReadOnlyWrapper */
- protected $readOnlyStorage;
-
- /** @var \OC\Files\Cache\Cache */
- protected $readOnlyCache;
-
- protected function setUp() {
- parent::setUp();
-
- $this->view->mkdir('readonly');
- $this->view->file_put_contents('readonly/foo.txt', 'foo');
- $this->view->file_put_contents('readonly/bar.txt', 'bar');
-
- list($this->storage) = $this->view->resolvePath('');
- $this->loader = new \OC\Files\Storage\StorageFactory();
- $this->readOnlyMount = new \OC\Files\Mount\MountPoint($this->storage,
- '/readonly', [[]], $this->loader);
- $this->readOnlyStorage = $this->loader->getInstance($this->readOnlyMount,
- '\OCA\Files_Sharing\ReadOnlyWrapper', ['storage' => $this->storage]);
-
- $this->readOnlyCache = $this->readOnlyStorage->getCache();
- }
-
- public function testSetup() {
- $this->assertTrue($this->view->file_exists('/readonly/foo.txt'));
-
- $perms = $this->readOnlyStorage->getPermissions('files/readonly/foo.txt');
- $this->assertEquals(17, $perms);
-
- $this->assertFalse($this->readOnlyStorage->unlink('files/readonly/foo.txt'));
- $this->assertTrue($this->readOnlyStorage->file_exists('files/readonly/foo.txt'));
-
- $this->assertInstanceOf('\OCA\Files_Sharing\ReadOnlyCache', $this->readOnlyCache);
- }
-
- public function testGetWhenFileExists() {
- $result = $this->readOnlyCache->get('files/readonly/foo.txt');
- $this->assertNotEmpty($result);
- }
-
- public function testGetWhenFileDoesNotExist() {
- $result = $this->readOnlyCache->get('files/readonly/proof does not exist.md');
- $this->assertFalse($result);
- }
-
- public function testGetFolderContentsWhenFolderExists() {
- $results = $this->readOnlyCache->getFolderContents('files/readonly');
- $this->assertNotEmpty($results);
-
- foreach ($results as $result) {
- $this->assertNotEmpty($result);
- }
- }
-
- public function testGetFolderContentsWhenFolderDoesNotExist() {
- $results = $this->readOnlyCache->getFolderContents('files/iamaghost');
- $this->assertEmpty($results);
- }
-
-}