Skip to content

Track SSH agent key ownership by the root group uuid - #13730

Open
underclockeddev wants to merge 1 commit into
keepassxreboot:developfrom
underclockeddev:fix/ssh-agent-root-group-uuid
Open

underclockeddev wants to merge 1 commit into
keepassxreboot:developfrom
underclockeddev:fix/ssh-agent-root-group-uuid

Conversation

@underclockeddev

Copy link
Copy Markdown

Fixes #13704. Supersedes #13705, per the discussion there.

SSHAgent recorded which database added each key by Database::uuid(), which is generated for every Database object and never stored in the file. Anything that builds a new Database object for the same file orphaned the keys: locking no longer removed them, and unlocking was refused as an ownership conflict. This change keys ownership on the root group uuid instead, which is stored in the file, as suggested in #13704.

Two paths that build a new object are fixed by this:

  • a reload from disk (reloadDatabaseFile), for example when a sync tool delivers an edit made on another machine. This includes the hardware-key case: the reload first fails with the key unplugged, then completes once the key is back.
  • an unlock dialog (for example one opened by a Secret Service request) that is completed after the main window has already unlocked the same database. unlockDatabase() then replaces the database with a second object.

Behaviour change: two copies of the same file open at once now share ownership of their keys instead of refusing each other. Either can add them, and locking either removes them. testTwoOpenCopiesShareKeys covers this.

The investigation, patch and tests were written with Claude Code (Claude Opus 5.5) and reviewed by me before submitting.

Screenshots

N/A

Testing strategy

Type of change

  • ✅ Bug fix (non-breaking change that fixes an issue)

SSHAgent recorded which database added each key by Database::uuid(). That
uuid is generated for every Database object and is not stored in the file,
so a reload from disk (which builds a new Database object) orphaned the
keys: locking no longer removed them, and unlocking was refused as an
ownership conflict. Use the root group uuid instead, which is stored in the
file and survives a reload.

Two open copies of the same file now share ownership of their keys instead
of refusing each other: either one can add them, and locking either removes
them.

Fixes keepassxreboot#13704

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@droidmonkey

Copy link
Copy Markdown
Member

Beautiful

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.

SSH agent: after the database file is reloaded from disk, lock no longer removes keys and unlock no longer adds them

2 participants