]> granicus.if.org Git - postgresql/commitdiff
Fix pgpass to work with PQconnectDB().
authorBruce Momjian <bruce@momjian.us>
Wed, 8 Jan 2003 21:33:53 +0000 (21:33 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 8 Jan 2003 21:33:53 +0000 (21:33 +0000)
Backpatch to 7.3.X.

Report from ljb.

src/interfaces/libpq/fe-connect.c

index 7cdd2466624469daecb16563fb419eb4d6972b52..3a64ec1748ac4e251700a94eba745a174432be35 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.213 2002/10/24 23:35:55 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.213.2.1 2003/01/08 21:33:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -304,6 +304,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
@@ -501,9 +504,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);