diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2018-09-19 12:15:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-19 12:15:40 +0200 |
commit | 06141b2b8adf2cc56c7ff9bf6fc6c94c1db8c4f2 (patch) | |
tree | 0228a3a63d48bdc6cba98b596f0d31748131599a /apps | |
parent | d8f554944d0757f51e747f93113a4d873920d1f3 (diff) | |
parent | a2725c31e4f0e043c96bb6b5fdb75bb4c43a3227 (diff) | |
download | nextcloud-server-06141b2b8adf2cc56c7ff9bf6fc6c94c1db8c4f2.tar.gz nextcloud-server-06141b2b8adf2cc56c7ff9bf6fc6c94c1db8c4f2.zip |
Merge pull request #11041 from nextcloud/fix/noid/get_permission_of_storage_for_shares
Check the permission of the underlying storage
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 13 | ||||
-rw-r--r-- | apps/files_sharing/tests/PermissionsTest.php | 14 |
3 files changed, 18 insertions, 11 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 352001ecbd4..f3712ead58b 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -142,7 +142,7 @@ class Cache extends CacheJail { } else { $entry['path'] = $path; } - $sharePermissions = $this->storage->getPermissions($path); + $sharePermissions = $this->storage->getPermissions($entry['path']); if (isset($entry['permissions'])) { $entry['permissions'] &= $sharePermissions; } else { diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 2d2f14fc554..34a21fcd637 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -195,7 +195,8 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto if (!$this->isValid()) { return 0; } - $permissions = $this->superShare->getPermissions(); + $permissions = parent::getPermissions($target) & $this->superShare->getPermissions(); + // part files and the mount point always have delete permissions if ($target === '' || pathinfo($target, PATHINFO_EXTENSION) === 'part') { $permissions |= \OCP\Constants::PERMISSION_DELETE; @@ -257,11 +258,17 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto case 'xb': case 'a': case 'ab': - $creatable = $this->isCreatable($path); + $creatable = $this->isCreatable(dirname($path)); $updatable = $this->isUpdatable($path); // if neither permissions given, no need to continue if (!$creatable && !$updatable) { - return false; + if (pathinfo($path, PATHINFO_EXTENSION) === 'part') { + $updatable = $this->isUpdatable(dirname($path)); + } + + if (!$updatable) { + return false; + } } $exists = $this->file_exists($path); diff --git a/apps/files_sharing/tests/PermissionsTest.php b/apps/files_sharing/tests/PermissionsTest.php index 2eca474e966..5c0086646de 100644 --- a/apps/files_sharing/tests/PermissionsTest.php +++ b/apps/files_sharing/tests/PermissionsTest.php @@ -134,14 +134,14 @@ class PermissionsTest extends TestCase { * Test that the permissions of shared directory are returned correctly */ function testGetPermissions() { - $sharedDirPerms = $this->sharedStorage->getPermissions('shareddir'); + $sharedDirPerms = $this->sharedStorage->getPermissions(''); $this->assertEquals(31, $sharedDirPerms); - $sharedDirPerms = $this->sharedStorage->getPermissions('shareddir/textfile.txt'); - $this->assertEquals(31, $sharedDirPerms); - $sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('shareddirrestricted'); - $this->assertEquals(7, $sharedDirRestrictedPerms); - $sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('shareddirrestricted/textfile.txt'); - $this->assertEquals(7, $sharedDirRestrictedPerms); + $sharedDirPerms = $this->sharedStorage->getPermissions('textfile.txt'); + $this->assertEquals(27, $sharedDirPerms); + $sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions(''); + $this->assertEquals(15, $sharedDirRestrictedPerms); + $sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('textfile1.txt'); + $this->assertEquals(3, $sharedDirRestrictedPerms); } /** |