aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-10-16 03:10:17 +0000
committerBruce Momjian <bruce@momjian.us>2004-10-16 03:10:17 +0000
commit88fd162ef64cab7ed197f0612e0b610d57007200 (patch)
tree7ea088e7cef6a6848508fe9629c55819a200b399
parent9ffc8ed58b55cb3925bb95cc184583fcb9772013 (diff)
downloadpostgresql-88fd162ef64cab7ed197f0612e0b610d57007200.tar.gz
postgresql-88fd162ef64cab7ed197f0612e0b610d57007200.zip
Allow pg_ctl to determine the server is up when getting a request for a
password. Make password error message a #define and use it consistently. Sean Chittenden
-rw-r--r--src/bin/pg_ctl/pg_ctl.c7
-rw-r--r--src/bin/pg_dump/pg_backup_db.c6
-rw-r--r--src/bin/pg_dump/pg_dumpall.c4
-rw-r--r--src/bin/psql/command.c4
-rw-r--r--src/bin/psql/startup.c4
-rw-r--r--src/bin/scripts/common.c5
-rw-r--r--src/interfaces/libpq/fe-auth.c4
-rw-r--r--src/interfaces/libpq/libpq-fe.h5
8 files changed, 22 insertions, 17 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 9c87b397151..40674c305b4 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.38 2004/10/15 04:54:33 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.39 2004/10/16 03:10:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -364,7 +364,6 @@ test_postmaster_connection(void)
char portstr[32];
char *p;
-
*portstr = '\0';
/* post_opts */
@@ -432,7 +431,9 @@ test_postmaster_connection(void)
{
if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,
"template1", NULL, NULL)) != NULL &&
- PQstatus(conn) == CONNECTION_OK)
+ (PQstatus(conn) == CONNECTION_OK ||
+ (strcmp(PQerrorMessage(conn),
+ PQnoPasswordSupplied) == 0)))
{
PQfinish(conn);
success = true;
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 181414c263a..989fdf8287f 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.59 2004/10/01 17:25:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.60 2004/10/16 03:10:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -168,7 +168,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
if (PQstatus(newConn) == CONNECTION_BAD)
{
noPwd = (strcmp(PQerrorMessage(newConn),
- "fe_sendauth: no password supplied\n") == 0);
+ PQnoPasswordSupplied) == 0);
badPwd = (strncmp(PQerrorMessage(newConn),
"Password authentication failed for user", 39) == 0);
@@ -249,7 +249,7 @@ ConnectDatabase(Archive *AHX,
die_horribly(AH, modulename, "failed to connect to database\n");
if (PQstatus(AH->connection) == CONNECTION_BAD &&
- strcmp(PQerrorMessage(AH->connection), "fe_sendauth: no password supplied\n") == 0 &&
+ strcmp(PQerrorMessage(AH->connection), PQnoPasswordSupplied) == 0 &&
!feof(stdin))
{
PQfinish(AH->connection);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 1b26ebb4dc9..caf439cf316 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.53 2004/10/15 04:32:28 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.54 2004/10/16 03:10:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -957,7 +957,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
}
if (PQstatus(conn) == CONNECTION_BAD &&
- strcmp(PQerrorMessage(conn), "fe_sendauth: no password supplied\n") == 0 &&
+ strcmp(PQerrorMessage(conn), PQnoPasswordSupplied) == 0 &&
!feof(stdin))
{
PQfinish(conn);
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 998a0027946..04c017c321b 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.128 2004/10/14 20:23:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.129 2004/10/16 03:10:16 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -929,7 +929,7 @@ do_connect(const char *new_dbname, const char *new_user)
NULL, NULL, dbparam, userparam, pwparam);
if (PQstatus(pset.db) == CONNECTION_BAD &&
- strcmp(PQerrorMessage(pset.db), "fe_sendauth: no password supplied\n") == 0 &&
+ strcmp(PQerrorMessage(pset.db), PQnoPasswordSupplied) == 0 &&
!feof(stdin))
{
PQfinish(pset.db);
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 3af3bc789d7..87f9200d7cd 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.103 2004/10/08 11:24:19 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.104 2004/10/16 03:10:16 momjian Exp $
*/
#include "postgres_fe.h"
@@ -195,7 +195,7 @@ main(int argc, char *argv[])
username, password);
if (PQstatus(pset.db) == CONNECTION_BAD &&
- strcmp(PQerrorMessage(pset.db), "fe_sendauth: no password supplied\n") == 0 &&
+ strcmp(PQerrorMessage(pset.db), PQnoPasswordSupplied) == 0 &&
!feof(stdin))
{
PQfinish(pset.db);
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index 7fe8b406018..a52b30fec88 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -5,13 +5,14 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.11 2004/08/29 05:06:54 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.12 2004/10/16 03:10:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include "common.h"
+#include "libpq-fe.h"
#include <pwd.h>
#include <unistd.h>
@@ -102,7 +103,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
}
if (PQstatus(conn) == CONNECTION_BAD &&
- strcmp(PQerrorMessage(conn), "fe_sendauth: no password supplied\n") == 0 &&
+ strcmp(PQerrorMessage(conn), PQnoPasswordSupplied) == 0 &&
!feof(stdin))
{
PQfinish(conn);
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 17862a0c807..84477563ef5 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.93 2004/09/28 00:06:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.94 2004/10/16 03:10:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -634,7 +634,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
if (password == NULL || *password == '\0')
{
(void) snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "fe_sendauth: no password supplied\n");
+ PQnoPasswordSupplied);
return STATUS_ERROR;
}
if (pg_password_sendauth(conn, password, areq) != STATUS_OK)
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index ff1a2c1ad69..9e6ebb28381 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.108 2004/08/29 05:07:00 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.109 2004/10/16 03:10:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -398,6 +398,9 @@ extern void PQfreemem(void *ptr);
/* Exists for backward compatibility. bjm 2003-03-24 */
#define PQfreeNotify(ptr) PQfreemem(ptr)
+/* Define the string so all uses are consistent. */
+#define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"
+
/*
* Make an empty PGresult with given status (some apps find this
* useful). If conn is not NULL and status indicates an error, the