Skip to content

Fix keyring backend selection to honor ZED_KEYRING_PASSWORD over SSH - #728

Open
josephschorr wants to merge 1 commit into
authzed:mainfrom
josephschorr:fix/keyring-backend-ssh
Open

josephschorr wants to merge 1 commit into
authzed:mainfrom
josephschorr:fix/keyring-backend-ssh

Conversation

@josephschorr

@josephschorr josephschorr commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

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:

ERR terminated with errors error="Object does not exist at path \"/\""

Root cause

zed opens 99designs/keyring without restricting AllowedBackends. 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-prompter fails with "cannot open display" and gnome-keyring returns a dismissed result. The gsterjov/go-libsecret dependency (unmaintained since 2016) mishandles that dismissal and treats / as the collection, so the next call fails with the opaque Object 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

  • When ZED_KEYRING_PASSWORD is set (non-empty), restrict keyring.Config.AllowedBackends to FileBackend, since that's the only backend that honors it.
  • Add a new ZED_KEYRING_BACKEND environment 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.
  • Updated README and inline doc comments to mention ZED_KEYRING_BACKEND.
  • Added table-driven unit tests in internal/storage/secrets_test.go covering: password-alone forces file backend, backend override, empty password is a no-op, and invalid backend errors.

go build ./... and go test ./internal/storage/... both pass.

Files changed

  • internal/storage/secrets.go
  • internal/storage/secrets_test.go
  • README.md

Fixes the issue raised internally from Aurora's report (Slack thread, not urgent but blocks a core zed workflow for SSH-based teams).

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-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/storage/secrets.go 94.44% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

2 participants