also avoid crashing in most circumstances if unable to determine the username

Mostly the username is only used for the git committer or other display
purposes, and we can just fall back to a dummy value in these cases.

The only remaining place where an error is thrown is when starting local
pairing, which needs the username to be known.
This commit is contained in:
Joey Hess 2016-06-08 15:04:15 -04:00
parent a3ff99ea3b
commit 8e4cbefbc6
Failed to extract signature
6 changed files with 20 additions and 22 deletions

View file

@ -226,7 +226,7 @@ startLocalPairing stage oncancel alert muuid displaysecret secret = do
let pubkey = either error id $ validateSshPubKey $ sshPubKey keypair
pairdata <- liftIO $ PairData
<$> getHostname
<*> myUserName
<*> (either error id <$> myUserName)
<*> pure reldir
<*> pure pubkey
<*> (maybe genUUID return muuid)
@ -291,8 +291,8 @@ promptSecret msg cont = pairPage $ do
let (username, hostname) = maybe ("", "")
(\(_, v, a) -> (T.pack $ remoteUserName v, T.pack $ fromMaybe (showAddr a) (remoteHostName v)))
(verifiableVal . fromPairMsg <$> msg)
u <- T.pack <$> liftIO myUserName
let sameusername = username == u
u <- liftIO myUserName
let sameusername = Right username == (T.pack <$> u)
$(widgetFile "configurators/pairing/local/prompt")
{- This counts unicode characters as more than one character,