Re: .pgpass file and unix domain sockets - Mailing list pgsql-hackers

From Tom Lane
Subject Re: .pgpass file and unix domain sockets
Date
Msg-id 25954.1147311278@sss.pgh.pa.us
Whole thread Raw
In response to .pgpass file and unix domain sockets  (Joachim Wieland <joe@mcknight.de>)
Responses Re: .pgpass file and unix domain sockets
List pgsql-hackers
Joachim Wieland <joe@mcknight.de> writes:
> The documentation suggests that the hostname part of .pgpass can be set to
> "localhost" to allow for automatic unix domain socket authentication. This
> doesn't seem to work. Instead you have to set the directory of the socket as
> the hostname part.

It looks to me like if you don't specify the host in the connection request,
then "localhost" is indeed used to search .pgpass with.  *However*, if
you specify a socket path in pghost, then that's what's used.

I'm not sure if that's a bug or not.  Arguably, different socket paths
might point to different servers for which you need different passwords.
If we did want unix-socket connections to search for "localhost"
regardless of socket path, it'd be a simple change (change the order of
operations in connectOptions2).  But maybe the code is right and we
should fix the documentation.  Or maybe this whole notion of using
"localhost" is bogus and we should always use the socket path.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: BEGIN inside transaction should be an error
Next
From: Zdenek Kotala
Date:
Subject: [TODO] Allow commenting of variables ...