Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-13 Thread Bruce Momjian
Applied. --- Bruce Momjian wrote: Andrew Dunstan wrote: Bruce Momjian wrote: + /* If it was 'invalid authorization', add .pgpass mention */ + if (conn-dot_pgpass_used conn-password_needed

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-12 Thread Bruce Momjian
Andrew Dunstan wrote: Bruce Momjian wrote: + /* If it was 'invalid authorization', add .pgpass mention */ + if (conn-dot_pgpass_used conn-password_needed conn-result + /* only works with = 9.0 servers */ + strcmp(PQresultErrorField(conn-result,

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Bruce Momjian
Bruce Momjian wrote: Tom Lane wrote: Bruce Momjian br...@momjian.us writes: Tom Lane wrote: I'm inclined to think that maybe we should make the server return a distinct SQLSTATE for bad password, and have libpq check for that rather than just assuming that the failure must be bad

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Alvaro Herrera
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 */ +

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Bruce Momjian
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 */ +

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Tom Lane
Bruce Momjian br...@momjian.us writes: Alvaro Herrera wrote: 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

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian br...@momjian.us writes: Alvaro Herrera wrote: This bit seems strange ... I think we just do strcmp() to compare sqlstates? Uh, the PQresultErrorField is a string, while ERRCODE_INVALID_PASSWORD_SPECIFICATION is a 4-byte value in base-64. Yea, it's

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Tom Lane
Bruce Momjian br...@momjian.us writes: ERRCODE_INVALID_PASSWORD_SPECIFICATION BTW, why not just ERRCODE_INVALID_PASSWORD? The extra word doesn't seem to promote anything except carpal tunnel syndrome. regards, tom lane -- Sent via pgsql-hackers mailing list

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Tom Lane
Bruce Momjian br...@momjian.us writes: + #define ERRCODE_INVALID_PASSWORD_SPECIFICATION MAKE_SQLSTATE('2','8', '0','0','1') Oh, another thought: you're infringing on SQL-committee-controlled code space there. Probably 28P01 would be a safer choice. regards, tom lane

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian br...@momjian.us writes: + #define ERRCODE_INVALID_PASSWORD_SPECIFICATION MAKE_SQLSTATE('2','8', '0','0','1') Oh, another thought: you're infringing on SQL-committee-controlled code space there. Probably 28P01 would be a safer choice. OK, updated patch

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Robert Haas
On Thu, Mar 11, 2010 at 4:19 PM, Bruce Momjian br...@momjian.us wrote:        $ sql -h localhost test        psql: FATAL:  password authentication failed for user postgres        password retrieved from .pgpass I find this not quite explicit enough for my taste. Maybe something like this?

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Bruce Momjian
Robert Haas wrote: On Thu, Mar 11, 2010 at 4:19 PM, Bruce Momjian br...@momjian.us wrote: ? ? ? ?$ sql -h localhost test ? ? ? ?psql: FATAL: ?password authentication failed for user postgres ? ? ? ?password retrieved from .pgpass I find this not quite explicit enough for my taste. Maybe

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-11 Thread Andrew Dunstan
Bruce Momjian wrote: + /* If it was 'invalid authorization', add .pgpass mention */ + if (conn-dot_pgpass_used conn-password_needed conn-result + /* only works with = 9.0 servers */ + strcmp(PQresultErrorField(conn-result, PG_DIAG_SQLSTATE), +

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-10 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian br...@momjian.us writes: The attached patch reports the fact that .pgpass was used if the libpq connection fails: The test is in a very inappropriate place --- it will be missed by several fully-supported code paths. Agreed. I moved it to the error return

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-10 Thread Tom Lane
Bruce Momjian br...@momjian.us writes: Tom Lane wrote: I'm inclined to think that maybe we should make the server return a distinct SQLSTATE for bad password, and have libpq check for that rather than just assuming that the failure must be bad password. Modifying the backend to issue this

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-10 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian br...@momjian.us writes: Tom Lane wrote: I'm inclined to think that maybe we should make the server return a distinct SQLSTATE for bad password, and have libpq check for that rather than just assuming that the failure must be bad password. Modifying the

[HACKERS] Warning about invalid .pgpass passwords

2010-03-09 Thread Bruce Momjian
Bruce Momjian wrote: Tom Lane wrote: Alvaro Herrera alvhe...@commandprompt.com writes: It had to do with me having a bogus password in .pgpass (so psql was first trying empty password, then the one in .pgpass, and both failing). Pilot error. However, I'd say that we ought to give a

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-09 Thread Fujii Masao
On Wed, Mar 10, 2010 at 11:52 AM, Bruce Momjian br...@momjian.us wrote: The attached patch reports the fact that .pgpass was used if the libpq connection fails: + /* +* If the connection failed, we should mention that +* we got the password from .pgpass in case

Re: [HACKERS] Warning about invalid .pgpass passwords

2010-03-09 Thread Tom Lane
Bruce Momjian br...@momjian.us writes: The attached patch reports the fact that .pgpass was used if the libpq connection fails: The test is in a very inappropriate place --- it will be missed by several fully-supported code paths. I am not sure if I like the parentheses or not. I don't like