Commit bdac9836 authored by Robert Haas's avatar Robert Haas

libpq: Fix inadvertent change in .pgpass lookup behavior.

Commit 274bb2b3 caused password file
lookups to use the hostaddr in preference to the host, but that was
not intended and the documented behavior is the opposite.

Report and patch by Kyotaro Horiguchi.

Discussion: http://postgr.es/m/20170428.165432.60857995.horiguchi.kyotaro@lab.ntt.co.jp
parent fed6df48
......@@ -978,9 +978,18 @@ connectOptions2(PGconn *conn)
for (i = 0; i < conn->nconnhost; i++)
{
/* Try to get a password for this host from pgpassfile */
/*
* Try to get a password for this host from pgpassfile. We use host
* name rather than host address in the same manner to PQhost().
*/
char *pwhost = conn->connhost[i].host;
if (conn->connhost[i].type == CHT_HOST_ADDRESS &&
conn->pghost != NULL && conn->pghost[0] != '\0')
pwhost = conn->pghost;
conn->connhost[i].password =
passwordFromFile(conn->connhost[i].host,
passwordFromFile(pwhost,
conn->connhost[i].port,
conn->dbName,
conn->pguser,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment