Skip to content

Fix the CLI hanging on a locked OS keyring - #618

Merged
greenart7c3 merged 2 commits into
masterfrom
fix/cli-keyring-timeout
Nov 20, 2026
Merged

greenart7c3 merged 2 commits into
masterfrom
fix/cli-keyring-timeout

Conversation

@greenart7c3

Copy link
Copy Markdown
Owner

On a desktop whose GNOME login keyring is locked (any boot with autologin), every amber command that touches the saved connections waited on the keyring's unlock prompt forever, ignoring --timeout. A script or agent with nobody at the screen never returned.

Now every call into the OS credential store goes through withKeyringTimeout (SecretStore.kt): opening the keyring (Keyring.create() already unlocks the freedesktop collection, which is where it blocked), checking, reading, saving and deleting the key. The bound is the command's --timeout (120 s by default). On expiry the command exits with code 5 and says to unlock the keyring or set AMBER_CLI_KEY_STORE=file. It never switches to the key file on its own: a locked store still holds the key, and switching would lock existing connections out (or put a new store's key in a file for good).

Tested in the Ubuntu VM after a fresh boot (keyring locked): amber connect --timeout 8 used to hang (killed after 60 s); now it exits 5 after 10 s with the message. After unlocking, the key is saved to the keyring as before. --timeout help and cli/README.md mention the bound.

New KeyringTimeoutTest: an answer in time, a call that never answers (exit 5 in about 1 s), and errors passed through unchanged. All 44 CLI tests, detektAll and the pre-push test lint pass.

A locked GNOME login keyring answers only once the user unlocks it in a
prompt, so an unattended amber command waited forever, ignoring --timeout.
Every call into the OS credential store is now bounded by --timeout (120 s
by default) and fails with exit code 5 and a message on how to unlock it or
use a key file. It never switches to the key file on its own: a locked store
still holds the key.
Keyring.create() already unlocks the freedesktop collection, so a locked keyring blocked there, before any bounded call: tested in the Ubuntu VM, where connect still hung. Opening it now goes through the same --timeout bound.
@greenart7c3
greenart7c3 merged commit 33780e0 into master Nov 20, 2026
13 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.

1 participant