Use USER and HOME environment when set, and only fall back to getpwent, which doesn't work with LDAP or NIS.

This commit is contained in:
Joey Hess 2012-10-25 18:17:32 -04:00
parent 2018de53a3
commit 7ee0ffaeb9
13 changed files with 49 additions and 20 deletions

View file

@ -20,20 +20,16 @@ import qualified Annex.Branch
import Logs.UUID
import Annex.Version
import Annex.UUID
import System.Posix.User
import Utility.UserInfo
genDescription :: Maybe String -> Annex String
genDescription (Just d) = return d
genDescription Nothing = do
hostname <- maybe "" id <$> liftIO getHostname
let at = if null hostname then "" else "@"
username <- clicketyclickety
username <- liftIO myUserName
reldir <- liftIO . relHome =<< fromRepo Git.repoPath
return $ concat [username, at, hostname, ":", reldir]
where
clicketyclickety = liftIO $ userName <$>
(getUserEntryForID =<< getEffectiveUserID)
initialize :: Maybe String -> Annex ()
initialize mdescription = do