aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-03-19 21:18:48 +0100
committerVincent Petry <pvince81@owncloud.com>2015-03-19 21:18:48 +0100
commit5ba508b3466fb2021cd1ea9e4c4010875dd0be22 (patch)
tree32b78abfecf7017168e627ee1ffd13c5fd70dff6 /lib
parenta9e6eba018eb8cbd552fef51380cbbfff8c29783 (diff)
downloadnextcloud-server-5ba508b3466fb2021cd1ea9e4c4010875dd0be22.tar.gz
nextcloud-server-5ba508b3466fb2021cd1ea9e4c4010875dd0be22.zip
Fix permission checks in Sabre connector
This fixes moving files in and out of shared folders with some exotic permission combinations.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/connector/sabre/objecttree.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php
index 3705aa80586..1de0ee73ec6 100644
--- a/lib/private/connector/sabre/objecttree.php
+++ b/lib/private/connector/sabre/objecttree.php
@@ -158,8 +158,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);
@@ -173,14 +174,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();
}