Skip to content

Commit 088935d

Browse files
icewind1991backportbot[bot]
authored andcommitted
fix: make smb auth failure on forbidden exception more reliable
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 24b7f24 commit 088935d

File tree

1 file changed

+8
-2
lines changed
  • apps/files_external/lib/Lib/Storage

1 file changed

+8
-2
lines changed

apps/files_external/lib/Lib/Storage/SMB.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,15 @@ protected function getFileInfo(string $path): IFileInfo {
178178
throw new \OCP\Files\NotFoundException($e->getMessage(), 0, $e);
179179
} catch (ForbiddenException $e) {
180180
// with php-smbclient, this exception is thrown when the provided password is invalid.
181-
// Possible is also ForbiddenException with a different error code, so we check it.
182-
if ($e->getCode() === 1) {
181+
// we check if we can stat the root, which should only fail in authentication failures
182+
if ($path === '') {
183183
$this->throwUnavailable($e);
184+
} else {
185+
try {
186+
$this->share->stat('');
187+
} catch (\Exception $e) {
188+
$this->throwUnavailable($e);
189+
}
184190
}
185191
throw new \OCP\Files\ForbiddenException($e->getMessage(), false, $e);
186192
}

0 commit comments

Comments
 (0)