Skip to content

Commit

Permalink
fix: created a patch from 3258 and 3592 PRs to fix acl issues while l…
Browse files Browse the repository at this point in the history
…isting group folders

Signed-off-by: yemkareems <[email protected]>
  • Loading branch information
yemkareems committed Feb 11, 2025
1 parent c475f81 commit 780f8e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/ACL/ACLManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCP\Constants;
use OCP\Files\IRootFolder;
use OCP\IUser;
use RuntimeException;

class ACLManager {
private CappedMemoryCache $ruleCache;
Expand Down Expand Up @@ -108,6 +109,10 @@ private function getRelevantPaths(string $path): array {
$groupFolderId = (int)$groupFolderId;
/* Remove the date part */
$separatorPos = strrpos($rootTrashedItemName, '.d');
if ($separatorPos === false) {
throw new RuntimeException('Invalid trash item name ' . $rootTrashedItemName);
}

$rootTrashedItemDate = (int)substr($rootTrashedItemName, $separatorPos + 2);
$rootTrashedItemName = substr($rootTrashedItemName, 0, $separatorPos);
}
Expand All @@ -116,6 +121,7 @@ private function getRelevantPaths(string $path): array {
$path = dirname($path);
if ($fromTrashbin && ($path === '__groupfolders/trash')) {
/* We are in trash and hit the root folder, continue looking for ACLs on parent folders in original location */
/** @psalm-suppress PossiblyUndefinedVariable Variables are defined above */
$trashItemRow = $this->trashManager->getTrashItemByFileName($groupFolderId, $rootTrashedItemName, $rootTrashedItemDate);
$path = dirname('__groupfolders/' . $groupFolderId . '/' . $trashItemRow['original_location']);
$fromTrashbin = false;
Expand Down
9 changes: 7 additions & 2 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,13 @@ private function userHasAccessToPath(
string $path,
int $permission = Constants::PERMISSION_READ
): bool {
$activePermissions = $this->aclManagerFactory->getACLManager($user)
->getACLPermissionsForPath($path);
try {
$activePermissions = $this->aclManagerFactory->getACLManager($user)
->getACLPermissionsForPath($path);
} catch (\Exception $e) {
$this->logger->warning("Failed to get permissions for {$path}", ['exception' => $e]);
return false;
}
return (bool)($activePermissions & $permission);
}

Expand Down

0 comments on commit 780f8e0

Please sign in to comment.