diff options
author | Joey Hess <joey@kitenet.net> | 2012-09-27 11:27:16 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-09-27 11:27:16 -0400 |
commit | 0b33de8e83ae2dd3f18f60698b7e9d033b30fae6 (patch) | |
tree | 9b69a57643a0eeb3bb603f86ec1d7f8438ca9293 /Assistant | |
parent | 7ba3dcd478b37ef2df7dde8c355e16bbb41cadc5 (diff) |
webapp: Avoid crashing when ssh-keygen -F chokes on an invalid known_hosts file.
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/Ssh.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs index 876f85466..59ed34497 100644 --- a/Assistant/Ssh.hs +++ b/Assistant/Ssh.hs @@ -223,6 +223,10 @@ knownHost :: Text -> IO Bool knownHost hostname = do sshdir <- sshDir ifM (doesFileExist $ sshdir </> "known_hosts") - ( not . null <$> readProcess "ssh-keygen" ["-F", T.unpack hostname] + ( not . null <$> checkhost , return False ) + where + {- ssh-keygen -F can crash on some old known_hosts file -} + checkhost = catchDefaultIO "" $ + readProcess "ssh-keygen" ["-F", T.unpack hostname] |