From 9d16cbbfb188b8416e67ed8d4a4c1253e32d1294 Mon Sep 17 00:00:00 2001 From: Christian Heimlich Date: Fri, 26 Jun 2026 23:59:58 +0000 Subject: [PATCH] fix(files_external/SMB): Use 'null' explicitly for no workgroup Robin Appleman's SMB library is designed so that 'null' is to be used when no explicit workgroup is set: final class BasicAuth implements IAuth { /** @var string */ private $username; /** @var string|null */ private $workgroup; /** @var string */ private $password; //... However, it previously was loose with its checks and would still treat any falsy value (e.g. an empty string) as "not specified" when forming arguments for the various underlying utilities, such as `smbclient`. icewind/SMB@4a93467905 updated it's handling to be more strict and as such will now treat empty strings as distinct from null values for workgroups. An empty value for workgroup often doesn't make sense, unless the backend tool happens to convert it to "WORKGROUP". In the case of the `smbclient` utility, passing an empty string for the $workgroup paramters results in `-W ''` being used which is invalid syntax and so the invocation fails resulting in the user seeing an `[Icewind\SMB\Exception\ConnectionRefusedException]` error. Therefore, it is important to always pass 'null' to this constructor for $workgroup when there isn't one. Most paths in the 'files_external' app already handle this correctly, but this now altered path originally just took the raw value from the app backend and passed it as-is. Assuming the user left the "Domain" box empty in the frontend, this would be an empty string. Now the the SMB library's interface is correctly honored in that case. It's arguable that the SMB library should simply be updated to formally accept '' as a valid input meaning "no workgroup", restoring the old behavior in a canonical fashion, as there is almost no situation where one would want to pass an empty string and have it mean anything else; but regardless, there is no harm in being more explicit on the nextcloud/server side as well. Fixes #58445. Signed-off-by: Christian Heimlich --- apps/files_external/lib/Lib/Backend/SMB.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_external/lib/Lib/Backend/SMB.php b/apps/files_external/lib/Lib/Backend/SMB.php index 79c5e4dd55a8f..9e2e2dbf35741 100644 --- a/apps/files_external/lib/Lib/Backend/SMB.php +++ b/apps/files_external/lib/Lib/Backend/SMB.php @@ -70,7 +70,7 @@ public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = $smbAuth = new BasicAuth( $storage->getBackendOption('user'), - $storage->getBackendOption('domain'), + $storage->getBackendOption('domain') ?: null, $storage->getBackendOption('password') ); } else {