Repository navigation
ssh-agent-install no longer replaces an rc with less than it held - #137
Open
closer-claudio wants to merge 1 commit into
Open
closer-claudio wants to merge 1 commit into
closer-claudio wants to merge 1 commit into
Conversation
strip_lines wrote its copy of the rc to <rc>.tmp, behind `|| true`, then wrote that copy over the rc. Two losses came of it. `|| true` was there for grep's exit 1 (no line left to keep) and passed over every other failure as well: in a home that takes no new file the copy was never made, and the redirection of the second command had emptied the rc before cat failed on the missing copy. An uninstall, or an install replacing an earlier install's export, left a writable rc at 0 bytes there. And an rc with a NUL byte in it (a key binding) is binary to grep, which prints one line, "Binary file <rc> matches", and exits 0: that line became the rc. The copy is now made with mktemp under TMPDIR, by grep -a; a grep status above 1 stops before the rc is touched; and a failed write through leaves the copy and names it, since writing through (which keeps a linked rc a link) cannot be atomic. test-binary.sh 6d holds each clause: a home of mode 0555 with a writable rc that carries the old export beside the user's lines, one of them quoting the export and one with a NUL byte, compared byte for byte after uninstall and after install; an rc holding the export alone; a grep that fails on the copy; a cat that fails on the write; and TMPDIR empty after every run that succeeds. 6b and 6c now also look for the mark line, which their pattern did not match. Twelve single-clause breakages of the installer each fail a row. Fixes #135 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: closer-claudio <claudio@farcloser.world>
closer-claudio
marked this pull request as ready for review
November 17, 2026 09:41
closer-claudio
enabled auto-merge
November 17, 2026 09:42
Contributor
Author
|
Reviewed at 9aa2dcf |
1 similar comment
Contributor
Author
|
Reviewed at 9aa2dcf |
This branch has not been deployed
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.
🎯 Why
ssh-agent-installtakes its own lines out of a shell rc by copying the rc without them, then writing the copy over the rc. Two ways that lost the user's file (#135):<rc>.tmp) behind|| true. In a home directory that takes no new file the copy was never made, and the next command's redirection had emptied the rc beforecatfailed on the missing copy.ssh-agent-install uninstall, or an install replacing an earlier install's export, exited 1 and left a writable rc at 0 bytes.grep, which prints one line,Binary file <rc> matches, and exits 0. That line became the rc, with exit 0.🛠️ What
strip_linesinagent/ssh-agent-install:mktempunderTMPDIR, bygrep -a;🧪 How
test-binary.sh6d, run by CI against the built package:grepthat fails when making the copy: exit non-zero, rc unchanged, nothing left inTMPDIR;catthat fails on the write: exit non-zero, the named copy is there and whole;TMPDIRempty after every run that succeeds.6b and 6c now also look for the installer's mark line, which their pattern did not match.
Twelve single-clause breakages of the installer, run against sections 6b to 6d with a CI-built package: each fails a row.
📝 Notes
Draft until the checks are green: the full
test-binary.shneeds the built package.