Skip to content

Allow changing or regenerating the SMB share password - #2165

Open
TomKalina wants to merge 2 commits into
getumbrel:masterfrom
TomKalina:feat/share-password-management
Open

Allow changing or regenerating the SMB share password#2165
TomKalina wants to merge 2 commits into
getumbrel:masterfrom
TomKalina:feat/share-password-management

Conversation

@TomKalina

Copy link
Copy Markdown

Summary

Adds the ability to change or regenerate the Files share (SMB) password from Settings → File Sharing. Previously the password was a random token that could only be viewed — there was no way to rotate it or replace it with a memorable value.

Refs #2164.

Changes

Backend (umbreld)

  • samba.ts: new setSharePassword(password) and regenerateSharePassword() methods. Validate length (8–127), reject newlines, persist to the existing secrets/share-password file, and re-apply via smbpasswd.
  • routes.ts: two new tRPC mutations:
    • files.setSharePassword({password})
    • files.regenerateSharePassword()
  • samba.integration.test.ts: tests for auth, length validation, persistence, and regeneration.

Frontend (ui)

  • share-password-dialog/index.tsx: new AlertDialog with two modes — custom (input + Save) and regenerate (confirm + Regenerate).
  • file-sharing.tsx: two new buttons under the connection instructions, opening the dialog in the right mode.
  • use-shares.ts: wraps the new mutations and invalidates the cached sharePassword query on success.
  • en.json: new strings for buttons, dialog titles, descriptions, error messages, and toasts.

Test plan

Screen: Settings → File Sharing
How to get there: Umbrel UI → click your avatar → Settings → File Sharing. Make sure at least one folder is shared so the connection instructions render.
What to check:

  • "Change" button opens the custom-password dialog. Saving a value < 8 chars shows an inline error and disables Save.
  • Saving a valid password ≥ 8 chars closes the dialog, shows a success toast, and the displayed password under the platform instructions updates to the new value.
  • "Regenerate" button opens the confirm dialog. Confirming closes the dialog, shows a success toast, and the displayed password updates to a new random 32-char hex token.
  • Connecting from macOS Finder / Windows Explorer with the new password succeeds; the old password is rejected.
  • Backend integration tests pass: cd packages/umbreld && pnpm test samba.integration

Notes

  • Length range matches smbpasswd's interactive limit (127 chars) with a sane 8-char minimum.
  • Newlines are rejected because they would break the smbpasswd stdin protocol.
  • No data migration needed — existing installs keep their auto-generated token until the user rotates it.

The Files share password was previously a random token that could only
be viewed in Settings → File Sharing. There was no way for users to
rotate it or set a memorable value to share with other devices.

This adds two new tRPC mutations and matching UI in the file-sharing
settings:
  - files.setSharePassword(password): set a custom password (8-127 chars)
  - files.regenerateSharePassword(): replace with a new random token

Both apply the change to Samba via smbpasswd and invalidate the cached
password query so the UI reflects the new value immediately.

Closes getumbrel#2164
@TomKalina
TomKalina marked this pull request as ready for review July 6, 2026 15:18
setSharePassword/regenerateSharePassword wrote the new password to the
secrets file before calling applySharePassword(). If smbpasswd failed,
the file would hold a password Samba never actually accepted, silently
desyncing the stored value from the real one. Apply first, persist only
on success.

Also map the password-too-short/password-too-long/invalid-password
error codes in getFilesErrorMessage(), matching the existing convention
for every other backend error code (was falling through to the raw
bracketed code in the toast).
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.

1 participant