diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-03-26 22:01:05 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-03-26 22:01:05 +0100 |
commit | e8109f0bc3065cb038bc97faa37d0a19e748fdd9 (patch) | |
tree | 7a77c9022000d8e761dd1045afbf60bc37afb18b /lib | |
parent | 4c00be49613fe14a03e996dd0768bcb7ef2795ab (diff) | |
parent | eef5851a6750da9fb15446af09dd8f385131de73 (diff) | |
download | nextcloud-server-e8109f0bc3065cb038bc97faa37d0a19e748fdd9.tar.gz nextcloud-server-e8109f0bc3065cb038bc97faa37d0a19e748fdd9.zip |
Merge pull request #13802 from owncloud/share-partfilepermissions
Fix share permission checks
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/connector/sabre/objecttree.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index 79ae19522c3..999750fd785 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -175,8 +175,9 @@ class ObjectTree extends \Sabre\DAV\Tree { throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); } + $targetNodeExists = $this->nodeExists($destinationPath); $sourceNode = $this->getNodeForPath($sourcePath); - if ($sourceNode instanceof \Sabre\DAV\ICollection and $this->nodeExists($destinationPath)) { + if ($sourceNode instanceof \Sabre\DAV\ICollection && $targetNodeExists) { throw new \Sabre\DAV\Exception\Forbidden('Could not copy directory ' . $sourceNode . ', target exists'); } list($sourceDir,) = \Sabre\HTTP\URLUtil::splitPath($sourcePath); @@ -190,14 +191,22 @@ class ObjectTree extends \Sabre\DAV\Tree { } try { - // check update privileges - if (!$this->fileView->isUpdatable($sourcePath) && !$isMovableMount) { - throw new \Sabre\DAV\Exception\Forbidden(); - } - if ($sourceDir !== $destinationDir) { + $sameFolder = ($sourceDir === $destinationDir); + // if we're overwriting or same folder + if ($targetNodeExists || $sameFolder) { + // note that renaming a share mount point is always allowed + if (!$this->fileView->isUpdatable($destinationDir) && !$isMovableMount) { + throw new \Sabre\DAV\Exception\Forbidden(); + } + } else { if (!$this->fileView->isCreatable($destinationDir)) { throw new \Sabre\DAV\Exception\Forbidden(); } + } + + if (!$sameFolder) { + // moving to a different folder, source will be gone, like a deletion + // note that moving a share mount point is always allowed if (!$this->fileView->isDeletable($sourcePath) && !$isMovableMount) { throw new \Sabre\DAV\Exception\Forbidden(); } |