From: | Martin Pitt <martin(at)piware(dot)de> |
---|---|
To: | PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Provide a way to not ask for a password in psql |
Date: | 2007-10-09 13:56:33 |
Message-ID: | 20071009135633.GB7103@piware.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-patches |
Hello,
first, congratulations for 8.3beta1. I built some initial
Debian/Ubuntu packages which went very smoothly.
I am now walking through the failures of my postgresql-common test
suite. One particular regression is that there seems to be no way any
more to inhibit the password prompt in psql. This is particularly bad
for noninteractive scripts. For example, "psql -l" is a convenient
method to check whether the postmaster is running at all,
finished with startup and ready for connections.
There is a command line switch -W which forces the password prompt,
but not an inverse switch to avoid it. So those three obvious
workarounds came to my mind:
(1) psql -l < /dev/null
Does not work because simple_prompt() reads from /dev/tty.
psql could check the already existing pset.notty and not enter the
do-while loop for asking for the password if it is True.
(2) PGPASSFILE=/dev/null psql -l
With /dev/null I get a segfault (I'll probably send a patch for
that later). With an empty dummy file it cannot find a matching
password and thus prompt me again. Admittedly this behaviour does
make sense, so it should not be altered.
(3) PGPASSWORD=foo psql -l
This trick with specifying an invalid password worked up until 8.2.
Unfortunately it stopped working now due to a slight code change:
if (PQstatus(pset.db) == CONNECTION_BAD &&
- strcmp(PQerrorMessage(pset.db), PQnoPasswordSupplied) == 0 &&
+ PQconnectionUsedPassword(pset.db) &&
To get back the earlier behaviour, this could be reverted, or the
case could me made explicit with
- password == NULL &&
+ password == NULL && !getenv("PGPASSWORD") &&
My current workaround is to use the dodgy patch in (3), but I'd
prefer to use an official upstream sanctioned method.
Thank you!
Martin
--
Martin Pitt http://www.piware.de
Ubuntu Developer http://www.ubuntu.com
Debian Developer http://www.debian.org
From | Date | Subject | |
---|---|---|---|
Next Message | Martin Pitt | 2007-10-09 14:32:02 | libpq crash fix [was: Provide a way to not ask for a password in psql] |
Previous Message | Tom Lane | 2007-10-09 13:17:19 | Re: BUG #3660: unused empty file is created with csvlog |
From | Date | Subject | |
---|---|---|---|
Next Message | Martin Pitt | 2007-10-09 14:32:02 | libpq crash fix [was: Provide a way to not ask for a password in psql] |
Previous Message | Magnus Hagander | 2007-10-09 11:18:41 | Re: Preliminary patch for tsearch example dictionaries/parsers in contrib |