diff options
author | icewind1991 <robin@icewind.nl> | 2014-06-25 15:01:34 +0200 |
---|---|---|
committer | icewind1991 <robin@icewind.nl> | 2014-06-25 15:01:34 +0200 |
commit | c94c69aea1ad668f7b8f523a89bcb12dab561589 (patch) | |
tree | a613e6b5d16a4adc046ac3928d8382ec97189bd1 | |
parent | b1116880f861cf5b72d45a9edfabfdd7d48a9887 (diff) | |
parent | 113749bd96811312ef390d0e760e6206bba90e46 (diff) | |
download | nextcloud-server-c94c69aea1ad668f7b8f523a89bcb12dab561589.tar.gz nextcloud-server-c94c69aea1ad668f7b8f523a89bcb12dab561589.zip |
Merge pull request #9189 from owncloud/sharing_fix_permissions
Sharing fix permissions
-rw-r--r-- | apps/files_sharing/lib/cache.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/tests/permissions.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/tests/sharedstorage.php | 31 | ||||
-rw-r--r-- | lib/private/files/view.php | 2 |
4 files changed, 37 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 7a6b70d82b5..6bc9e131949 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -95,9 +95,9 @@ class Shared_Cache extends Cache { } $data['uid_owner'] = $this->storage->getOwner($file); if (isset($data['permissions'])) { - $data['permissions'] &= $this->storage->getPermissions(''); + $data['permissions'] &= $this->storage->getPermissions($file); } else { - $data['permissions'] = $this->storage->getPermissions(''); + $data['permissions'] = $this->storage->getPermissions($file); } return $data; } @@ -163,7 +163,7 @@ class Shared_Cache extends Cache { $sourceFolderContent[$key]['path'] = $dir . $c['name']; $sourceFolderContent[$key]['uid_owner'] = $parent['uid_owner']; $sourceFolderContent[$key]['displayname_owner'] = $parent['uid_owner']; - $sourceFolderContent[$key]['permissions'] = $sourceFolderContent[$key]['permissions'] & $this->storage->getPermissions(''); + $sourceFolderContent[$key]['permissions'] = $sourceFolderContent[$key]['permissions'] & $this->storage->getPermissions($dir . $c['name']); } return $sourceFolderContent; diff --git a/apps/files_sharing/tests/permissions.php b/apps/files_sharing/tests/permissions.php index 2cbc412d261..299e471a3fd 100644 --- a/apps/files_sharing/tests/permissions.php +++ b/apps/files_sharing/tests/permissions.php @@ -145,10 +145,9 @@ class Test_Files_Sharing_Permissions extends Test_Files_Sharing_Base { $this->assertEquals(27, $contents[1]['permissions']); $contents = $this->secondView->getDirectoryContent('files/shareddirrestricted'); $this->assertEquals('subdir', $contents[0]['name']); - $this->assertEquals(7 | \OCP\PERMISSION_DELETE, $contents[0]['permissions']); + $this->assertEquals(7, $contents[0]['permissions']); $this->assertEquals('textfile1.txt', $contents[1]['name']); // 3 is correct because create is reserved to folders only - // delete permissions are added since mount points can always be deleted - $this->assertEquals(3 | \OCP\PERMISSION_DELETE, $contents[1]['permissions']); + $this->assertEquals(3, $contents[1]['permissions']); } } diff --git a/apps/files_sharing/tests/sharedstorage.php b/apps/files_sharing/tests/sharedstorage.php index b80ab6b4f14..27f3b5150d5 100644 --- a/apps/files_sharing/tests/sharedstorage.php +++ b/apps/files_sharing/tests/sharedstorage.php @@ -166,4 +166,35 @@ class Test_Files_Sharing_Storage extends Test_Files_Sharing_Base { $this->assertTrue($result); } + function testGetPermissions() { + $fileinfoFolder = $this->view->getFileInfo($this->folder); + + $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, + self::TEST_FILES_SHARING_API_USER2, 1); + $this->assertTrue($result); + + self::loginHelper(self::TEST_FILES_SHARING_API_USER2); + + $this->assertTrue(\OC\Files\Filesystem::is_dir($this->folder)); + + // for the share root we expect: + // the shared permissions (1) + // the delete permission (8), to enable unshare + // the update permission (2), to allow renaming of the mount point + $rootInfo = \OC\Files\Filesystem::getFileInfo($this->folder); + $this->assertSame(11, $rootInfo->getPermissions()); + + // for the file within the shared folder we expect: + // the shared permissions (1) + $subfileInfo = \OC\Files\Filesystem::getFileInfo($this->folder . $this->filename); + $this->assertSame(1, $subfileInfo->getPermissions()); + + + //cleanup + self::loginHelper(self::TEST_FILES_SHARING_API_USER1); + $result = \OCP\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, + self::TEST_FILES_SHARING_API_USER2); + $this->assertTrue($result); + } + } diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 91d7ea260d3..ff3cb9ee68b 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -896,7 +896,7 @@ class View { return false; } - if ($mount instanceof MoveableMount) { + if ($mount instanceof MoveableMount && $internalPath === '') { $data['permissions'] |= \OCP\PERMISSION_DELETE | \OCP\PERMISSION_UPDATE; } |