From 3ed51156f971281cef15476c1ac025f44c3a1a0a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Jun 2026 12:07:25 +0200 Subject: [PATCH 1/3] fix: use correct permissions mark for non-home storage public links Signed-off-by: Robin Appelman --- apps/dav/appinfo/v2/publicremote.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/dav/appinfo/v2/publicremote.php b/apps/dav/appinfo/v2/publicremote.php index 3f014f1c65c87..f92d23f01d444 100644 --- a/apps/dav/appinfo/v2/publicremote.php +++ b/apps/dav/appinfo/v2/publicremote.php @@ -7,6 +7,7 @@ */ use OC\Files\Filesystem; use OC\Files\Storage\Wrapper\DirPermissionsMask; +use OC\Files\Storage\Wrapper\PermissionsMask; use OC\Files\View; use OCA\DAV\Connector\Sabre\PublicAuth; use OCA\DAV\Connector\Sabre\ServerFactory; @@ -20,6 +21,7 @@ use OCP\BeforeSabrePubliclyLoadedEvent; use OCP\Constants; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\IHomeStorage; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\ICacheFactory; @@ -111,11 +113,15 @@ $mask |= Constants::PERMISSION_READ | Constants::PERMISSION_DELETE; } - return new DirPermissionsMask([ - 'storage' => $storage, - 'mask' => $mask, - 'path' => 'files', - ]); + if ($storage instanceof IHomeStorage) { + return new DirPermissionsMask([ + 'storage' => $storage, + 'mask' => $mask, + 'path' => 'files', + ]); + } else { + return new PermissionsMask(['storage' => $storage, 'mask' => $mask]); + } }); /** @psalm-suppress MissingClosureParamType */ From 960275b27d4128e5bd4a55481ad196df76b1a757 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Jun 2026 13:34:57 +0200 Subject: [PATCH 2/3] chore: psalm fix Signed-off-by: Robin Appelman --- lib/private/Files/Storage/Wrapper/DirPermissionsMask.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Storage/Wrapper/DirPermissionsMask.php b/lib/private/Files/Storage/Wrapper/DirPermissionsMask.php index 6ab777f309f2f..e1066e8d04f20 100644 --- a/lib/private/Files/Storage/Wrapper/DirPermissionsMask.php +++ b/lib/private/Files/Storage/Wrapper/DirPermissionsMask.php @@ -10,8 +10,8 @@ namespace OC\Files\Storage\Wrapper; use OC\Files\Cache\Wrapper\CacheDirPermissionsMask; -use OC\Files\Storage\Storage; use OCP\Files\Cache\ICache; +use OCP\Files\Storage\IStorage; /** * While PermissionMask can mask a whole storage this can @@ -30,7 +30,7 @@ class DirPermissionsMask extends PermissionsMask { private readonly int $pathLength; /** - * @param array{storage: Storage, mask: int, path: string, ...} $parameters + * @param array{storage: IStorage, mask: int, path: string, ...} $parameters * @psalm-suppress MoreSpecificImplementedParamType * * $storage: The storage the permissions mask should be applied on From 03bbdc4383c3e96d93dcf0802b4ecc022b7f5892 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Jun 2026 16:30:58 +0200 Subject: [PATCH 3/3] test: add test for uploading to publicly shared external storage Signed-off-by: Robin Appelman --- .../integration/features/bootstrap/WebDav.php | 17 ++++++++++++++ .../sharing_features/sharing-v1.feature | 23 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index e433a570a78ab..481cd42abfab0 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -335,6 +335,23 @@ public function downloadedContentShouldStartWith($start) { } } + /** + * @When Uploading public file :filename with content :content + */ + public function uploadingPublicFile(string $filename, string $content) { + $token = $this->lastShareData->data->token; + $fullUrl = substr($this->baseUrl, 0, -4) . "public.php/dav/files/$token/$filename"; + + $client = new GClient(); + try { + $this->response = $client->request('PUT', $fullUrl, [ + 'body' => $content + ]); + } catch (\GuzzleHttp\Exception\ClientException $e) { + $this->response = $e->getResponse(); + } + } + /** * @Then /^as "([^"]*)" gets properties of (file|folder|entry) "([^"]*)" with$/ * @param string $user diff --git a/build/integration/sharing_features/sharing-v1.feature b/build/integration/sharing_features/sharing-v1.feature index 25f168db2e7cb..34f3e5e6aed00 100644 --- a/build/integration/sharing_features/sharing-v1.feature +++ b/build/integration/sharing_features/sharing-v1.feature @@ -556,7 +556,28 @@ Feature: sharing And Share fields of last share match with | expiration | +3 days | - Scenario: getting all shares of a user using that user +Scenario: Writing to a read-only link share of an external storage + Given user "user0" exists + Then As an "user0" + When creating a share with + | path | local_storage | + | shareType | 3 | + And the OCS status code should be "100" + And the HTTP status code should be "200" + Then Uploading public file "foo.txt" with content "bar" + And the HTTP status code should be "403" + +Scenario: Writing to a read-write link share of an external storage + Given user "user0" exists + Then As an "user0" + When creating a share with + | path | local_storage | + | shareType | 3 | + | permissions | 7 | + Then Uploading public file "foo.txt" with content "bar" + And the HTTP status code should be "201" + +Scenario: getting all shares of a user using that user Given user "user0" exists And user "user1" exists And file "textfile0.txt" of user "user0" is shared with user "user1"