summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2015-10-02 16:50:38 +0200
committerRobin Appelman <robin@icewind.nl>2015-10-02 16:50:38 +0200
commit8bdffb5ed3d45e026b47e62fc8e07dfd107553e0 (patch)
treef94ab10bac90b83cf3d7f3dd5fd61d667c7edefa /lib/private
parentaf01c043601c31ba0f7b1f3f173d8bdc6f85295f (diff)
parent64ca00925b0384592091cab3e596d5427c1c5517 (diff)
downloadnextcloud-server-8bdffb5ed3d45e026b47e62fc8e07dfd107553e0.tar.gz
nextcloud-server-8bdffb5ed3d45e026b47e62fc8e07dfd107553e0.zip
Merge pull request #19525 from owncloud/share-preventmovemountpointintosharedfolder
Prevent moving mount point into already shared folder (outgoing)
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/files/view.php37
1 files changed, 29 insertions, 8 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 95b688fef5c..c8dbc001f2d 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1602,25 +1602,46 @@ class View {
/**
* check if it is allowed to move a mount point to a given target.
- * It is not allowed to move a mount point into a different mount point
+ * It is not allowed to move a mount point into a different mount point or
+ * into an already shared folder
*
* @param string $target path
* @return boolean
*/
private function isTargetAllowed($target) {
- $result = false;
-
- list($targetStorage,) = \OC\Files\Filesystem::resolvePath($target);
- if ($targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
- $result = true;
- } else {
+ list($targetStorage, $targetInternalPath) = \OC\Files\Filesystem::resolvePath($target);
+ if (!$targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
\OCP\Util::writeLog('files',
'It is not allowed to move one mount point into another one',
\OCP\Util::DEBUG);
+ return false;
}
- return $result;
+ // note: cannot use the view because the target is already locked
+ $fileId = (int)$targetStorage->getCache()->getId($targetInternalPath);
+ if ($fileId === -1) {
+ // target might not exist, need to check parent instead
+ $fileId = (int)$targetStorage->getCache()->getId(dirname($targetInternalPath));
+ }
+
+ // check if any of the parents were shared by the current owner (include collections)
+ $shares = \OCP\Share::getItemShared(
+ 'folder',
+ $fileId,
+ \OCP\Share::FORMAT_NONE,
+ null,
+ true
+ );
+
+ if (count($shares) > 0) {
+ \OCP\Util::writeLog('files',
+ 'It is not allowed to move one mount point into a shared folder',
+ \OCP\Util::DEBUG);
+ return false;
+ }
+
+ return true;
}
/**