summaryrefslogtreecommitdiffstats
path: root/lib/private/share/share.php
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2015-12-09 12:00:00 +0100
committerBjörn Schießle <bjoern@schiessle.org>2015-12-14 17:16:14 +0100
commitefc030aa25b047a7c9f720cf781f26cbe1d274e0 (patch)
treec5fb0f9eb12ec53a9f9e20a3a6ede8841e64b25c /lib/private/share/share.php
parentdb41c4f4b5f27757838ba17c03f6f263b91af527 (diff)
downloadnextcloud-server-efc030aa25b047a7c9f720cf781f26cbe1d274e0.tar.gz
nextcloud-server-efc030aa25b047a7c9f720cf781f26cbe1d274e0.zip
don't allow to create a federated share if source and target server are the same
Diffstat (limited to 'lib/private/share/share.php')
-rw-r--r--lib/private/share/share.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 3edffba8a3f..fff437b3ff7 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -849,11 +849,20 @@ class Share extends Constants {
throw new \Exception($message_t);
}
+ // don't allow federated shares if source and target server are the same
+ list($user, $remote) = Helper::splitUserRemote($shareWith);
+ $currentServer = self::removeProtocolFromUrl(\OC::$server->getURLGenerator()->getAbsoluteURL('/'));
+ $currentUser = \OC::$server->getUserSession()->getUser()->getUID();
+ if (Helper::isSameUserOnSameServer($user, $remote, $currentUser, $currentServer)) {
+ $message = 'Not allowed to create a federated share with the same user.';
+ $message_t = $l->t('Not allowed to create a federated share with the same user');
+ \OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG);
+ throw new \Exception($message_t);
+ }
$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
\OCP\Security\ISecureRandom::CHAR_DIGITS);
- list($user, $remote) = Helper::splitUserRemote($shareWith);
$shareWith = $user . '@' . $remote;
$shareId = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, $token, $itemSourceName);
@@ -2510,7 +2519,7 @@ class Share extends Constants {
* @param string $url
* @return string
*/
- private static function removeProtocolFromUrl($url) {
+ public static function removeProtocolFromUrl($url) {
if (strpos($url, 'https://') === 0) {
return substr($url, strlen('https://'));
} else if (strpos($url, 'http://') === 0) {