From 6e4006d1397817f83c2dd3cafc4d697ac1e6a2a7 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 8 Dec 2015 13:02:57 +0100 Subject: Add reshare permission checks Added in isSharable() in incoming remote share. Added in isSharable() in regular incoming share. Added in FileInfo to make sure the proper attributes are returned to the clients. --- apps/files_sharing/lib/external/storage.php | 8 ++++++++ apps/files_sharing/lib/sharedstorage.php | 2 +- lib/private/files/fileinfo.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php index 2a0d827e064..36ff4f0c226 100644 --- a/apps/files_sharing/lib/external/storage.php +++ b/apps/files_sharing/lib/external/storage.php @@ -265,4 +265,12 @@ class Storage extends DAV implements ISharedStorage { list(, $remote) = explode('://', $this->remote, 2); return $this->remoteUser . '@' . $remote; } + + public function isSharable($path) { + if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) { + return false; + } + return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE); + } + } diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index cda3f564d5f..38f79762dc6 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -257,7 +257,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { } public function isSharable($path) { - if (\OCP\Util::isSharingDisabledForUser()) { + if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) { return false; } return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE); diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php index 0525c259604..5ed65cd3795 100644 --- a/lib/private/files/fileinfo.php +++ b/lib/private/files/fileinfo.php @@ -196,7 +196,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { */ public function getPermissions() { $perms = $this->data['permissions']; - if (\OCP\Util::isSharingDisabledForUser()) { + if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) { $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE; } return $perms; -- cgit v1.2.3