]> granicus.if.org Git - postgresql/commitdiff
Allow pg_ctl to determine the server is up when getting a request for a
authorBruce Momjian <bruce@momjian.us>
Sat, 16 Oct 2004 03:10:17 +0000 (03:10 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 16 Oct 2004 03:10:17 +0000 (03:10 +0000)
password.

Make password error message a #define and use it consistently.

Sean Chittenden

src/bin/pg_ctl/pg_ctl.c
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_dumpall.c
src/bin/psql/command.c
src/bin/psql/startup.c
src/bin/scripts/common.c
src/interfaces/libpq/fe-auth.c
src/interfaces/libpq/libpq-fe.h

index 9c87b3971515d8e49733869ee6dcc8224e182c32..40674c305b40ea7f967ecce66da60c8eb19253d1 100644 (file)
@@ -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;
index 181414c263af5b5867465fcba53a29e6be94bf1d..989fdf8287f2a910da297520c88078ea2b70a275 100644 (file)
@@ -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);
index 1b26ebb4dc938070c36040972a194ee821ae9a29..caf439cf3162074d4418ce06f96f8773713cf47b 100644 (file)
@@ -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);
index 998a002794651185b83243173bdaf3324864556e..04c017c321b4ae88063a17fc0d0da80201ecf3c4 100644 (file)
@@ -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);
index 3af3bc789d7d421f725aebec96cdc6fc7e713cc3..87f9200d7cdbe2757f49a3d857331f44783505cc 100644 (file)
@@ -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);
index 7fe8b40601871a16486ddeb61567ef04aaf2a985..a52b30fec880cc145b00e167fa7c9b0f4633c721 100644 (file)
@@ -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);
index 17862a0c807d3c77ea8570b832066a108872df90..84477563ef551f12d3c734153795734784517413 100644 (file)
@@ -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)
index ff1a2c1ad69e93ce84a753d1e000e24a7c621596..9e6ebb28381069408655d24fe885f1e44ea1f400 100644 (file)
@@ -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