From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Bizarre behavior in libpq's searching of ~/.pgpass
Date: Tue, 31 Jul 2018 10:31:41 -0400
Message-ID: <11455.1533047501@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoYwNjrapiDo6BEpMCEVc0GxNSUKd8hObsUZJLEsVnpUqA@mail.gmail.com>
References: <30805.1532749137@sss.pgh.pa.us>
<CA+TgmoYwNjrapiDo6BEpMCEVc0GxNSUKd8hObsUZJLEsVnpUqA@mail.gmail.com>
Robert Haas <robertmhaas@gmail.com> writes:
> On Fri, Jul 27, 2018 at 11:38 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I noticed that there's some strange coding in libpq's choice of
>> what hostname to use for searching ~/.pgpass for a password.
> Yeah, that's bad code. The intent was that if you set host=a,b you
> probably want to use either 'a' or 'b' as the thing to look up in
> .pgpass, not 'a,b', but the implementation leaves something to be
> desired.
Right. Closely related to that is that the existing code in
passwordFromFile behaves differently for null vs. empty hostname.
This is bad on its face, because nowhere else in libpq do we treat
empty-string parameters differently from unset ones, but it's particularly
a mess for the comma-separated-list case because then it's impossible
for one of the alternatives to be NULL. In the already-posted patch
I fixed that so that an empty alternative is replaced by DefaultHost
in passwordFromFile, and likewise for port (though I think the latter
case may be unreachable).
But now that I look at it, it seems like the code in connectOptions2
has also Gotten It Wrong. Shouldn't the replacement of "unspecified"
cases by DEFAULT_PGSOCKET_DIR/DefaultHost also happen on an entry-by-
entry basis, so that "host=foo," would behave as though the empty
entry were "localhost"?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Bizarre behavior in libpq's searching of ~/.pgpass
In-Reply-To: <11455.1533047501@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox