pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Password with libpq
4+ messages / 4 participants
[nested] [flat]

* Password with libpq
@ 2004-06-27 17:13  Tony Reina <reina_ga@hotmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: reina_ga@hotmail.com @ 2004-06-27 17:13 UTC (permalink / raw)
  To: pgsql-admin

I'm setting my PostgreSQL server to demand md5 encrypted passwords
from users. In my C programs (using libpq as the interface), it's no
big deal to pass the password through PQconnectdb.

However, what about in the general case where my client program
doesn't know if a password is required or not. Is there any libpq
function to query the server if a password is required? Perhaps,
there's a return value for PQconnectdb which would tell me that the
connection failed because of the password? (In which case, I can ask
for the password and try the connection again.)

Thanks.
-Tony



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Password with libpq
@ 2004-06-27 22:12  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Tony Reina <reina_ga@hotmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2004-06-27 22:12 UTC (permalink / raw)
  To: reina_ga@hotmail.com; +Cc: pgsql-admin

reina_ga@hotmail.com (Tony Reina) writes:
> However, what about in the general case where my client program
> doesn't know if a password is required or not. Is there any libpq
> function to query the server if a password is required? Perhaps,
> there's a return value for PQconnectdb which would tell me that the
> connection failed because of the password? (In which case, I can ask
> for the password and try the connection again.)

Look into the psql source code; it does essentially this.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Password with libpq
@ 2004-06-28 15:11  Tony and Bryn Reina <reina_ga@hotmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Tony and Bryn Reina @ 2004-06-28 15:11 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-admin

Thanks Tom. I found the relevant bit of code in the psql files. Looks like
it's just a simple loop that compares the error with the phrase
"fe_sendauth: no password supplied" and then prompts for the password and
tries again. Of course, if someone in the future decides to change the error
message, then the code gets broke. I doubt that's likely however.

-Tony



----- Original Message ----- 
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Tony Reina" <reina_ga@hotmail.com>
Cc: <pgsql-admin@postgresql.org>
Sent: Monday, June 28, 2004 12:12 AM
Subject: Re: [ADMIN] Password with libpq


> reina_ga@hotmail.com (Tony Reina) writes:
> > However, what about in the general case where my client program
> > doesn't know if a password is required or not. Is there any libpq
> > function to query the server if a password is required? Perhaps,
> > there's a return value for PQconnectdb which would tell me that the
> > connection failed because of the password? (In which case, I can ask
> > for the password and try the connection again.)
>
> Look into the psql source code; it does essentially this.
>
> regards, tom lane
>



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Password with libpq
@ 2004-06-28 17:22  Peter Eisentraut <peter_e@gmx.net>
  parent: Tony and Bryn Reina <reina_ga@hotmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Peter Eisentraut @ 2004-06-28 17:22 UTC (permalink / raw)
  To: Tony and Bryn Reina <reina_ga@hotmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-admin

Tony and Bryn Reina wrote:
> Thanks Tom. I found the relevant bit of code in the psql files. Looks
> like it's just a simple loop that compares the error with the phrase
> "fe_sendauth: no password supplied" and then prompts for the password
> and tries again. Of course, if someone in the future decides to
> change the error message, then the code gets broke. I doubt that's
> likely however.

Eventually, we should introduce error codes for this situation.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2004-06-28 17:22 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-27 17:13 Password with libpq Tony Reina <reina_ga@hotmail.com>
2004-06-27 22:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-06-28 15:11   ` Tony and Bryn Reina <reina_ga@hotmail.com>
2004-06-28 17:22     ` Peter Eisentraut <peter_e@gmx.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox