Skip to content

smb: save the user name in the config even if it matches the current user - fixes #9356 - #9945

Merged
ncw merged 1 commit into
rclone:masterfrom
hsdfat:smb-default-user-9356
Sep 21, 2026
Merged

ncw merged 1 commit into
rclone:masterfrom
hsdfat:smb-default-user-9356

Conversation

@hsdfat

@hsdfat hsdfat commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What does this change do?

This implements the suggestion in the issue: the default for --smb-user becomes blank, and a blank user is
resolved to the current user name when the remote is used.

The default used to be the name of the user running rclone config. Since rclone doesn't write default values to
the config file, typing your own user name at the prompt left it out of the config, and the remote then logged in
as whoever ran it later - root under a systemd mount. With a blank default, a name typed at the prompt is always
saved, and pressing Enter leaves it blank as before.

Existing configs behave the same: a remote with no user still logs in as the current user, and an explicit user
is unchanged. The ftp backend already resolves a blank user this way.

A blank user = line in the config file was already ignored, so that falls back to the current user as before.
The one difference is an explicitly empty user from somewhere else - --smb-user "", RCLONE_SMB_USER= or
:smb,user='': - which used to send an empty user name and now sends the current user's. The SMB docs already say
anonymous login isn't supported and to use guest instead.

sftp has the same kind of default and could get the same change, but its user handling interacts with the ssh
option, so I've left it for a separate PR if you'd like one.

Testing

  • TestNewFsUser: a blank or missing user resolves to the current user, and an explicit one is kept.
  • TestUserDefault: the option default is blank.

Both fail on master. I also ran the interactive rclone config from the issue with the new binary: typing the
current user name now writes user = <name>, and pressing Enter leaves it out.

go build ./..., make quicktest and golangci-lint run ./backend/smb/ pass, and
go run ./fstest/test_all -backends smb passes against the docker test servers.

Linked issue

Fixes #9356

Checklist

  • This change is trivial OR it has been discussed and agreed in the linked issue.
  • I have read the contribution guidelines.
  • (If I used AI tools to help write this code) I have read and understood the AI-assisted contributions guidance, and I have tested and take ownership of this change myself.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate. (The option help says a blank user means the current user.)
  • All commit messages are in house style.
  • (Backend changes only) test_all passes for this backend and if submitting a new backend can provide a test account for the integration tester - see CONTRIBUTING.md.
  • This Pull Request is ready for review.

@hsdfat
hsdfat requested a review from ncw as a code owner September 18, 2026 21:03

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect - thank you :-)

@ncw

ncw commented Sep 19, 2026

Copy link
Copy Markdown
Member

Can you fix up the conflict, then I'll merge - thanks!

@hsdfat
hsdfat force-pushed the smb-default-user-9356 branch from aeacb6b to 4c4d4e8 Compare September 19, 2026 14:57
…user - fixes rclone#9356

The default for --smb-user was the name of the user running rclone
config, and rclone does not write defaults to the config file, so
entering your own user name left it out. A remote made that way then
logged in as whoever ran it later, e.g. root under systemd.

Make the default blank and look up the current user when the remote is
used, as the ftp backend does. Existing configs work as before.
@hsdfat
hsdfat force-pushed the smb-default-user-9356 branch from 270621f to 972d600 Compare September 21, 2026 06:49
@ncw
ncw merged commit 3c51b96 into rclone:master Sep 21, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The configuration editor drops SMB usernames when they are equal to the username of the user, making usage of the same in systemd more difficult

2 participants