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

Commitcb7fb3c

Browse files
committed
First phase of FE/BE protocol modifications: new StartupPacket layout
with variable-width fields. No more truncation of long user names.Also, libpq can now send its environment-variable-driven SET commandsas part of the startup packet, saving round trips to server.
1 parent76fd678 commitcb7fb3c

File tree

16 files changed

+436
-300
lines changed

16 files changed

+436
-300
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.117 2003/03/25 16:15:37 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.118 2003/04/17 22:26:00 tgl Exp $
33
-->
44

55
<chapter id="libpq">
@@ -193,7 +193,7 @@ PGconn *PQconnectdb(const char *conninfo);
193193
<term><literal>tty</literal></term>
194194
<listitem>
195195
<para>
196-
A file or <acronym>TTY</acronym> for optional debug output from the server.
196+
Ignored (formerly, this specified where to send server debug output).
197197
</para>
198198
</listitem>
199199
</varlistentry>
@@ -669,6 +669,9 @@ char *PQport(const PGconn *conn);
669669
<listitem>
670670
<para>
671671
Returns the debug <acronym>TTY</acronym> of the connection.
672+
(This is obsolete, since the server no longer pays attention
673+
to the <acronym>TTY</acronym> setting, but the function remains
674+
for backwards compatibility.)
672675
<synopsis>
673676
char *PQtty(const PGconn *conn);
674677
</synopsis>
@@ -2365,12 +2368,6 @@ the <productname>PostgreSQL</productname> server.
23652368
</listitem>
23662369
<listitem>
23672370
<para>
2368-
<envar>PGTTY</envar> sets the file or <acronym>TTY</> on which debugging
2369-
messages from the server are displayed.
2370-
</para>
2371-
</listitem>
2372-
<listitem>
2373-
<para>
23742371
<envar>PGREQUIRESSL</envar> sets whether or not the connection must be
23752372
made over <acronym>SSL</acronym>. If set to
23762373
<quote>1</quote>, <application>libpq</>
@@ -2678,7 +2675,7 @@ main()
26782675
pgport = NULL; /* port of the backend server */
26792676
pgoptions = NULL; /* special options to start up the backend
26802677
* server */
2681-
pgtty = NULL; /*debugging tty for the backend server */
2678+
pgtty = NULL; /*unused */
26822679
dbName = "template1";
26832680

26842681
/* make a connection to the database */
@@ -2826,7 +2823,7 @@ main()
28262823
pgport = NULL; /* port of the backend server */
28272824
pgoptions = NULL; /* special options to start up the backend
28282825
* server */
2829-
pgtty = NULL; /*debugging tty for the backend server */
2826+
pgtty = NULL; /*unused */
28302827
dbName = getenv("USER"); /* change this to the name of your test
28312828
* database */
28322829

@@ -2950,7 +2947,7 @@ main()
29502947
pgport = NULL; /* port of the backend server */
29512948
pgoptions = NULL; /* special options to start up the backend
29522949
* server */
2953-
pgtty = NULL; /*debugging tty for the backend server */
2950+
pgtty = NULL; /*unused */
29542951

29552952
dbName = getenv("USER"); /* change this to the name of your test
29562953
* database */

‎src/backend/libpq/auth.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.97 2003/02/14 14:05:00 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.98 2003/04/17 22:26:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -29,7 +29,6 @@
2929
#include"libpq/crypt.h"
3030
#include"libpq/hba.h"
3131
#include"libpq/libpq.h"
32-
#include"libpq/password.h"
3332
#include"libpq/pqcomm.h"
3433
#include"libpq/pqformat.h"
3534
#include"miscadmin.h"
@@ -378,7 +377,7 @@ auth_failed(Port *port, int status)
378377
}
379378

380379
elog(FATAL,"%s authentication failed for user \"%s\"",
381-
authmethod,port->user);
380+
authmethod,port->user_name);
382381
/* doesn't return */
383382
}
384383

@@ -427,7 +426,7 @@ ClientAuthentication(Port *port)
427426

428427
elog(FATAL,
429428
"No pg_hba.conf entry for host %s, user %s, database %s",
430-
hostinfo,port->user,port->database);
429+
hostinfo,port->user_name,port->database_name);
431430
break;
432431
}
433432

@@ -638,10 +637,12 @@ CheckPAMAuth(Port *port, char *user, char *password)
638637
* not allocated */
639638

640639
/* Optionally, one can set the service name in pg_hba.conf */
641-
if (port->auth_arg[0]=='\0')
642-
retval=pam_start(PGSQL_PAM_SERVICE,"pgsql@",&pam_passw_conv,&pamh);
640+
if (port->auth_arg&&port->auth_arg[0]!='\0')
641+
retval=pam_start(port->auth_arg,"pgsql@",
642+
&pam_passw_conv,&pamh);
643643
else
644-
retval=pam_start(port->auth_arg,"pgsql@",&pam_passw_conv,&pamh);
644+
retval=pam_start(PGSQL_PAM_SERVICE,"pgsql@",
645+
&pam_passw_conv,&pamh);
645646

646647
if (retval!=PAM_SUCCESS)
647648
{
@@ -741,7 +742,7 @@ recv_and_check_password_packet(Port *port)
741742
/* Do not echo password to logs, for security. */
742743
elog(DEBUG5,"received password packet");
743744

744-
result=md5_crypt_verify(port,port->user,buf.data);
745+
result=md5_crypt_verify(port,port->user_name,buf.data);
745746

746747
pfree(buf.data);
747748
returnresult;

‎src/backend/libpq/crypt.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.51 2002/12/05 18:52:42 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.52 2003/04/17 22:26:01 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -87,15 +87,19 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass)
8787
/* pg_shadow plain, double-encrypt */
8888
char*crypt_pwd2=palloc(MD5_PASSWD_LEN+1);
8989

90-
if (!EncryptMD5(shadow_pass,port->user,strlen(port->user),
90+
if (!EncryptMD5(shadow_pass,
91+
port->user_name,
92+
strlen(port->user_name),
9193
crypt_pwd2))
9294
{
9395
pfree(crypt_pwd);
9496
pfree(crypt_pwd2);
9597
returnSTATUS_ERROR;
9698
}
97-
if (!EncryptMD5(crypt_pwd2+strlen("md5"),port->md5Salt,
98-
sizeof(port->md5Salt),crypt_pwd))
99+
if (!EncryptMD5(crypt_pwd2+strlen("md5"),
100+
port->md5Salt,
101+
sizeof(port->md5Salt),
102+
crypt_pwd))
99103
{
100104
pfree(crypt_pwd);
101105
pfree(crypt_pwd2);
@@ -117,7 +121,9 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass)
117121
{
118122
/* Encrypt user-supplied password to match MD5 in pg_shadow */
119123
crypt_client_pass=palloc(MD5_PASSWD_LEN+1);
120-
if (!EncryptMD5(client_pass,port->user,strlen(port->user),
124+
if (!EncryptMD5(client_pass,
125+
port->user_name,
126+
strlen(port->user_name),
121127
crypt_client_pass))
122128
{
123129
pfree(crypt_client_pass);

‎src/backend/libpq/hba.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.98 2003/04/13 04:07:17 tgl Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.99 2003/04/17 22:26:01 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -471,15 +471,17 @@ check_db(char *dbname, char *user, char *param_str)
471471

472472
/*
473473
*Scan the rest of a host record (after the mask field)
474-
*and return the interpretation of it as *userauth_p,auth_arg, and
474+
*and return the interpretation of it as *userauth_p,*auth_arg_p, and
475475
**error_p. line points to the next token of the line.
476476
*/
477477
staticvoid
478-
parse_hba_auth(List*line,UserAuth*userauth_p,char*auth_arg,
478+
parse_hba_auth(List*line,UserAuth*userauth_p,char**auth_arg_p,
479479
bool*error_p)
480480
{
481481
char*token;
482482

483+
*auth_arg_p=NULL;
484+
483485
if (!line)
484486
*error_p= true;
485487
else
@@ -514,11 +516,10 @@ parse_hba_auth(List *line, UserAuth *userauth_p, char *auth_arg,
514516
if (!*error_p)
515517
{
516518
/* Get the authentication argument token, if any */
517-
if (!line)
518-
auth_arg[0]='\0';
519-
else
519+
if (line)
520520
{
521-
StrNCpy(auth_arg,lfirst(line),MAX_AUTH_ARG-1);
521+
token=lfirst(line);
522+
*auth_arg_p=pstrdup(token);
522523
/* If there is more on the line, it is an error */
523524
if (lnext(line))
524525
*error_p= true;
@@ -570,7 +571,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
570571
gotohba_syntax;
571572

572573
/* Read the rest of the line. */
573-
parse_hba_auth(line,&port->auth_method,port->auth_arg,error_p);
574+
parse_hba_auth(line,&port->auth_method,&port->auth_arg,error_p);
574575
if (*error_p)
575576
gotohba_syntax;
576577

@@ -642,7 +643,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
642643
line=lnext(line);
643644
if (!line)
644645
gotohba_syntax;
645-
parse_hba_auth(line,&port->auth_method,port->auth_arg,error_p);
646+
parse_hba_auth(line,&port->auth_method,&port->auth_arg,error_p);
646647
if (*error_p)
647648
gotohba_syntax;
648649

@@ -654,9 +655,9 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
654655
else
655656
gotohba_syntax;
656657

657-
if (!check_db(port->database,port->user,db))
658+
if (!check_db(port->database_name,port->user_name,db))
658659
return;
659-
if (!check_user(port->user,user))
660+
if (!check_user(port->user_name,user))
660661
return;
661662

662663
/* Success */
@@ -946,7 +947,7 @@ check_ident_usermap(const char *usermap_name,
946947
boolfound_entry= false,
947948
error= false;
948949

949-
if (usermap_name[0]=='\0')
950+
if (usermap_name==NULL||usermap_name[0]=='\0')
950951
{
951952
elog(LOG,"check_ident_usermap: hba configuration file does not "
952953
"have the usermap field filled in in the entry that pertains "
@@ -1387,7 +1388,7 @@ authident(hbaPort *port)
13871388
returnSTATUS_ERROR;
13881389
}
13891390

1390-
if (check_ident_usermap(port->auth_arg,port->user,ident_user))
1391+
if (check_ident_usermap(port->auth_arg,port->user_name,ident_user))
13911392
returnSTATUS_OK;
13921393
else
13931394
returnSTATUS_ERROR;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp