From 555d582f35d1704996c3bf72510a8272cc38f833 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= <danxuliu@gmail.com>
Date: Thu, 2 Nov 2017 17:28:58 +0100
Subject: [PATCH] Return whether the file is readable or not in the DAV
 permissions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Until now it was safe to assume that every file was readable by its
owner, so there was no need to return whether the file was readable or
not. However, with the introduction of end to end encryption that is no
longer the case, and it is now necessary to explicitly provide that
information.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
---
 apps/dav/lib/Connector/Sabre/Node.php         |  3 +++
 .../tests/unit/Connector/Sabre/NodeTest.php   | 20 ++++++++++---------
 .../features/sharing-v1-part3.feature         | 12 +++++------
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php
index b6d4090bf8f..a046b734661 100644
--- a/apps/dav/lib/Connector/Sabre/Node.php
+++ b/apps/dav/lib/Connector/Sabre/Node.php
@@ -299,6 +299,9 @@ abstract class Node implements \Sabre\DAV\INode {
 		if ($this->info->isMounted()) {
 			$p .= 'M';
 		}
+		if ($this->info->isReadable()) {
+			$p .= 'G';
+		}
 		if ($this->info->isDeletable()) {
 			$p .= 'D';
 		}
diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
index fe6cbd97829..a6b9e81d9d8 100644
--- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
@@ -41,15 +41,17 @@ use OCP\Share\IShare;
 class NodeTest extends \Test\TestCase {
 	public function davPermissionsProvider() {
 		return array(
-			array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RDNVW'),
-			array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RDNVCK'),
-			array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRDNVW'),
-			array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMDNVW'),
-			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SDNVW'),
-			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RD'),
-			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RNVW'),
-			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RDNVW'),
-			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RDNV'),
+			array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RGDNVW'),
+			array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RGDNVCK'),
+			array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRGDNVW'),
+			array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMGDNVW'),
+			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SGDNVW'),
+			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RGD'),
+			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RGNVW'),
+			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RGDNVW'),
+			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_READ, 'file', false, false, 'RDNVW'),
+			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RGDNV'),
+			array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_READ, 'dir', false, false, 'RDNVCK'),
 		);
 	}
 
diff --git a/build/integration/features/sharing-v1-part3.feature b/build/integration/features/sharing-v1-part3.feature
index b4b1ae9bf94..44a41341a02 100644
--- a/build/integration/features/sharing-v1-part3.feature
+++ b/build/integration/features/sharing-v1-part3.feature
@@ -167,7 +167,7 @@ Feature: sharing
     And folder "/merge-test-outside-perms" of user "user0" is shared with user "user1" with permissions 31
     Then as "user1" gets properties of folder "/merge-test-outside-perms" with
       |{http://owncloud.org/ns}permissions|
-    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
+    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
     And as "user1" the folder "/merge-test-outside-perms (2)" does not exist
 
   Scenario: Merging shares for recipient when shared from outside with two groups
@@ -197,7 +197,7 @@ Feature: sharing
     And folder "/merge-test-outside-twogroups-perms" of user "user0" is shared with group "group2" with permissions 31
     Then as "user1" gets properties of folder "/merge-test-outside-twogroups-perms" with
       |{http://owncloud.org/ns}permissions|
-    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
+    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
     And as "user1" the folder "/merge-test-outside-twogroups-perms (2)" does not exist
 
   Scenario: Merging shares for recipient when shared from outside with two groups and member
@@ -214,7 +214,7 @@ Feature: sharing
     And folder "/merge-test-outside-twogroups-member-perms" of user "user0" is shared with user "user1" with permissions 1
     Then as "user1" gets properties of folder "/merge-test-outside-twogroups-member-perms" with
       |{http://owncloud.org/ns}permissions|
-    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
+    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
     And as "user1" the folder "/merge-test-outside-twogroups-member-perms (2)" does not exist
 
   Scenario: Merging shares for recipient when shared from inside with group
@@ -253,7 +253,7 @@ Feature: sharing
     And folder "/merge-test-inside-twogroups-perms" of user "user0" is shared with group "group2"
     Then as "user0" gets properties of folder "/merge-test-inside-twogroups-perms" with
       |{http://owncloud.org/ns}permissions|
-    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "RDNVCK"
+    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "RGDNVCK"
     And as "user0" the folder "/merge-test-inside-twogroups-perms (2)" does not exist
     And as "user0" the folder "/merge-test-inside-twogroups-perms (3)" does not exist
 
@@ -270,7 +270,7 @@ Feature: sharing
     And folder "/merge-test-outside-groups-renamebeforesecondshare" of user "user0" is shared with user "user1"
     Then as "user1" gets properties of folder "/merge-test-outside-groups-renamebeforesecondshare-renamed" with
       |{http://owncloud.org/ns}permissions|
-    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
+    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
     And as "user1" the folder "/merge-test-outside-groups-renamebeforesecondshare" does not exist
 
   Scenario: Merging shares for recipient when shared from outside with user then group and recipient renames in between
@@ -287,7 +287,7 @@ Feature: sharing
     And folder "/merge-test-outside-groups-renamebeforesecondshare" of user "user0" is shared with group "group1"
     Then as "user1" gets properties of folder "/merge-test-outside-groups-renamebeforesecondshare-renamed" with
       |{http://owncloud.org/ns}permissions|
-    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK"
+    And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRGDNVCK"
     And as "user1" the folder "/merge-test-outside-groups-renamebeforesecondshare" does not exist
 
   Scenario: Empting trashbin
-- 
GitLab