Skip to content

Commit

Permalink
fix: make early check if users filesystem have a mountpoint at /<user…
Browse files Browse the repository at this point in the history
…>/files/

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Feb 17, 2025
1 parent 892c473 commit 42cd771
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/private/Files/Utils/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,17 @@ public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECUR
foreach (['', 'files'] as $path) {
if (!$storage->isCreatable($path)) {
$fullPath = $storage->getSourcePath($path);
if (!$storage->is_dir($path) && $storage->getCache()->inCache($path)) {
if (isset($mounts[$mount->getMountPoint() . $path . '/'])) {
// /<user>/files is overwritten by a mountpoint, so this check is irrelevant
break;
} elseif (!$storage->is_dir($path) && $storage->getCache()->inCache($path)) {
throw new NotFoundException("User folder $fullPath exists in cache but not on disk");
} elseif ($storage->is_dir($path)) {
$ownerUid = fileowner($fullPath);
$owner = posix_getpwuid($ownerUid);
$owner = $owner['name'] ?? $ownerUid;
$permissions = decoct(fileperms($fullPath));
throw new ForbiddenException("User folder $fullPath is not writable, folders is owned by $owner and has mode $permissions");
} elseif (isset($mounts[$mount->getMountPoint() . $path . '/'])) {
// /<user>/files is overwritten by a mountpoint, so this check is irrelevant
break;
} else {
// if the root exists in neither the cache nor the storage the user isn't setup yet
break 2;
Expand Down

0 comments on commit 42cd771

Please sign in to comment.