summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-04-15 09:02:01 +0200
committerRoeland Jago Douma <rullzer@owncloud.com>2016-04-19 14:04:00 +0200
commitafa37d363fe1bedfe85a4dbd53adb091f3b014b2 (patch)
tree7724697e16c71aa4c8ac67d1c09d6520459a3fcd
parent6123badbfa22b79167c4b41f84a38b372f033a2e (diff)
downloadnextcloud-server-afa37d363fe1bedfe85a4dbd53adb091f3b014b2.tar.gz
nextcloud-server-afa37d363fe1bedfe85a4dbd53adb091f3b014b2.zip
Fix related logic
-rw-r--r--apps/dav/lib/connector/sabre/node.php2
-rw-r--r--lib/private/Share20/Manager.php51
-rw-r--r--lib/private/files/config/usermountcache.php2
-rw-r--r--lib/private/files/storage/wrapper/jail.php15
-rw-r--r--lib/private/helper.php2
5 files changed, 48 insertions, 24 deletions
diff --git a/apps/dav/lib/connector/sabre/node.php b/apps/dav/lib/connector/sabre/node.php
index eaba6713992..979149fc937 100644
--- a/apps/dav/lib/connector/sabre/node.php
+++ b/apps/dav/lib/connector/sabre/node.php
@@ -224,7 +224,7 @@ abstract class Node implements \Sabre\DAV\INode {
if ($storage->instanceOfStorage('\OC\Files\Storage\Shared')) {
/** @var \OC\Files\Storage\Shared $storage */
- $permissions = (int)$storage->getShare()['permissions'];
+ $permissions = (int)$storage->getShare()->getPermissions();
} else {
$permissions = $storage->getPermissions($path);
}
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 1ec25750cfe..dee9e0cdd21 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -237,6 +237,17 @@ class Manager implements IManager {
if (($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) {
throw new \InvalidArgumentException('Shares need at least read permissions');
}
+
+ if ($share->getNode() instanceof \OCP\Files\File) {
+ if ($share->getPermissions() & \OCP\Constants::PERMISSION_DELETE) {
+ $message_t = $this->l->t('Files can\'t be shared with delete permissions');
+ throw new GenericShareException($message_t);
+ }
+ if ($share->getPermissions() & \OCP\Constants::PERMISSION_CREATE) {
+ $message_t = $this->l->t('Files can\'t be shared with create permissions');
+ throw new GenericShareException($message_t);
+ }
+ }
}
/**
@@ -505,6 +516,24 @@ class Manager implements IManager {
$this->generalCreateChecks($share);
+ // Verify if there are any issues with the path
+ $this->pathCreateChecks($share->getNode());
+
+ /*
+ * On creation of a share the owner is always the owner of the path
+ * Except for mounted federated shares.
+ */
+ $storage = $share->getNode()->getStorage();
+ if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
+ $parent = $share->getNode()->getParent();
+ while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
+ $parent = $parent->getParent();
+ }
+ $share->setShareOwner($parent->getOwner()->getUID());
+ } else {
+ $share->setShareOwner($share->getNode()->getOwner()->getUID());
+ }
+
//Verify share type
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$this->userCreateChecks($share);
@@ -538,24 +567,6 @@ class Manager implements IManager {
}
}
- // Verify if there are any issues with the path
- $this->pathCreateChecks($share->getNode());
-
- /*
- * On creation of a share the owner is always the owner of the path
- * Except for mounted federated shares.
- */
- $storage = $share->getNode()->getStorage();
- if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
- $parent = $share->getNode()->getParent();
- while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
- $parent = $parent->getParent();
- }
- $share->setShareOwner($parent->getOwner()->getUID());
- } else {
- $share->setShareOwner($share->getNode()->getOwner()->getUID());
- }
-
// Cannot share with the owner
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
$share->getSharedWith() === $share->getShareOwner()) {
@@ -818,7 +829,7 @@ class Manager implements IManager {
* @param string $recipientId
*/
public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) {
- list($providerId, ) = $this->splitFullId($share->getId());
+ list($providerId, ) = $this->splitFullId($share->getFullId());
$provider = $this->factory->getProvider($providerId);
$provider->deleteFromSelf($share, $recipientId);
@@ -844,7 +855,7 @@ class Manager implements IManager {
}
}
- list($providerId, ) = $this->splitFullId($share->getId());
+ list($providerId, ) = $this->splitFullId($share->getFullId());
$provider = $this->factory->getProvider($providerId);
$provider->move($share, $recipientId);
diff --git a/lib/private/files/config/usermountcache.php b/lib/private/files/config/usermountcache.php
index 78b19972787..68436174025 100644
--- a/lib/private/files/config/usermountcache.php
+++ b/lib/private/files/config/usermountcache.php
@@ -82,7 +82,7 @@ class UserMountCache implements IUserMountCache {
$newMounts = array_map(function (IMountPoint $mount) use ($user) {
$storage = $mount->getStorage();
if ($storage->instanceOfStorage('\OC\Files\Storage\Shared')) {
- $rootId = (int)$storage->getShare()['file_source'];
+ $rootId = (int)$storage->getShare()->getNodeId();
} else {
$rootId = (int)$storage->getCache()->getId('');
}
diff --git a/lib/private/files/storage/wrapper/jail.php b/lib/private/files/storage/wrapper/jail.php
index e5f5ab90359..6c2a5199f2e 100644
--- a/lib/private/files/storage/wrapper/jail.php
+++ b/lib/private/files/storage/wrapper/jail.php
@@ -47,7 +47,7 @@ class Jail extends Wrapper {
$this->rootPath = $arguments['root'];
}
- protected function getSourcePath($path) {
+ public function getSourcePath($path) {
if ($path === '') {
return $this->rootPath;
} else {
@@ -417,6 +417,14 @@ class Jail extends Wrapper {
/**
* @param string $path
+ * @return array
+ */
+ public function getMetaData($path) {
+ return $this->storage->getMetaData($this->getSourcePath($path));
+ }
+
+ /**
+ * @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
@@ -442,4 +450,9 @@ class Jail extends Wrapper {
public function changeLock($path, $type, ILockingProvider $provider) {
$this->storage->changeLock($this->getSourcePath($path), $type, $provider);
}
+
+ public function resolvePath($path) {
+ $path = $this->getSourcePath($path);
+ return \OC\Files\Filesystem::resolvePath($path);
+ }
}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 70c50bb7b4b..e6aaed0fd15 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -628,7 +628,7 @@ class OC_Helper {
/** @var \OC\Files\Storage\Wrapper\Quota $storage */
$quota = $sourceStorage->getQuota();
}
- $free = $storage->free_space('');
+ $free = $sourceStorage->free_space('');
if ($free >= 0) {
$total = $free + $used;
} else {