summaryrefslogtreecommitdiff
path: root/src/bin/scripts/common.c
diff options
context:
space:
mode:
authorPeter Eisentraut2009-02-26 16:02:39 +0000
committerPeter Eisentraut2009-02-26 16:02:39 +0000
commit9de59fd191dc86e7a49a5d7726ef09041549fc88 (patch)
tree9edc44560aa7beca92b7bc6c8e889c78655172c0 /src/bin/scripts/common.c
parenteea49769d415b00ea36e2ee64774cb4d1313d991 (diff)
Add a -w/--no-password option that prevents all password prompts to all
programs that have a -W/--password option. In passing, remove the ancient PSQL_ALWAYS_GET_PASSWORDS compile option.
Diffstat (limited to 'src/bin/scripts/common.c')
-rw-r--r--src/bin/scripts/common.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index 2587f1a99df..c34115a1ba0 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.34 2009/02/25 13:24:40 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.35 2009/02/26 16:02:38 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -96,14 +96,14 @@ handle_help_version_opts(int argc, char *argv[],
*/
PGconn *
connectDatabase(const char *dbname, const char *pghost, const char *pgport,
- const char *pguser, bool require_password,
+ const char *pguser, enum trivalue prompt_password,
const char *progname)
{
PGconn *conn;
char *password = NULL;
bool new_pass;
- if (require_password)
+ if (prompt_password == TRI_YES)
password = simple_prompt("Password: ", 100, false);
/*
@@ -124,7 +124,8 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
if (PQstatus(conn) == CONNECTION_BAD &&
PQconnectionNeedsPassword(conn) &&
- password == NULL)
+ password == NULL &&
+ prompt_password != TRI_NO)
{
PQfinish(conn);
password = simple_prompt("Password: ", 100, false);