summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-07-02 21:01:03 +0200
committerVincent Petry <pvince81@owncloud.com>2014-07-02 21:01:03 +0200
commited29e7d1606ae073ab156ab1bf086ddec2b94bb3 (patch)
tree1b7170cfea5291f1b0bd774a73ec45c5f0108392 /lib
parentf1f66ff686a6b419fa06c11ecc0797238e45c7e2 (diff)
parentbb935978fa1af1dd304bf2a5aad4d135dfea8268 (diff)
downloadnextcloud-server-ed29e7d1606ae073ab156ab1bf086ddec2b94bb3.tar.gz
nextcloud-server-ed29e7d1606ae073ab156ab1bf086ddec2b94bb3.zip
Merge pull request #9329 from owncloud/sharing_check_target
don't move a share mount point into a different mount point
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/objectstore/homeobjectstorestorage.php2
-rw-r--r--lib/private/files/storage/home.php2
-rw-r--r--lib/private/files/view.php41
-rw-r--r--lib/public/files/storage.php4
4 files changed, 40 insertions, 9 deletions
diff --git a/lib/private/files/objectstore/homeobjectstorestorage.php b/lib/private/files/objectstore/homeobjectstorestorage.php
index 26a2788d860..947fc496b20 100644
--- a/lib/private/files/objectstore/homeobjectstorestorage.php
+++ b/lib/private/files/objectstore/homeobjectstorestorage.php
@@ -22,7 +22,7 @@ namespace OC\Files\ObjectStore;
use OC\User\User;
-class HomeObjectStoreStorage extends ObjectStoreStorage {
+class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IHomeStorage {
/**
* The home user storage requires a user object to create a unique storage id
diff --git a/lib/private/files/storage/home.php b/lib/private/files/storage/home.php
index 214deede620..015b1f01885 100644
--- a/lib/private/files/storage/home.php
+++ b/lib/private/files/storage/home.php
@@ -11,7 +11,7 @@ namespace OC\Files\Storage;
/**
* Specialized version of Local storage for home directory usage
*/
-class Home extends Local {
+class Home extends Local implements \OCP\Files\IHomeStorage {
/**
* @var string
*/
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index ff3cb9ee68b..1a9b0e8d2ae 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -440,13 +440,17 @@ class View {
$internalPath1 = $mount->getInternalPath($absolutePath1 . $postFix1);
list(, $internalPath2) = Filesystem::resolvePath($absolutePath2 . $postFix2);
if ($internalPath1 === '' and $mount instanceof MoveableMount) {
- /**
- * @var \OC\Files\Mount\Mount | \OC\Files\Mount\MoveableMount $mount
- */
- $sourceMountPoint = $mount->getMountPoint();
- $result = $mount->moveMount($absolutePath2);
- $manager->moveMount($sourceMountPoint, $mount->getMountPoint());
- \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2);
+ if ($this->isTargetAllowed($absolutePath2)) {
+ /**
+ * @var \OC\Files\Mount\Mount | \OC\Files\Mount\MoveableMount $mount
+ */
+ $sourceMountPoint = $mount->getMountPoint();
+ $result = $mount->moveMount($absolutePath2);
+ $manager->moveMount($sourceMountPoint, $mount->getMountPoint());
+ \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2);
+ } else {
+ $result = false;
+ }
} elseif ($mp1 == $mp2) {
if ($storage1) {
$result = $storage1->rename($internalPath1, $internalPath2);
@@ -1185,4 +1189,27 @@ class View {
throw new \OCP\Files\InvalidPathException("Path length($pathLen) exceeds max path length($maxLen): $path");
}
}
+
+ /**
+ * 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
+ *
+ * @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 {
+ \OCP\Util::writeLog('files',
+ 'It is not allowed to move one mount point into another one',
+ \OCP\Util::DEBUG);
+ }
+
+ return $result;
+ }
}
diff --git a/lib/public/files/storage.php b/lib/public/files/storage.php
index 323d20db564..8f8d7852ee4 100644
--- a/lib/public/files/storage.php
+++ b/lib/public/files/storage.php
@@ -336,3 +336,7 @@ interface Storage {
*/
public function instanceOfStorage($class);
}
+
+interface IHomeStorage {
+
+}