On 10/27/21 7:17 PM, Tom Lane wrote:
> Notice it says "peer authentication", not "password authentication".
> So the password was never asked for, and the problem is that you're
> not logged in as "valid_user" (rather, it looks like, as "root").
This is still a bug, since per your description, the -U flag doesn't
work correctly -- or is meaningless. And, the -U flag works differently
depending on which other flags are set ( -h in his case ), as my example
does show, and that's not documented anywhere, as far as I know.
> This is evidently going to a different pg_hba.conf line, which
> might or might not be selecting password auth --- we can't see it.
There exist no such lines which pertain to "valid_user" here.
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:
Clearly, .pgpass is being utilized in the second example, and not in the
first, contrary to the apparent intent and the documentation.
--
David Hillman
david@kapitaltrading.com