Skip to content

Commit

Permalink
Properly handle SMB ACL blocking scanning a directory
Browse files Browse the repository at this point in the history
This makes sure that a possible ForbiddenException is properly passed
through the storage as a ForbiddenException and can be catched when
trying to fetch the quota info of a parent folder

Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jan 29, 2021
1 parent 6a3321c commit e9ae943
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OCP\Files\FileInfo;
use OCP\Files\ForbiddenException;
use OCP\Files\InvalidPathException;
use OCP\Files\NotPermittedException;
use OCP\Files\StorageNotAvailableException;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
Expand Down Expand Up @@ -343,6 +344,8 @@ public function getQuotaInfo() {
return [0, 0];
} catch (\OCP\Files\StorageNotAvailableException $e) {
return [0, 0];
} catch (NotPermittedException $e) {
return [0, 0];
}
}

Expand Down
9 changes: 7 additions & 2 deletions apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
use OCP\Files\EntityTooLargeException;
use OCP\Files\Notify\IChange;
use OCP\Files\Notify\IRenameChange;
use OCP\Files\NotPermittedException;
use OCP\Files\Storage\INotifyStorage;
use OCP\Files\StorageAuthException;
use OCP\Files\StorageNotAvailableException;
Expand Down Expand Up @@ -235,7 +236,11 @@ private function getACL(IFileInfo $file): ?ACL {
protected function getFolderContents($path): iterable {
try {
$path = ltrim($this->buildPath($path), '/');
$files = $this->share->dir($path);
try {
$files = $this->share->dir($path);
} catch (ForbiddenException $e) {
throw new NotPermittedException();
}
foreach ($files as $file) {
$this->statCache[$path . '/' . $file->getName()] = $file;
}
Expand Down Expand Up @@ -595,7 +600,7 @@ public function opendir($path) {
$files = $this->getFolderContents($path);
} catch (NotFoundException $e) {
return false;
} catch (ForbiddenException $e) {
} catch (NotPermittedException $e) {
return false;
}
$names = array_map(function ($info) {
Expand Down

0 comments on commit e9ae943

Please sign in to comment.