Properly handle SMB ACL blocking scanning a directory
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 <jus@bitgrid.net>
This commit is contained in:
parent
59b43e0699
commit
6f6f45b77b
|
@ -40,6 +40,7 @@ use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
|
||||||
use OCP\Files\FileInfo;
|
use OCP\Files\FileInfo;
|
||||||
use OCP\Files\ForbiddenException;
|
use OCP\Files\ForbiddenException;
|
||||||
use OCP\Files\InvalidPathException;
|
use OCP\Files\InvalidPathException;
|
||||||
|
use OCP\Files\NotPermittedException;
|
||||||
use OCP\Files\StorageNotAvailableException;
|
use OCP\Files\StorageNotAvailableException;
|
||||||
use OCP\Lock\ILockingProvider;
|
use OCP\Lock\ILockingProvider;
|
||||||
use OCP\Lock\LockedException;
|
use OCP\Lock\LockedException;
|
||||||
|
@ -340,6 +341,8 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
|
||||||
return $this->quotaInfo;
|
return $this->quotaInfo;
|
||||||
} catch (\OCP\Files\StorageNotAvailableException $e) {
|
} catch (\OCP\Files\StorageNotAvailableException $e) {
|
||||||
return [0, 0];
|
return [0, 0];
|
||||||
|
} catch (NotPermittedException $e) {
|
||||||
|
return [0, 0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ use OCP\Constants;
|
||||||
use OCP\Files\EntityTooLargeException;
|
use OCP\Files\EntityTooLargeException;
|
||||||
use OCP\Files\Notify\IChange;
|
use OCP\Files\Notify\IChange;
|
||||||
use OCP\Files\Notify\IRenameChange;
|
use OCP\Files\Notify\IRenameChange;
|
||||||
|
use OCP\Files\NotPermittedException;
|
||||||
use OCP\Files\Storage\INotifyStorage;
|
use OCP\Files\Storage\INotifyStorage;
|
||||||
use OCP\Files\StorageAuthException;
|
use OCP\Files\StorageAuthException;
|
||||||
use OCP\Files\StorageNotAvailableException;
|
use OCP\Files\StorageNotAvailableException;
|
||||||
|
@ -235,7 +236,11 @@ class SMB extends Common implements INotifyStorage {
|
||||||
protected function getFolderContents($path): iterable {
|
protected function getFolderContents($path): iterable {
|
||||||
try {
|
try {
|
||||||
$path = ltrim($this->buildPath($path), '/');
|
$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) {
|
foreach ($files as $file) {
|
||||||
$this->statCache[$path . '/' . $file->getName()] = $file;
|
$this->statCache[$path . '/' . $file->getName()] = $file;
|
||||||
}
|
}
|
||||||
|
@ -595,7 +600,7 @@ class SMB extends Common implements INotifyStorage {
|
||||||
$files = $this->getFolderContents($path);
|
$files = $this->getFolderContents($path);
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
return false;
|
return false;
|
||||||
} catch (ForbiddenException $e) {
|
} catch (NotPermittedException $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$names = array_map(function ($info) {
|
$names = array_map(function ($info) {
|
||||||
|
|
Loading…
Reference in New Issue