Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/ACL/ACLManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCP\Files\IRootFolder;
use OCP\IUser;
use Psr\Log\LoggerInterface;
use RuntimeException;

class ACLManager {
private CappedMemoryCache $ruleCache;
Expand Down Expand Up @@ -93,10 +94,19 @@ private function getRelevantPaths(string $path): array {
$fromTrashbin = str_starts_with($path, '__groupfolders/trash/');
if ($fromTrashbin) {
/* Exploded path will look like ["__groupfolders", "trash", "1", "folderName.d2345678", "rest/of/the/path.txt"] */
[, , $groupFolderId, $rootTrashedItemName] = explode('/', $path, 5);
$parts = explode('/', $path, 5);
if (count($parts) < 4) {
// path is the root of the groupfolder trash
return [];
}
[, , $groupFolderId, $rootTrashedItemName] = $parts;
$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 @@ -105,6 +115,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);
$fromTrashbin = false;
if ($trashItemRow) {
Expand Down
9 changes: 7 additions & 2 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,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
Loading