Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cardano-db/src/Cardano/Db/PGConfig.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.Db.PGConfig
( PGConfig (..)
Expand Down Expand Up @@ -79,8 +80,12 @@ readPGPassFile (PGPassFile fpath) = do
replaceUser pgc
| pgcUser pgc /= "*" = pure pgc
| otherwise = do
user <- getEffectiveUserName
pure $ pgc { pgcUser = BS.pack user }
euser <- Exception.try getEffectiveUserName
case euser of
Left (_ :: IOException) ->
error "readPGPassFile: User in pgpass file was specified as '*' but getEffectiveUserName failed."
Right user ->
pure $ pgc { pgcUser = BS.pack user }


-- | Read 'PGPassFile' into 'PGConfig'.
Expand Down