Merge pull request #25383 from nextcloud/bugfix/24893

Properly handle SMB ACL blocking scanning a directory
This commit is contained in:
Roeland Jago Douma 2021-01-29 15:52:14 +01:00 committed by GitHub
commit 98c8cd5089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -41,6 +41,7 @@ use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
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;
@ -343,6 +344,8 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
return [0, 0];
} catch (\OCP\Files\StorageNotAvailableException $e) {
return [0, 0];
} catch (NotPermittedException $e) {
return [0, 0];
}
}

View File

@ -61,6 +61,7 @@ use OCP\Constants;
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;
@ -235,7 +236,11 @@ class SMB extends Common implements INotifyStorage {
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;
}
@ -595,7 +600,7 @@ class SMB extends Common implements INotifyStorage {
$files = $this->getFolderContents($path);
} catch (NotFoundException $e) {
return false;
} catch (ForbiddenException $e) {
} catch (NotPermittedException $e) {
return false;
}
$names = array_map(function ($info) {