From 7f78bc92b67be3aeaef89a9f5f4163bbc82f90cb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 27 Sep 2012 11:27:16 -0400 Subject: [PATCH] webapp: Avoid crashing when ssh-keygen -F chokes on an invalid known_hosts file. --- Assistant/Ssh.hs | 6 +++++- debian/changelog | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs index 876f854667..59ed34497a 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] diff --git a/debian/changelog b/debian/changelog index 976b70903d..f8efeba5aa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,8 @@ git-annex (3.20120925) UNRELEASED; urgency=low in the git repository, as that would allow anyone with access to the repository access to the S3 account. Instead, they're stored in a 600 mode file in the local git repo. + * webapp: Avoid crashing when ssh-keygen -F chokes on an invalid known_hosts + file. -- Joey Hess Mon, 24 Sep 2012 19:58:07 -0400