diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-09-21 12:39:13 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-09-21 12:39:13 -0400 |
commit | d57325804d57faef755be86f330119cffe1d1bba (patch) | |
tree | ef31d92d17e6c563e626e34ea242a9ad000e3296 /Utility/SshConfig.hs | |
parent | 0535973adab83a9a73a399a6fa798629c0067633 (diff) |
assistant: When updating ~/.ssh/config, preserve any symlinks.
Diffstat (limited to 'Utility/SshConfig.hs')
-rw-r--r-- | Utility/SshConfig.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Utility/SshConfig.hs b/Utility/SshConfig.hs index ca336a4b8..57e4f0f38 100644 --- a/Utility/SshConfig.hs +++ b/Utility/SshConfig.hs @@ -15,6 +15,7 @@ import Utility.FileMode import Data.Char import Data.Ord import Data.Either +import System.Directory data SshConfig = GlobalConfig SshSetting @@ -117,8 +118,11 @@ changeUserSshConfig modifier = do whenM (doesFileExist configfile) $ do c <- readFileStrict configfile let c' = modifier c - when (c /= c') $ - viaTmp writeSshConfig configfile c' + when (c /= c') $ do + -- 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 f s = do |