fix(software-install): relax nlink on target rollback restore - #4
Merged
Conversation
install_or_update_software creates the target's software/ and bin/ subdirectories between capturing the target identity snapshot and the rollback restore. On any failure after those mkdir calls, the else-branch rollback invoked restore_directory_metadata with the default require_nlink=True, and the now-higher nlink failed the comparison: target identity changed This reproduced even on a freshly-managed target because software-install against an existing target takes the else branch (created_target is False) after legitimately raising target.nlink. dev/ino/uid/gid still guard the real anti-TOCTOU identity; only nlink is relaxed, mirroring the five other pi call sites that already pass require_nlink=False where subdirectories are expected to be created/removed mid-operation.
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.
Problem
software-installfailed with:even on a freshly-managed target created by the manager's own
install.Root cause
install_or_update_softwarecreates the target'ssoftware/andbin/subdirectories (lines 5018, 5020) between capturing the target identity snapshot (line 4945) and the rollback restore. On any failure after thosemkdircalls, theelse-branch rollback (line 5182) invokedrestore_directory_metadatawith the defaultrequire_nlink=True. The now-highernlink(two new subdirectories) failed the comparison.This reproduced on a freshly-managed target because
software-installagainst an existing target takes theelsebranch (created_targetisFalse) after legitimately raisingtarget.nlink.Fix
Pass
require_nlink=Falseat the call site (line 5182).dev/ino/uid/gidstill guard the real anti-TOCTOU identity; onlynlinkis relaxed. This mirrors the five other pi call sites that already passrequire_nlink=Falsewhere subdirectories are expected to be created/removed mid-operation (lines 1038, 1369, 1474, 1571, 2692, 2790), and matches what every sibling harness (cline, qwen, codex) does by omittingnlinkfrom the comparison entirely.