Repository navigation
fix(config): write through a symlinked ~/.ssh/config - #125
Open
lord-helicon wants to merge 1 commit into
Open
lord-helicon wants to merge 1 commit into
lord-helicon wants to merge 1 commit into
Conversation
Saving renamed the temp file over ~/.ssh/config itself, replacing a symlink (e.g. into a dotfiles repo) with a regular file and leaving the real file stale. Resolve the link first and atomically replace its target instead. Backups still go next to the link in ~/.ssh. Fixes Adembc#96
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.
Fixes #96.
When
~/.ssh/configis a symlink (for example into a dotfiles repo), saving renamed the temp file over the link itself. That replaced the symlink with a regular file and left the real file stale.lazyssh now resolves the link first and atomically replaces its target. Backups still go next to the link in
~/.ssh, and a config that doesn't exist yet behaves as before.Testing
TestAddServerKeepsSymlinkedConfigchecks that the link survives, the target is updated, the original backup lands next to the link, and no extra files appear next to the target.make build(gofumpt, vet, golangci-lint) andmake testpass.This PR is independent of my other two config fixes. The small
helpers_test.gois identical in all three, so they merge cleanly in any order.