Repository navigation
Fix the CLI hanging on a locked OS keyring - #618
Merged
Merged
Conversation
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.
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.
On a desktop whose GNOME login keyring is locked (any boot with autologin), every
ambercommand 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 setAMBER_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 8used 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.--timeouthelp andcli/README.mdmention 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,detektAlland the pre-pushtest lintpass.