Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit88fd162

Browse files
committed
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
1 parent9ffc8ed commit88fd162

File tree

8 files changed

+22
-17
lines changed

8 files changed

+22
-17
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.38 2004/10/15 04:54:33 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.39 2004/10/16 03:10:14 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -364,7 +364,6 @@ test_postmaster_connection(void)
364364
charportstr[32];
365365
char*p;
366366

367-
368367
*portstr='\0';
369368

370369
/* post_opts */
@@ -432,7 +431,9 @@ test_postmaster_connection(void)
432431
{
433432
if ((conn=PQsetdbLogin(NULL,portstr,NULL,NULL,
434433
"template1",NULL,NULL))!=NULL&&
435-
PQstatus(conn)==CONNECTION_OK)
434+
(PQstatus(conn)==CONNECTION_OK||
435+
(strcmp(PQerrorMessage(conn),
436+
PQnoPasswordSupplied)==0)))
436437
{
437438
PQfinish(conn);
438439
success= true;

‎src/bin/pg_dump/pg_backup_db.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*Implements the basic DB functions used by the archiver.
66
*
77
* IDENTIFICATION
8-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.59 2004/10/01 17:25:55 tgl Exp $
8+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.60 2004/10/16 03:10:15 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -168,7 +168,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
168168
if (PQstatus(newConn)==CONNECTION_BAD)
169169
{
170170
noPwd= (strcmp(PQerrorMessage(newConn),
171-
"fe_sendauth: no password supplied\n")==0);
171+
PQnoPasswordSupplied)==0);
172172
badPwd= (strncmp(PQerrorMessage(newConn),
173173
"Password authentication failed for user",39)==0);
174174

@@ -249,7 +249,7 @@ ConnectDatabase(Archive *AHX,
249249
die_horribly(AH,modulename,"failed to connect to database\n");
250250

251251
if (PQstatus(AH->connection)==CONNECTION_BAD&&
252-
strcmp(PQerrorMessage(AH->connection),"fe_sendauth: no password supplied\n")==0&&
252+
strcmp(PQerrorMessage(AH->connection),PQnoPasswordSupplied)==0&&
253253
!feof(stdin))
254254
{
255255
PQfinish(AH->connection);

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.53 2004/10/15 04:32:28 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.54 2004/10/16 03:10:15 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -957,7 +957,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
957957
}
958958

959959
if (PQstatus(conn)==CONNECTION_BAD&&
960-
strcmp(PQerrorMessage(conn),"fe_sendauth: no password supplied\n")==0&&
960+
strcmp(PQerrorMessage(conn),PQnoPasswordSupplied)==0&&
961961
!feof(stdin))
962962
{
963963
PQfinish(conn);

‎src/bin/psql/command.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.128 2004/10/14 20:23:46 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.129 2004/10/16 03:10:16 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -929,7 +929,7 @@ do_connect(const char *new_dbname, const char *new_user)
929929
NULL,NULL,dbparam,userparam,pwparam);
930930

931931
if (PQstatus(pset.db)==CONNECTION_BAD&&
932-
strcmp(PQerrorMessage(pset.db),"fe_sendauth: no password supplied\n")==0&&
932+
strcmp(PQerrorMessage(pset.db),PQnoPasswordSupplied)==0&&
933933
!feof(stdin))
934934
{
935935
PQfinish(pset.db);

‎src/bin/psql/startup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.103 2004/10/08 11:24:19 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.104 2004/10/16 03:10:16 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -195,7 +195,7 @@ main(int argc, char *argv[])
195195
username,password);
196196

197197
if (PQstatus(pset.db)==CONNECTION_BAD&&
198-
strcmp(PQerrorMessage(pset.db),"fe_sendauth: no password supplied\n")==0&&
198+
strcmp(PQerrorMessage(pset.db),PQnoPasswordSupplied)==0&&
199199
!feof(stdin))
200200
{
201201
PQfinish(pset.db);

‎src/bin/scripts/common.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.11 2004/08/29 05:06:54 momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.12 2004/10/16 03:10:16 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
1212

1313
#include"postgres_fe.h"
1414
#include"common.h"
15+
#include"libpq-fe.h"
1516

1617
#include<pwd.h>
1718
#include<unistd.h>
@@ -102,7 +103,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
102103
}
103104

104105
if (PQstatus(conn)==CONNECTION_BAD&&
105-
strcmp(PQerrorMessage(conn),"fe_sendauth: no password supplied\n")==0&&
106+
strcmp(PQerrorMessage(conn),PQnoPasswordSupplied)==0&&
106107
!feof(stdin))
107108
{
108109
PQfinish(conn);

‎src/interfaces/libpq/fe-auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.93 2004/09/28 00:06:02 momjian Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.94 2004/10/16 03:10:17 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -634,7 +634,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
634634
if (password==NULL||*password=='\0')
635635
{
636636
(void)snprintf(PQerrormsg,PQERRORMSG_LENGTH,
637-
"fe_sendauth: no password supplied\n");
637+
PQnoPasswordSupplied);
638638
returnSTATUS_ERROR;
639639
}
640640
if (pg_password_sendauth(conn,password,areq)!=STATUS_OK)

‎src/interfaces/libpq/libpq-fe.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.108 2004/08/29 05:07:00 momjian Exp $
10+
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.109 2004/10/16 03:10:17 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -398,6 +398,9 @@ extern void PQfreemem(void *ptr);
398398
/* Exists for backward compatibility. bjm 2003-03-24 */
399399
#definePQfreeNotify(ptr) PQfreemem(ptr)
400400

401+
/* Define the string so all uses are consistent. */
402+
#definePQnoPasswordSupplied"fe_sendauth: no password supplied\n"
403+
401404
/*
402405
* Make an empty PGresult with given status (some apps find this
403406
* useful). If conn is not NULL and status indicates an error, the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp