diff --git a/apps/dav/appinfo/v2/publicremote.php b/apps/dav/appinfo/v2/publicremote.php index 03b8fb21f8519..865c8d311cac7 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; @@ -21,6 +22,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; @@ -116,11 +118,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 */ diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index fb2e441d93791..984fd8478ca50 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 dad3d6ee6fd9a..0200f7fda00d6 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 When User "user1" deletes file "/textfile0.txt" 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