Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-10-27
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Design

`_unlock_keyring` checks `_keyring_is_locked()` after running `gnome-keyring-daemon --replace --unlock`. When locked is True, it formats `ERRORS.devcontainer.keyring_wrong_password` with `path=_login_keyring_file()`.

The message states that the keyring is still locked, names the path of the keyring file, and gives the shell command to move the file to a backup and run `devops devcontainer unlock-keyring`.

## Rejected alternatives

- **Automated file deletion or overwrite without backup:** Overwriting or deleting the existing keyring automatically destroys existing credentials without confirmation. If the user remembers the password later, the secrets would be lost. Rejected.
- **Add a `--reset` option to `unlock-keyring`:** Moving the file explicitly with `mv` is transparent, standard, and requires no additional CLI flags or options. Rejected.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Proposal

## Why

Issue #2340: After a devcontainer rebuild from a new image, `devops devcontainer unlock-keyring` rejects the keyring password when the entered password differs from the password used to create the persisted keyring file. The current error message ("Wrong password; the keyring is still locked.") provides no remedy or way forward.

## What Changes

- When an existing keyring rejects the password, `devops devcontainer unlock-keyring` prints an error message that names the keyring file path and provides the exact procedure to back up the file and reset the keyring.
- The error message text in `src/devops_cli/lang/en/errors.py` is updated to include the file path and reset instructions.
- A test in `tests/test_devcontainer.py` verifies that the error output contains the path and reset command.

## Capabilities

### New Capabilities

- `devcontainer-keyring-unlock`: requirements for reporting keyring unlock failure with actionable remediation steps.

### Modified Capabilities

None.

## Impact

- `src/devops_cli/commands/devcontainer.py`, `src/devops_cli/lang/en/errors.py`, `tests/test_devcontainer.py`.

## Feasibility

- Upstream `gnome-keyring` source code (`pkcs11/secret-store/gkm-secret-binary.c`, `egg/egg-symkey.c`) confirms that the binary keyring format (`GnomeKeyring\n\r\0\n`, AES-128-CBC, SHA-256 key derivation with salt and iterations, MD5 integrity check) has remained unchanged across versions (42 through 51.1).
- The rejection occurs because the user's home volume persists `~/.local/share/keyrings/login.keyring` across image rebuilds, and the password entered does not match the master password used to encrypt the file.
- Because AES-128 encryption protects the keyring, recovering data without the original password is not possible.
- Naming the path and the reset command (`mv <path> <path>.bak` and `devops devcontainer unlock-keyring`) gives the user a clear way forward.

## Existing Tool Considered

No outside tool applies. The change updates an error message string and formats it with the existing keyring file path in the `unlock-keyring` command.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Spec Delta

## Purpose
How `devops devcontainer unlock-keyring` handles password verification and provides actionable remediation when an existing keyring rejects the password.

## ADDED Requirements

### Requirement: Keyring wrong password error provides clear remediation
When `devops devcontainer unlock-keyring` runs against an existing keyring file and `gnome-keyring-daemon` fails to unlock it, the command SHALL exit with status 1. The output SHALL print an error message that states the keyring is locked, names the keyring file path, and specifies the command to move the file to a backup and rerun `devops devcontainer unlock-keyring`.

#### Scenario: Wrong password entered for existing keyring
- **WHEN** an existing keyring file exists at `~/.local/share/keyrings/login.keyring`
- **AND** the entered password does not unlock the keyring
- **THEN** the command exits 1
- **AND** the error output names the keyring file path
- **AND** the error output contains the instruction to move the file to a backup and run `devops devcontainer unlock-keyring`
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tasks

- [x] 1.1 Write failing test in `tests/test_devcontainer.py` asserting that a wrong password on an existing keyring prints the file path and reset instructions.
- [x] 1.2 Update `ERRORS.devcontainer.keyring_wrong_password` in `src/devops_cli/lang/en/errors.py` with the path placeholder and remediation instructions in ASD-STE100.
- [x] 1.3 Update `_unlock_keyring` in `src/devops_cli/commands/devcontainer.py` to format `ERRORS.devcontainer.keyring_wrong_password` with `_login_keyring_file()`.
- [x] 1.4 Run `devops ci fail-to-pass --base origin/main` to verify the check passes.
- [x] 1.5 Run `devops openspec check` and full checks `devops ci`.
16 changes: 16 additions & 0 deletions openspec/specs/devcontainer-keyring-unlock/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# devcontainer-keyring-unlock Specification

## Purpose
How `devops devcontainer unlock-keyring` handles password verification and provides actionable remediation when an existing keyring rejects the password.

## Requirements

### Requirement: Keyring wrong password error provides clear remediation
When `devops devcontainer unlock-keyring` runs against an existing keyring file and `gnome-keyring-daemon` fails to unlock it, the command SHALL exit with status 1. The output SHALL print an error message that states the keyring is locked, names the keyring file path, and specifies the command to move the file to a backup and rerun `devops devcontainer unlock-keyring`.

#### Scenario: Wrong password entered for existing keyring
- **WHEN** an existing keyring file exists at `~/.local/share/keyrings/login.keyring`
- **AND** the entered password does not unlock the keyring
- **THEN** the command exits 1
- **AND** the error output names the keyring file path
- **AND** the error output contains the instruction to move the file to a backup and run `devops devcontainer unlock-keyring`
2 changes: 1 addition & 1 deletion src/devops_cli/commands/devcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ def _unlock_keyring(*, timeout: int | None) -> bool:
print_error(ERRORS.devcontainer.keyring_not_created)
return False
if locked:
print_error(ERRORS.devcontainer.keyring_wrong_password)
print_error(ERRORS.devcontainer.keyring_wrong_password.format(path=_login_keyring_file()))
return False

pending.unlink(missing_ok=True)
Expand Down
5 changes: 4 additions & 1 deletion src/devops_cli/lang/en/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ class DevcontainerErrorMessages:
"Refusing an empty password: the keyring would store every secret in plain text."
)
keyring_password_mismatch: str = "Passwords do not match; the keyring was not created."
keyring_wrong_password: str = "Wrong password; the keyring is still locked."
keyring_wrong_password: str = (
"Wrong password; the keyring is still locked. To reset the keyring, "
"move {path} to a backup file and run 'devops devcontainer unlock-keyring'."
)
keyring_not_created: str = "The keyring could not be created or reached over D-Bus."


Expand Down
6 changes: 5 additions & 1 deletion tests/test_devcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,11 @@ def test_unlock_keyring_reports_a_wrong_password(
result = runner.invoke(app, ["unlock-keyring"])

assert result.exit_code == 1
assert "Wrong password" in result.output
assert "Wrong password; the keyring is still locked." in result.output
assert (
f"To reset the keyring, move {keyring_file} to a backup file and run 'devops devcontainer unlock-keyring'."
in result.output
)


def test_unlock_keyring_needs_gnome_keyring(
Expand Down
Loading