Skip to content

ssh-agent-install no longer stops on an rc file it cannot write: it installs the agent and names the file - #134

Merged
closer-claudio merged 1 commit into
mainfrom
claudio/20261116-unwritable-rc
Nov 16, 2026
Merged

closer-claudio merged 1 commit into
mainfrom
claudio/20261116-unwritable-rc

Conversation

@closer-claudio

@closer-claudio closer-claudio commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Why

An rc of mode 0444, or one linked into a read-only store, ended ssh-agent-install at its >> with the shell's own "Permission denied" and exit 1: #131. By then the LaunchAgent was loaded and the rc files before that one written: an install done in part, with no closing line and no word on which file or what to do.

Refusing up front would serve nobody who has the problem: the owner of an rc linked into a read-only store cannot make it writable, and the agent needs nothing from that file.

🛠️ What

  • agent/ssh-agent-install: which rc gets the line is settled before anything is loaded. One that cannot be written (mode 0444, a link to a read-only file, a link to nothing) is passed over: the agent is installed, the others are written, and the closing line names it with the exact line to add by hand. Exit 0. Uninstall does the same with an rc it cannot take its line out of, and tells apart the two lines it may leave: this install's, which is guarded and does nothing once the env file is gone, and an earlier install's fixed export, which still sets SSH_AUTH_SOCK and is named with the line to take out.
  • test-binary.sh, 6c: a ~/.zshrc of mode 0444, and a ~/.bash_profile linked to a read-only file, each under a throwaway HOME. The installer must exit 0, name the file with the line, leave it as it was (a link stays a link), write ~/.bashrc; run again it must change nothing and name it again. Then the line is added by hand and the file locked again: uninstall must exit 0, name it, leave it as it is and leave no .tmp beside it. And a locked ~/.profile holding the old export: uninstall must say it still sets the variable.
  • README.md: one sentence under "The agent".

🧪 How

  • V: on the package CI built, with main's installer in it, 6c stops at "ssh-agent-install (readonly, first run) stopped on an rc it cannot write"; so does this installer with its check taken out on the install side, and on the uninstall side at the uninstall; with the two leftover lines not told apart it stops at the export's row; this one passes 6c and goes on to the server.
  • V: just lint green.
  • V: the whole smoke test, in this pull request's CI.

📝 Notes

An rc of mode 0444, or one linked into a read-only store, ended the
installer at its `>>` with the shell's own "Permission denied" and
exit 1 (#131). By then the
LaunchAgent was loaded and the rc files before that one written: an
install done in part, with no closing line and no word on which file
or what to do.

Refusing would serve nobody who has the problem: the owner of an rc
linked into a read-only store cannot make it writable, and the agent
needs nothing from that file. So which rc gets the line is settled
before anything is loaded. One that cannot be written is passed over:
the agent is installed, the others are written, and the closing line
names it with the exact line to add by hand. Exit 0. A link to nothing
is passed over the same way. Uninstall does the same with an rc it
cannot take its line out of, and tells the two lines it may leave
apart: this install's is guarded on the env file, which is gone, and
does nothing now; an earlier install's fixed export is not, and still
sets SSH_AUTH_SOCK to a socket nothing serves, so that one is named
with the line to take out.

test-binary.sh, 6c: a ~/.zshrc of mode 0444, and a ~/.bash_profile
linked to a read-only file, each under a throwaway HOME. The installer
must exit 0, name the file with the line, leave it as it was (and a
link a link), write ~/.bashrc; run again it must change nothing and
name it again. Then the line is added by hand, as the installer said,
and the file locked again: uninstall must exit 0, name it, leave it as
it is and leave no .tmp beside it. And a locked ~/.profile holding the
old export: uninstall must say it still sets the variable, and must
not say it does nothing. On main's installer the section stops at
"stopped on an rc it cannot write"; so does this one with its check
taken out on the install side, and on the uninstall side at the
uninstall; with the two lines not told apart it stops at the export's
row.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: closer-claudio <claudio@farcloser.world>
@closer-claudio
closer-claudio force-pushed the claudio/20261116-unwritable-rc branch from 49f588c to 7f2af90 Compare November 16, 2026 06:31
@closer-claudio
closer-claudio marked this pull request as ready for review November 16, 2026 06:37
@closer-claudio

Copy link
Copy Markdown
Contributor Author

Reviewed at 7f2af90

1 similar comment
@closer-claudio

Copy link
Copy Markdown
Contributor Author

Reviewed at 7f2af90

@closer-claudio
closer-claudio merged commit 6be06d2 into main Nov 16, 2026
8 checks passed
@closer-claudio
closer-claudio deleted the claudio/20261116-unwritable-rc branch November 16, 2026 06:57
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.

2 participants