Re: Warning about invalid .pgpass passwords - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Warning about invalid .pgpass passwords
Date
Msg-id 201003112135.o2BLZeS12773@momjian.us
Whole thread Raw
In response to Re: Warning about invalid .pgpass passwords  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Warning about invalid .pgpass passwords
List pgsql-hackers
Alvaro Herrera wrote:
> Bruce Momjian wrote:
> 
> > + static void
> > + dot_pg_pass_warning(PGconn *conn)
> > + {
> > +     /* If it was 'invalid authorization', add .pgpass mention */
> > +     if (conn->dot_pgpass_used && conn->password_needed && conn->result &&
> > +         /* only works with >= 9.0 servers */
> > +         atoi(PQresultErrorField(conn->result, PG_DIAG_SQLSTATE)) ==
> > +             SQLSTATE_TO_BASE10(ERRCODE_INVALID_PASSWORD_SPECIFICATION))
> > +         appendPQExpBufferStr(&conn->errorMessage,
> > +             libpq_gettext("password retrieved from .pgpass\n"));
> > + }
> 
> This bit seems strange ...  I think we just do strcmp() to compare sqlstates?

Uh, the PQresultErrorField is a string, while
ERRCODE_INVALID_PASSWORD_SPECIFICATI is a 4-byte value in base-64.  
Yea, it's true.  For excitement, see the MAKE_SQLSTATE macro.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 PG East:  http://www.enterprisedb.com/community/nav-pg-east-2010.do


pgsql-hackers by date:

Previous
From: Steve Atkins
Date:
Subject: Re: [patch] build issues on Win32
Next
From: "Kevin Grittner"
Date:
Subject: Re: HeapTupleData.t_self garbage values