Repository navigation
Fix keyring backend selection to honor ZED_KEYRING_PASSWORD over SSH - #728
Open
josephschorr wants to merge 1 commit into
Open
josephschorr wants to merge 1 commit into
josephschorr wants to merge 1 commit into
Conversation
On Linux hosts with a reachable D-Bus session bus and GNOME Keyring installed, zed picks the secret-service keyring backend automatically. Over SSH, GNOME Keyring can't show its GUI unlock prompt, and the underlying go-libsecret dependency mishandles the resulting dismissed prompt, surfacing as `Object does not exist at path "/"` on `zed context set` and other keyring writes. The documented workaround, ZED_KEYRING_PASSWORD, was silently ignored because it is only read by the file backend, which never got a chance to run. This restricts the keyring to the file backend whenever ZED_KEYRING_PASSWORD is set and non-empty, since that's the only backend that honors it. A new ZED_KEYRING_BACKEND environment variable lets users explicitly select a backend by name (file, secret-service, kwallet, keychain, pass, keyctl), taking precedence over the password-implies-file-backend behavior; an unrecognized value returns a clear error listing the valid options. Reported by Aurora (Jeff Herald) - zed context commands over SSH on Linux with gnome-keyring.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Linux hosts with a reachable D-Bus session bus and GNOME Keyring installed,
zed context set(and other keyring writes) fails over SSH with:Root cause
zedopens99designs/keyringwithout restrictingAllowedBackends. On Linux the backend order is secret-service → kwallet → keyctl → pass → file. Secret-service gets picked whenever a session bus is reachable (which it is over a normal systemd SSH login, and godbus/dbus-launch can even start one). Over SSH, GNOME Keyring can't show its GUI unlock prompt;gcr-prompterfails with "cannot open display" and gnome-keyring returns a dismissed result. Thegsterjov/go-libsecretdependency (unmaintained since 2016) mishandles that dismissal and treats/as the collection, so the next call fails with the opaqueObject does not exist at path "/"error.The documented escape hatch,
ZED_KEYRING_PASSWORD, is only read by the file backend — but secret-service wins the backend race and fails later, so zed never falls through to the file backend and the env var does nothing.Fix
ZED_KEYRING_PASSWORDis set (non-empty), restrictkeyring.Config.AllowedBackendstoFileBackend, since that's the only backend that honors it.ZED_KEYRING_BACKENDenvironment variable to explicitly select a backend by name (file,secret-service,kwallet,keychain,pass,keyctl), taking precedence over the password-implies-file-backend behavior. An unrecognized value now returns a clear error listing the valid options instead of being silently ignored.ZED_KEYRING_BACKEND.internal/storage/secrets_test.gocovering: password-alone forces file backend, backend override, empty password is a no-op, and invalid backend errors.go build ./...andgo test ./internal/storage/...both pass.Files changed
internal/storage/secrets.gointernal/storage/secrets_test.goREADME.mdFixes the issue raised internally from Aurora's report (Slack thread, not urgent but blocks a core
zedworkflow for SSH-based teams).