From: Bruce Momjian Date: Wed, 8 Jan 2003 21:33:27 +0000 (+0000) Subject: Fix pgpass to work with PQconnectDB(). X-Git-Tag: REL7_4_BETA1~1264 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe7f8f2b91a587360bcdcb4b9371980bb2c1cf54;p=postgresql Fix pgpass to work with PQconnectDB(). Backpatch to 7.3.X. Report from ljb. --- diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index b5f566eb4f..57108df1ff 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.220 2003/01/08 16:21:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.221 2003/01/08 21:33:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -314,6 +314,9 @@ PQconnectStart(const char *conninfo) conn->pguser = tmp ? strdup(tmp) : NULL; tmp = conninfo_getval(connOptions, "password"); conn->pgpass = tmp ? strdup(tmp) : NULL; + if (conn->pgpass == NULL || conn->pgpass[0] == '\0') + conn->pgpass = PasswordFromFile(conn->pghost, conn->pgport, + conn->dbName, conn->pguser); tmp = conninfo_getval(connOptions, "connect_timeout"); conn->connect_timeout = tmp ? strdup(tmp) : NULL; #ifdef USE_SSL @@ -511,9 +514,6 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions, conn->pgpass = strdup(pwd); else if ((tmp = getenv("PGPASSWORD")) != NULL) conn->pgpass = strdup(tmp); - else if ((tmp = PasswordFromFile(conn->pghost, conn->pgport, - conn->dbName, conn->pguser))) - conn->pgpass = tmp; else conn->pgpass = strdup(DefaultPassword);