From 768f7c87f2546d9f48d4bdcd82a74821987ca398 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 10 Jun 2013 23:54:28 -0400 Subject: [PATCH] display any illegal character found in ssh comment --- Assistant/Ssh.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs index 7875c4c4cb..182e853772 100644 --- a/Assistant/Ssh.hs +++ b/Assistant/Ssh.hs @@ -82,9 +82,10 @@ validateSshPubKey pubkey = either error return $ check $ words pubkey where (ssh, keytype) = separate (== '-') prefix - checkcomment comment - | all (\c -> isAlphaNum c || c == '@' || c == '-' || c == '_' || c == '.') comment = ok - | otherwise = err "bad comment in ssh public key" + checkcomment comment = case filter (not . safeincomment) comment of + [] -> ok + badstuff -> err $ "bad comment in ssh public key (contains: \"" ++ badstuff ++ "\")" + safeincomment c = isAlphaNum c || c == '@' || c == '-' || c == '_' || c == '.' addAuthorizedKeys :: Bool -> FilePath -> SshPubKey -> IO Bool addAuthorizedKeys rsynconly dir pubkey = boolSystem "sh"