Avoid a crash if getpwuid does not work, when querying the user's full name.

This commit is contained in:
Joey Hess 2016-06-08 13:48:03 -04:00
parent 88c85ae609
commit d62d81ee1c
Failed to extract signature
3 changed files with 32 additions and 1 deletions

View file

@ -15,6 +15,7 @@ module Utility.UserInfo (
) where
import Utility.Env
import Utility.Exception
import System.PosixCompat
import Control.Applicative
@ -47,7 +48,7 @@ myUserGecos :: IO (Maybe String)
#if defined(__ANDROID__) || defined(mingw32_HOST_OS)
myUserGecos = return Nothing
#else
myUserGecos = Just <$> myVal [] userGecos
myUserGecos = catchMaybeIO $ myVal [] userGecos
#endif
myVal :: [String] -> (UserEntry -> String) -> IO String