mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
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
This commit is contained in:
parent
9ffc8ed58b
commit
88fd162ef6
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
* 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 portstr[32];
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
|
|
||||||
*portstr = '\0';
|
*portstr = '\0';
|
||||||
|
|
||||||
/* post_opts */
|
/* post_opts */
|
||||||
@ -432,7 +431,9 @@ test_postmaster_connection(void)
|
|||||||
{
|
{
|
||||||
if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,
|
if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,
|
||||||
"template1", NULL, NULL)) != NULL &&
|
"template1", NULL, NULL)) != NULL &&
|
||||||
PQstatus(conn) == CONNECTION_OK)
|
(PQstatus(conn) == CONNECTION_OK ||
|
||||||
|
(strcmp(PQerrorMessage(conn),
|
||||||
|
PQnoPasswordSupplied) == 0)))
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* Implements the basic DB functions used by the archiver.
|
* Implements the basic DB functions used by the archiver.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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)
|
if (PQstatus(newConn) == CONNECTION_BAD)
|
||||||
{
|
{
|
||||||
noPwd = (strcmp(PQerrorMessage(newConn),
|
noPwd = (strcmp(PQerrorMessage(newConn),
|
||||||
"fe_sendauth: no password supplied\n") == 0);
|
PQnoPasswordSupplied) == 0);
|
||||||
badPwd = (strncmp(PQerrorMessage(newConn),
|
badPwd = (strncmp(PQerrorMessage(newConn),
|
||||||
"Password authentication failed for user", 39) == 0);
|
"Password authentication failed for user", 39) == 0);
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ ConnectDatabase(Archive *AHX,
|
|||||||
die_horribly(AH, modulename, "failed to connect to database\n");
|
die_horribly(AH, modulename, "failed to connect to database\n");
|
||||||
|
|
||||||
if (PQstatus(AH->connection) == CONNECTION_BAD &&
|
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))
|
!feof(stdin))
|
||||||
{
|
{
|
||||||
PQfinish(AH->connection);
|
PQfinish(AH->connection);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 &&
|
if (PQstatus(conn) == CONNECTION_BAD &&
|
||||||
strcmp(PQerrorMessage(conn), "fe_sendauth: no password supplied\n") == 0 &&
|
strcmp(PQerrorMessage(conn), PQnoPasswordSupplied) == 0 &&
|
||||||
!feof(stdin))
|
!feof(stdin))
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
|
* 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 "postgres_fe.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
@ -929,7 +929,7 @@ do_connect(const char *new_dbname, const char *new_user)
|
|||||||
NULL, NULL, dbparam, userparam, pwparam);
|
NULL, NULL, dbparam, userparam, pwparam);
|
||||||
|
|
||||||
if (PQstatus(pset.db) == CONNECTION_BAD &&
|
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))
|
!feof(stdin))
|
||||||
{
|
{
|
||||||
PQfinish(pset.db);
|
PQfinish(pset.db);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
|
* 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"
|
#include "postgres_fe.h"
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ main(int argc, char *argv[])
|
|||||||
username, password);
|
username, password);
|
||||||
|
|
||||||
if (PQstatus(pset.db) == CONNECTION_BAD &&
|
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))
|
!feof(stdin))
|
||||||
{
|
{
|
||||||
PQfinish(pset.db);
|
PQfinish(pset.db);
|
||||||
|
@ -5,13 +5,14 @@
|
|||||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 "postgres_fe.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "libpq-fe.h"
|
||||||
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -102,7 +103,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PQstatus(conn) == CONNECTION_BAD &&
|
if (PQstatus(conn) == CONNECTION_BAD &&
|
||||||
strcmp(PQerrorMessage(conn), "fe_sendauth: no password supplied\n") == 0 &&
|
strcmp(PQerrorMessage(conn), PQnoPasswordSupplied) == 0 &&
|
||||||
!feof(stdin))
|
!feof(stdin))
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
|
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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')
|
if (password == NULL || *password == '\0')
|
||||||
{
|
{
|
||||||
(void) snprintf(PQerrormsg, PQERRORMSG_LENGTH,
|
(void) snprintf(PQerrormsg, PQERRORMSG_LENGTH,
|
||||||
"fe_sendauth: no password supplied\n");
|
PQnoPasswordSupplied);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
if (pg_password_sendauth(conn, password, areq) != STATUS_OK)
|
if (pg_password_sendauth(conn, password, areq) != STATUS_OK)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 */
|
/* Exists for backward compatibility. bjm 2003-03-24 */
|
||||||
#define PQfreeNotify(ptr) PQfreemem(ptr)
|
#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
|
* Make an empty PGresult with given status (some apps find this
|
||||||
* useful). If conn is not NULL and status indicates an error, the
|
* useful). If conn is not NULL and status indicates an error, the
|
||||||
|
Loading…
Reference in New Issue
Block a user