diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-09-24 13:26:12 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-09-24 13:26:12 +0200 |
commit | ee1f627155cad4153f3da3160ca6040c137841d3 (patch) | |
tree | 64864c6ffec1d150fe68a1136a72d92327ea11d5 /lib/connector/sabre/objecttree.php | |
parent | 40871bab88159d914cfab2dd938a2312ed8eb1c1 (diff) | |
download | nextcloud-server-ee1f627155cad4153f3da3160ca6040c137841d3.tar.gz nextcloud-server-ee1f627155cad4153f3da3160ca6040c137841d3.zip |
adding privilege check on move and rename operations
Diffstat (limited to 'lib/connector/sabre/objecttree.php')
-rw-r--r-- | lib/connector/sabre/objecttree.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/connector/sabre/objecttree.php b/lib/connector/sabre/objecttree.php index acff45ed5e2..7accf98c8e1 100644 --- a/lib/connector/sabre/objecttree.php +++ b/lib/connector/sabre/objecttree.php @@ -64,7 +64,29 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { list($sourceDir,) = \Sabre_DAV_URLUtil::splitPath($sourcePath); list($destinationDir,) = \Sabre_DAV_URLUtil::splitPath($destinationPath); - Filesystem::rename($sourcePath, $destinationPath); + // check update privileges + if ($sourceDir === $destinationDir) { + // for renaming it's enough to check if the sourcePath can be updated + if (!\OC\Files\Filesystem::isUpdatable($sourcePath)) { + throw new \Sabre_DAV_Exception_Forbidden(); + } + } else { + // for a full move we need update privileges on sourcePath and sourceDir as well as destinationDir + if (!\OC\Files\Filesystem::isUpdatable($sourcePath)) { + throw new \Sabre_DAV_Exception_Forbidden(); + } + if (!\OC\Files\Filesystem::isUpdatable($sourceDir)) { + throw new \Sabre_DAV_Exception_Forbidden(); + } + if (!\OC\Files\Filesystem::isUpdatable($destinationDir)) { + throw new \Sabre_DAV_Exception_Forbidden(); + } + } + + $renameOkay = Filesystem::rename($sourcePath, $destinationPath); + if (!$renameOkay) { + throw new \Sabre_DAV_Exception_Forbidden(''); + } $this->markDirty($sourceDir); $this->markDirty($destinationDir); |