]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add a wrapper to fall back to the share owner on public shares 20718/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 14 Apr 2020 12:42:28 +0000 (14:42 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 30 Apr 2020 06:57:01 +0000 (08:57 +0200)
Else it might happen that we setup a storage that has no real owner and
activities do boom etc (looking at you groupfolders and external
storages!).

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/dav/appinfo/v1/publicwebdav.php
apps/dav/composer/composer/autoload_classmap.php
apps/dav/composer/composer/autoload_static.php
apps/dav/lib/Storage/PublicOwnerWrapper.php [new file with mode: 0644]

index c50bc134131264c96c7e648d2a7a5d6096bab2de..556dd35de582b1b5abd1ffdf260f6582109bc59c 100644 (file)
@@ -82,7 +82,9 @@ $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, funct
        \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
                return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]);
        });
-
+       \OC\Files\Filesystem::addStorageWrapper('shareOwner', function ($mountPoint, $storage) use ($share) {
+               return new \OCA\DAV\Storage\PublicOwnerWrapper(['storage' => $storage, 'owner' => $share->getShareOwner()]);
+       });
        \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
 
        OC_Util::tearDownFS();
index 9b6108a80521889f0d17ab84df4fda76b7f2e3ed..057f4dddfcb86d779f2c74353debda0f3f6d2153 100644 (file)
@@ -210,6 +210,7 @@ return array(
     'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php',
     'OCA\\DAV\\Server' => $baseDir . '/../lib/Server.php',
     'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir . '/../lib/Settings/CalDAVSettings.php',
+    'OCA\\DAV\\Storage\\PublicOwnerWrapper' => $baseDir . '/../lib/Storage/PublicOwnerWrapper.php',
     'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => $baseDir . '/../lib/SystemTag/SystemTagMappingNode.php',
     'OCA\\DAV\\SystemTag\\SystemTagNode' => $baseDir . '/../lib/SystemTag/SystemTagNode.php',
     'OCA\\DAV\\SystemTag\\SystemTagPlugin' => $baseDir . '/../lib/SystemTag/SystemTagPlugin.php',
index fa57e9406e4ac5331574157b8cb0492dcb4be5cd..ec553beb2bb6d899d0ba411b2a8a5b33a71c8d2c 100644 (file)
@@ -225,6 +225,7 @@ class ComposerStaticInitDAV
         'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php',
         'OCA\\DAV\\Server' => __DIR__ . '/..' . '/../lib/Server.php',
         'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__ . '/..' . '/../lib/Settings/CalDAVSettings.php',
+        'OCA\\DAV\\Storage\\PublicOwnerWrapper' => __DIR__ . '/..' . '/../lib/Storage/PublicOwnerWrapper.php',
         'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagMappingNode.php',
         'OCA\\DAV\\SystemTag\\SystemTagNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagNode.php',
         'OCA\\DAV\\SystemTag\\SystemTagPlugin' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagPlugin.php',
diff --git a/apps/dav/lib/Storage/PublicOwnerWrapper.php b/apps/dav/lib/Storage/PublicOwnerWrapper.php
new file mode 100644 (file)
index 0000000..a02a2e4
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\DAV\Storage;
+
+use OC\Files\Storage\Wrapper\Wrapper;
+
+class PublicOwnerWrapper extends Wrapper {
+
+       /** @var string */
+       private $owner;
+
+       /**
+        * @param array $arguments ['storage' => $storage, 'owner' => $owner]
+        *
+        * $storage: The storage the permissions mask should be applied on
+        * $owner: The owner to use in case no owner is found
+        */
+       public function __construct($arguments) {
+               parent::__construct($arguments);
+               $this->owner = $arguments['owner'];
+       }
+
+       public function getOwner($path) {
+               $owner = parent::getOwner($path);
+
+               if ($owner === null || $owner === false) {
+                       return $this->owner;
+               }
+       }
+}