Re: BUG #17249: Bug in .pgpass search and/or documentation thereof, Ubuntu 13.4-4 - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #17249: Bug in .pgpass search and/or documentation thereof, Ubuntu 13.4-4
Date
Msg-id CAKFQuwb-_1FgMLRFWGXb1WHrkwKMmdtKMWxLDYosuudkbcB70g@mail.gmail.com
Whole thread Raw
In response to Re: BUG #17249: Bug in .pgpass search and/or documentation thereof, Ubuntu 13.4-4  (David Hillman <david@kapitaltrading.com>)
Responses Re: BUG #17249: Bug in .pgpass search and/or documentation thereof, Ubuntu 13.4-4
List pgsql-bugs
On Thu, Oct 28, 2021 at 8:54 AM David Hillman <david@kapitaltrading.com> wrote:

Furthermore, if I remove .pgpass, this case's result changes.

root@dbserver:~# cat ~/.pgpass
cat: /root/.pgpass: No such file or directory
root@dbserver:~# psql -d postgres -U valid_user -h localhost
Password for user valid_user:


You've already demonstrated that when connecting via "host" the first matching entry is a password requiring entry.  In your first email pgpass provided the password.  Here you've simply removed pgpass and demonstrated that you are actually being prompted for the password, as expected.

Your original email demonstrates that, absent -h localhost, psql is looking for and finding a local socket and thus the first matching entry is a "local" one which does not require password entry because it is set for "peer".  This is working as intended.  psql decides first where to go talk, then the pg_hba.conf file ignores any irrelevant lines based upon where the connection is coming in from and picks the first match among the remaining.

David J.

pgsql-bugs by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: BUG #17245: Index corruption involving deduplicated entries
Next
From: Tom Lane
Date:
Subject: Re: BUG #17249: Bug in .pgpass search and/or documentation thereof, Ubuntu 13.4-4