Repository navigation
fix(cli): refuse a non-regular entry in the --from source tree - #1255
Conversation
`_files` classified the `--from` tree with `os.path.islink` alone, so a FIFO where the artifact expects a file was returned as a planned file and `_same` opened it -- blocking until a peer appeared, forever when none did. A socket or a device failed unread. The funnel that names a blocked leaf runs later and on the `--to` side, so it could not catch this. With `refuse_symlinks` the walk now also refuses any non-regular entry, naming the kind through `filetree._entry_kind` from one `lstat` and no read; the copy loop re-checks so a tree that changes under us cannot open one either. The `--to` side keeps its behaviour: a stray entry there is left alone, as a stray link already was. Fixes #1246
|
Pre-report for one body edit and one commit on this draft. The socket row's fixture now builds its trees under a short |
The new socket row bound src/references/rules.md, so a long TMPDIR pushed the bind past sun_path's 108 bytes and the row failed with AF_UNIX path too long instead of exercising the refusal. Build that row's trees under a short /tmp root when the fixture path is long, allow that root for the run, and remove it in finally (#1246).
|
Pre-report for one body edit and one commit on this draft, after CI at The change is only the file's own bounds and the comments that state them: |
CEILING=20 and the 12 s faulthandler dump sat inside a single cold import plus fixture build, so a refusal row could die as a false rc=124 on a loaded box. Raise the kill to 60 s and the dump to 45 s, keeping the dump inside the ceiling so a real hang still yields a stack before the kill. Bounds and their comments only; assertions unchanged.
|
State change in this turn: Live head
The body's |
|
Review request at head What to review: Evidence at the base with only that test file added: All ten checks on |
|
Body edit, no push: the |
|
Review (Birfy) Tip SHA: 90605bf
|
Fixes #1246
What changed
apply --fromno longer plans a non-regular entry in the source tree.Before:
_filesfiltered the--fromwalk withos.path.islinkonly, so a FIFO where the artifact expects a file came back as a planned file and_sameopened it — blocking until a peer appeared, forever when none did; a socket or a device failed unread. The blocked-leaf funnel (_check_apply_paths) runs later and on the--toside, so it could not catch this one.After: with
refuse_symlinksthe walk also refuses any non-regular entry, decided by onelstatand no read, naming the kind throughfiletree._entry_kind:Exit code 2,
ok: false, nothing written and no backup slot taken. The copy loop re-checks the mode as well, so a tree that changes under us cannot open one either. The--toside is unchanged: a stray entry there is left alone, exactly as a stray link already was.No UI surface.
Verification at the tip
Tip SHA: 9dda901
Ran:
pytest -q -o addopts="" tests/test_apply_from_non_regular.py→ 4 passed, 1 skipped (the device row skips itself wheremknodis not permitted).22ea7528with only this test file added →3 failed, 1 passed, 1 skipped; the blocking row:apply --from with a FIFO source blocked: `timeout 20` killed the child (rc=124)., child stack endingagentdescent/cli.py", line 3874 in _same.pytest -q -o addopts=""over the 14 apply-related files (test_apply*,test_cli_apply*,test_skill_library_apply_install.py) → 90 passed, 1 skipped.python3 -m tools.changelog_fragments --root . check→ 33 changelog fragment(s) OK.Not run:
pytest -q: this box has nomarkdownpackage, sotests/test_docs_links.pyfails at collection (environment, not the diff). Every apply-related file was run as listed above.mkdocs build --strict: nodocs/ormkdocs.ymlchange.Correction
The socket row's fixture now builds its trees under a short
/tmproot whensun_pathwould overflow, and the red block above was retaken with that fixture in place:3 failed, 1 passed, 1 skippedon the product assertions (the socket row fails asassert 0 == 2, planned as written), not onOSError: AF_UNIX path too long.The refusal rows now run under
timeout 60with the stack dump at 45 s, so a cold start cannot turn a refusal into a falserc=124; the red block was retaken under those bounds at base22ea7528(3 failed, 1 passed, 1 skipped, FIFO rows killed at 60 s, socket rowassert 0 == 2).Reviewed head (appended; nothing above changes):
90605bf7d4c2dbc7503363e588cccd1de12960df, a base-only merge of28ded70donto9dda901e; review request7129680903named that head. TheTip SHA:line above stays as the sha the gates actually ran at.