assistant: When updating ~/.ssh/config, preserve any symlinks.

This commit is contained in:
Joey Hess 2015-09-21 12:39:13 -04:00
parent c6041164e4
commit 0ebde659bf
3 changed files with 22 additions and 2 deletions

View file

@ -15,6 +15,7 @@ import Utility.FileMode
import Data.Char import Data.Char
import Data.Ord import Data.Ord
import Data.Either import Data.Either
import System.Directory
data SshConfig data SshConfig
= GlobalConfig SshSetting = GlobalConfig SshSetting
@ -117,8 +118,11 @@ changeUserSshConfig modifier = do
whenM (doesFileExist configfile) $ do whenM (doesFileExist configfile) $ do
c <- readFileStrict configfile c <- readFileStrict configfile
let c' = modifier c let c' = modifier c
when (c /= c') $ when (c /= c') $ do
viaTmp writeSshConfig configfile c' -- If it's a symlink, replace the file it
-- points to.
f <- catchDefaultIO configfile (canonicalizePath configfile)
viaTmp writeSshConfig f c'
writeSshConfig :: FilePath -> String -> IO () writeSshConfig :: FilePath -> String -> IO ()
writeSshConfig f s = do writeSshConfig f s = do

1
debian/changelog vendored
View file

@ -2,6 +2,7 @@ git-annex (5.20150917) UNRELEASED; urgency=medium
* info: Don't allow use in a non-git-annex repository, since it * info: Don't allow use in a non-git-annex repository, since it
uses the git-annex branch and would create it if it were missing. uses the git-annex branch and would create it if it were missing.
* assistant: When updating ~/.ssh/config, preserve any symlinks.
-- Joey Hess <id@joeyh.name> Wed, 16 Sep 2015 12:23:33 -0400 -- Joey Hess <id@joeyh.name> Wed, 16 Sep 2015 12:23:33 -0400

View file

@ -0,0 +1,15 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2015-09-21T16:14:03Z"
content="""
The assistant does not normally do this when you merely start it up. It does it
when you configure a ssh remote, when it needs to modify that file.
It might also modify the file on startup if it detects a configuration that
an old version of the assistant put in that needs to be fixed up.
Is the trailing whitespace you speak of just a newline added after the
existing host block, or something else? Your "..." is not very clear.
Fixed symlink issue in git.
"""]]