Merge pull request #9329 from owncloud/sharing_check_target

don't move a share mount point into a different mount point
remotes/origin/ldap_group_count
Vincent Petry 11 years ago
commit ed29e7d160
  1. 1
      apps/files_sharing/lib/external/mount.php
  2. 1
      apps/files_sharing/lib/helper.php
  3. 10
      apps/files_sharing/lib/sharedmount.php
  4. 2
      lib/private/files/objectstore/homeobjectstorestorage.php
  5. 2
      lib/private/files/storage/home.php
  6. 41
      lib/private/files/view.php
  7. 4
      lib/public/files/storage.php

@ -38,6 +38,7 @@ class Mount extends \OC\Files\Mount\Mount implements MoveableMount {
public function moveMount($target) {
$result = $this->manager->setMountPoint($this->mountPoint, $target);
$this->setMountPoint($target);
return $result;
}

@ -236,4 +236,5 @@ class Helper {
$result = $appConfig->getValue('files_sharing', 'incoming_server2server_share_enabled', 'yes');
return ($result === 'yes') ? true : false;
}
}

@ -8,10 +8,8 @@
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
use OC\Files\Mount\Mount;
use OC\Files\Mount\MoveableMount;
use OC\Files\Storage\Shared;
/**
* Shared mount points can be moved by the user
@ -119,14 +117,6 @@ class SharedMount extends Mount implements MoveableMount {
* @return bool
*/
public function moveMount($target) {
// it shouldn't be possible to move a Shared storage into another one
list($targetStorage,) = Filesystem::resolvePath($target);
if ($targetStorage instanceof Shared) {
\OCP\Util::writeLog('file sharing',
'It is not allowed to move one mount point into another one',
\OCP\Util::DEBUG);
return false;
}
$relTargetPath = $this->stripUserFilesPath($target);
$share = $this->storage->getShare();

@ -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

@ -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
*/

@ -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;
}
}

@ -336,3 +336,7 @@ interface Storage {
*/
public function instanceOfStorage($class);
}
interface IHomeStorage {
}

Loading…
Cancel
Save