Repository navigation
fix(agent): stop identities when a directory changes owner - #2178
Benoît Cortier (CBenoit) wants to merge 3 commits into
Conversation
Evidence and notesLines changed (
How it works: the poll calls the new Tests at
The owner test (
Decisions and side effects worth a look:
Note LLM-assisted content (no human feedback). |
UNTESTED propertiesNo new
Note LLM-assisted content (no human feedback). |
…es owner mid-run An identity directory owned by another account must stop all identity processing until it is fixed, because the account that created it can keep a handle that still changes it after a permission reset. Start-up already refused such a directory, but the pending-directory poll only checked authority directories and identity.json, so a directory that changed owner while the agent ran only made each state change fail while every runner and agent channel stream kept going. The poll now runs what every state change runs before it writes: it takes and releases the state lock, whose provisioning refuses an identity directory with an owner the agent does not accept, then checks the stored identities. Such a refusal stops every identity and its streams, as an untrusted authority directory does, and start-up retries until the directory is fixed, so processing resumes without a restart. Other errors still only make the poll retry. Issue: DGW-478 Security: yes Co-Authored-By: Claude Opus 5.5 <[email protected]>
Issue: DGW-478 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The pending-directory poll checks the identity state on every interval with nothing to write. Taking the state lock for that check made it wait on any outside handle: on Windows the lock is an unshared handle on <data-dir>\identity, so Explorer, a shell whose working directory is that folder, or a backup or antivirus scan made the poll sleep for 30 s on a runtime worker each cycle, and on Unix flock waits without bound. The check now provisions the identity directories and checks the stored identities without locking. Provisioning is what the lock runs first, so a directory owned by another account is refused exactly as before, while a sharing violation is an ordinary error the poll retries. The test that gives an identity directory to another account now also covers the authority directories, and gives the directory back by SID, because icacls cannot map the name of an Entra ID or Microsoft account. Issue: DGW-478 Security: yes Co-Authored-By: Claude Opus 5.5 <[email protected]>
e71f436 to
dc8c68e
Compare
An identity directory owned by another account stops all Agent Identity processing until it is fixed, because the account that created it can keep a handle that still changes it after a reset. Start-up already refused such a directory, but while the agent ran, a directory that changed owner only made each state change fail: runners kept renewing and checking in, and their agent channel streams stayed open.
The pending-directory poll now provisions the identity directories, as every state change does before it writes, then checks the stored identities, without taking the state lock. A directory whose owner the agent doesn't accept stops every runner and its streams, as an untrusted authority directory or
identity.jsonalready does, and the agent resumes without a restart once the owner is fixed. A directory the agent owns with wrong permissions is still repaired and stops nothing; the poll now resets such permissions on each interval, which every state change already did.Issue: DGW-478
Security: yes
Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code