From 43727cb72c5b7d5ae93d539c3988efa120f6efe2 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 12 Jan 2026 13:48:09 +0100 Subject: [PATCH 1/2] fix: handle InvalidArumentException as availability failure in smb->getFileInfo Signed-off-by: Robin Appelman --- apps/files_external/lib/Lib/Storage/SMB.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 3d0a7063df78f..c019c20c5e064 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -172,6 +172,8 @@ protected function getFileInfo(string $path): IFileInfo { } } catch (ConnectException $e) { $this->throwUnavailable($e); + } catch (InvalidArgumentException $e) { + $this->throwUnavailable($e); } catch (NotFoundException $e) { throw new \OCP\Files\NotFoundException($e->getMessage(), 0, $e); } catch (ForbiddenException $e) { From 4dcd4223de93eb1ef259a5b943fa7ac28e61857d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 12 Jan 2026 15:23:24 +0100 Subject: [PATCH 2/2] fix: make smb auth failure on forbidden exception more reliable Signed-off-by: Robin Appelman --- apps/files_external/lib/Lib/Storage/SMB.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index c019c20c5e064..679e3ad791c4e 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -178,9 +178,15 @@ protected function getFileInfo(string $path): IFileInfo { throw new \OCP\Files\NotFoundException($e->getMessage(), 0, $e); } catch (ForbiddenException $e) { // with php-smbclient, this exception is thrown when the provided password is invalid. - // Possible is also ForbiddenException with a different error code, so we check it. - if ($e->getCode() === 1) { + // we check if we can stat the root, which should only fail in authentication failures + if ($path === '') { $this->throwUnavailable($e); + } else { + try { + $this->share->stat(''); + } catch (\Exception $e) { + $this->throwUnavailable($e); + } } throw new \OCP\Files\ForbiddenException($e->getMessage(), false, $e); }