From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Password prompting business |
Date: | 2009-02-20 13:31:49 |
Message-ID: | 499EB0C5.4090504@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I was revisiting the issue of how to prevent psql from prompting for a
password, for batch operations, previously discussion here:
http://www.mail-archive.com/pgsql-bugs(at)postgresql(dot)org/msg18440.html
http://www.mail-archive.com/pgsql-bugs(at)postgresql(dot)org/msg20002.html
I noticed that there appear to be remnants of actually supporting that
in the code that are now nonsense, e.g., in psql/startup.c:
if (PQstatus(pset.db) == CONNECTION_BAD &&
PQconnectionNeedsPassword(pset.db) &&
password == NULL &&
!feof(stdin))
{
PQfinish(pset.db);
password = simple_prompt(password_prompt, 100, false);
new_pass = true;
}
and similarly in scripts/common.c and in pg_dump(all).
The feof(stdin) test is there from a time when the prompt when to stdout
and the input came from stdin. Now it would usually not have any effect
unless the program reads from stdin before connecting to the database,
which doesn't happen, as far as I can tell.
Unless I'm reading this wrong, we should probably remove this.
Anyway, a way to prevent a password prompt would still be useful. This
should then be applicable to all client tools. I can imagine that we
either add a command-line option (-w would mirror -W well) or do this
automatically when stdin and/or stdout is not a terminal. I'm not sure
if the latter can be made to work safely, though.
From | Date | Subject | |
---|---|---|---|
Next Message | ohp | 2009-02-20 13:44:06 | Re: pg_restore new option -m |
Previous Message | Peter Eisentraut | 2009-02-20 12:32:05 | Re: pg_restore --multi-thread |