Re: BUG #4040: psql should provide option to not prompt for password - Mailing list pgsql-bugs

From Martin Pitt
Subject Re: BUG #4040: psql should provide option to not prompt for password
Date
Msg-id 20080317170728.GB19155@piware.de
Whole thread Raw
In response to Re: BUG #4040: psql should provide option to not prompt for password  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Tom Lane [2008-03-17 10:48 -0400]:
> Martin Pitt <martin@piware.de> writes:
> >          if (PQstatus(pset.db) == CONNECTION_BAD &&
> >              PQconnectionNeedsPassword(pset.db) &&
> > -            password == NULL &&
> > +            password == NULL && !getenv("PGPASSWORD") &&
> >              !feof(stdin))
> >          {
> >              PQfinish(pset.db);
>
> What exactly do you think that accomplishes?  AFAICS
> PQconnectionNeedsPassword can't possibly return true if there was a
> password available from PGPASSWORD (regardless of whether it was
> correct or not).

I don't claim to understand the complete code behind
PQconnectionNeedsPassword(). I just found that in at least 8.3RC1,
this did return True if pg_hba.conf set password authentication and
none was provided. I tried every trick that came into my mind,
redirecting stdin, using PGPASSWORD, and I think even a fake empty
.pgpass file, nothing worked.

Martin
--
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

pgsql-bugs by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: BUG #4040: psql should provide option to not prompt for password
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #4040: psql should provide option to not prompt for password