Skip to content

[stable33] fix(files_external/SMB): Use 'null' explicitly for no workgroup#62280

Open
backportbot[bot] wants to merge 1 commit into
stable33from
backport/61622/stable33
Open

[stable33] fix(files_external/SMB): Use 'null' explicitly for no workgroup#62280
backportbot[bot] wants to merge 1 commit into
stable33from
backport/61622/stable33

Conversation

@backportbot

@backportbot backportbot Bot commented Jul 17, 2026

Copy link
Copy Markdown

Backport of PR #61622

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 <chris@pcserenity.com>
@backportbot
backportbot Bot requested a review from a team as a code owner July 17, 2026 17:05
@backportbot
backportbot Bot requested review from Altahrim, CarlSchwan, nfebe, salmart-dev, sorbaugh and susnux and removed request for a team July 17, 2026 17:05
@backportbot backportbot Bot added this to the Nextcloud 33.0.8 milestone Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants