Skip to content

Commit

Permalink
Match against share target and node path
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Oct 28, 2021
1 parent 62f507e commit a6c557c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\HintException;
use OCP\IConfig;
use OCP\IGroupManager;
Expand Down Expand Up @@ -292,10 +293,18 @@ protected function generalCreateChecks(IShare $share) {
$permissions = 0;

if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) {
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) use ($share) {
try {
$targetNode = $share->getTarget() ? $userFolder->get($share->getTarget()) : null;
} catch (NotFoundException $e) {
$targetNode = null;
}
$userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) use ($share, $targetNode) {
// We need to filter since there might be other mountpoints that contain the file
// e.g. if the user has access to the same external storage that the file is originating from
return $mount->getStorage()->instanceOfStorage(ISharedStorage::class) && $mount->getPath() === $share->getNode()->getPath();
return $mount->getStorage()->instanceOfStorage(ISharedStorage::class) && (
$targetNode ? $targetNode->getPath() === $mount->getPath() :
$mount->getPath() === $share->getNode()->getPath()
);
});
$userMount = array_shift($userMounts);
if ($userMount === null) {
Expand Down

0 comments on commit a6c557c

Please sign in to comment.