diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-04-15 11:19:31 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-04-23 12:54:26 +0200 |
commit | 652d417a585ede1564456c446577aa1752253ccd (patch) | |
tree | 068b69d1996342739e1ccba556d83eed48195fb8 /lib | |
parent | b712393e72fc22dc9d38f074b2eca848e6439bcf (diff) | |
download | nextcloud-server-652d417a585ede1564456c446577aa1752253ccd.tar.gz nextcloud-server-652d417a585ede1564456c446577aa1752253ccd.zip |
we don't allow to share a folder if it contains a share mount point
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/view.php | 3 | ||||
-rw-r--r-- | lib/private/share/share.php | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 3f73632be13..a61d58aaf24 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1168,7 +1168,8 @@ class View { * @var \OC\Files\Mount\Mount $mount */ $cache = $mount->getStorage()->getCache(); - if ($internalPath = $cache->getPathById($id)) { + $internalPath = $cache->getPathById($id); + if (is_string($internalPath)) { $fullPath = $mount->getMountPoint() . $internalPath; if (!is_null($path = $this->getRelativePath($fullPath))) { return $path; diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 756a4d173e4..c07dd04b29f 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -489,6 +489,7 @@ class Share extends \OC\Share\Constants { $itemSourceName = $itemSource; } + // verify that the file exists before we try to share it if ($itemType === 'file' or $itemType === 'folder') { $path = \OC\Files\Filesystem::getPath($itemSource); @@ -499,6 +500,21 @@ class Share extends \OC\Share\Constants { } } + //verify that we don't share a folder which already contains a share mount point + if ($itemType === 'folder') { + $path = '/' . $uidOwner . '/files' . \OC\Files\Filesystem::getPath($itemSource) . '/'; + $mountManager = \OC\Files\Filesystem::getMountManager(); + $mounts = $mountManager->getAll(); + foreach ($mounts as $mountPoint => $mount) { + if ($mount->getStorage() instanceof \OC\Files\Storage\Shared && strpos($mountPoint, $path) === 0) { + $message = 'Sharing "' . $itemSourceName . '" failed, because it contains files shared with you!'; + \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); + throw new \Exception($message); + } + + } + } + // Verify share type and sharing conditions are met if ($shareType === self::SHARE_TYPE_USER) { if ($shareWith == $uidOwner) { |