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

Commitd330f15

Browse files
committed
Clean up libpq's pollution of application namespace by renaming the
exported routines of ip.c, md5.c, and fe-auth.c to begin with 'pg_'.Also get rid of the vestigial fe_setauthsvc/fe_getauthsvc routinesaltogether.
1 parent8ffdcbf commitd330f15

File tree

19 files changed

+237
-375
lines changed

19 files changed

+237
-375
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.193 2005/10/13 17:55:18momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.194 2005/10/17 16:24:18tgl Exp $
33
-->
44

55
<chapter id="libpq">
@@ -4049,15 +4049,13 @@ passed around freely between threads.
40494049

40504050
<para>
40514051
The deprecated functions
4052-
<function>PQrequestCancel</function>,
4053-
<function>PQoidStatus</function> and
4054-
<function>fe_setauthsvc</function>
4052+
<function>PQrequestCancel</function> and
4053+
<function>PQoidStatus</function>
40554054
are not thread-safe and should not be used in multithread programs.
40564055
<function>PQrequestCancel</function> can be replaced by
40574056
<function>PQcancel</function>.
40584057
<function>PQoidStatus</function> can be replaced by
40594058
<function>PQoidValue</function>.
4060-
There is no good reason to call <function>fe_setauthsvc</function> at all.
40614059
</para>
40624060

40634061
<para>

‎src/backend/commands/user.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.161 2005/10/15 02:49:16 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.162 2005/10/17 16:24:18 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -313,8 +313,8 @@ CreateRole(CreateRoleStmt *stmt)
313313
DirectFunctionCall1(textin,CStringGetDatum(password));
314314
else
315315
{
316-
if (!EncryptMD5(password,stmt->role,strlen(stmt->role),
317-
encrypted_password))
316+
if (!pg_md5_encrypt(password,stmt->role,strlen(stmt->role),
317+
encrypted_password))
318318
elog(ERROR,"password encryption failed");
319319
new_record[Anum_pg_authid_rolpassword-1]=
320320
DirectFunctionCall1(textin,CStringGetDatum(encrypted_password));
@@ -642,8 +642,8 @@ AlterRole(AlterRoleStmt *stmt)
642642
DirectFunctionCall1(textin,CStringGetDatum(password));
643643
else
644644
{
645-
if (!EncryptMD5(password,stmt->role,strlen(stmt->role),
646-
encrypted_password))
645+
if (!pg_md5_encrypt(password,stmt->role,strlen(stmt->role),
646+
encrypted_password))
647647
elog(ERROR,"password encryption failed");
648648
new_record[Anum_pg_authid_rolpassword-1]=
649649
DirectFunctionCall1(textin,CStringGetDatum(encrypted_password));

‎src/backend/libpq/auth.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.131 2005/10/15 21:27:19momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.132 2005/10/17 16:24:19tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -376,10 +376,10 @@ ClientAuthentication(Port *port)
376376
{
377377
charhostinfo[NI_MAXHOST];
378378

379-
getnameinfo_all(&port->raddr.addr,port->raddr.salen,
380-
hostinfo,sizeof(hostinfo),
381-
NULL,0,
382-
NI_NUMERICHOST);
379+
pg_getnameinfo_all(&port->raddr.addr,port->raddr.salen,
380+
hostinfo,sizeof(hostinfo),
381+
NULL,0,
382+
NI_NUMERICHOST);
383383

384384
#ifdefUSE_SSL
385385
ereport(FATAL,

‎src/backend/libpq/crypt.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.66 2005/10/15 02:49:17 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.67 2005/10/17 16:24:19 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -76,9 +76,9 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
7676
if (isMD5(shadow_pass))
7777
{
7878
/* stored password already encrypted, only do salt */
79-
if (!EncryptMD5(shadow_pass+strlen("md5"),
80-
(char*)port->md5Salt,
81-
sizeof(port->md5Salt),crypt_pwd))
79+
if (!pg_md5_encrypt(shadow_pass+strlen("md5"),
80+
(char*)port->md5Salt,
81+
sizeof(port->md5Salt),crypt_pwd))
8282
{
8383
pfree(crypt_pwd);
8484
returnSTATUS_ERROR;
@@ -89,19 +89,19 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
8989
/* stored password is plain, double-encrypt */
9090
char*crypt_pwd2=palloc(MD5_PASSWD_LEN+1);
9191

92-
if (!EncryptMD5(shadow_pass,
93-
port->user_name,
94-
strlen(port->user_name),
95-
crypt_pwd2))
92+
if (!pg_md5_encrypt(shadow_pass,
93+
port->user_name,
94+
strlen(port->user_name),
95+
crypt_pwd2))
9696
{
9797
pfree(crypt_pwd);
9898
pfree(crypt_pwd2);
9999
returnSTATUS_ERROR;
100100
}
101-
if (!EncryptMD5(crypt_pwd2+strlen("md5"),
102-
port->md5Salt,
103-
sizeof(port->md5Salt),
104-
crypt_pwd))
101+
if (!pg_md5_encrypt(crypt_pwd2+strlen("md5"),
102+
port->md5Salt,
103+
sizeof(port->md5Salt),
104+
crypt_pwd))
105105
{
106106
pfree(crypt_pwd);
107107
pfree(crypt_pwd2);
@@ -123,10 +123,10 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
123123
{
124124
/* Encrypt user-supplied password to match stored MD5 */
125125
crypt_client_pass=palloc(MD5_PASSWD_LEN+1);
126-
if (!EncryptMD5(client_pass,
127-
port->user_name,
128-
strlen(port->user_name),
129-
crypt_client_pass))
126+
if (!pg_md5_encrypt(client_pass,
127+
port->user_name,
128+
strlen(port->user_name),
129+
crypt_client_pass))
130130
{
131131
pfree(crypt_client_pass);
132132
returnSTATUS_ERROR;

‎src/backend/libpq/hba.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.148 2005/10/15 02:49:17 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.149 2005/10/17 16:24:19 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -756,7 +756,7 @@ parse_hba(List *line, int line_num, hbaPort *port,
756756
hints.ai_addr=NULL;
757757
hints.ai_next=NULL;
758758

759-
ret=getaddrinfo_all(token,NULL,&hints,&gai_result);
759+
ret=pg_getaddrinfo_all(token,NULL,&hints,&gai_result);
760760
if (ret|| !gai_result)
761761
{
762762
ereport(LOG,
@@ -767,20 +767,21 @@ parse_hba(List *line, int line_num, hbaPort *port,
767767
if (cidr_slash)
768768
*cidr_slash='/';
769769
if (gai_result)
770-
freeaddrinfo_all(hints.ai_family,gai_result);
770+
pg_freeaddrinfo_all(hints.ai_family,gai_result);
771771
gotohba_other_error;
772772
}
773773

774774
if (cidr_slash)
775775
*cidr_slash='/';
776776

777777
memcpy(&addr,gai_result->ai_addr,gai_result->ai_addrlen);
778-
freeaddrinfo_all(hints.ai_family,gai_result);
778+
pg_freeaddrinfo_all(hints.ai_family,gai_result);
779779

780780
/* Get the netmask */
781781
if (cidr_slash)
782782
{
783-
if (SockAddr_cidr_mask(&mask,cidr_slash+1,addr.ss_family)<0)
783+
if (pg_sockaddr_cidr_mask(&mask,cidr_slash+1,
784+
addr.ss_family)<0)
784785
gotohba_syntax;
785786
}
786787
else
@@ -791,7 +792,7 @@ parse_hba(List *line, int line_num, hbaPort *port,
791792
gotohba_syntax;
792793
token=lfirst(line_item);
793794

794-
ret=getaddrinfo_all(token,NULL,&hints,&gai_result);
795+
ret=pg_getaddrinfo_all(token,NULL,&hints,&gai_result);
795796
if (ret|| !gai_result)
796797
{
797798
ereport(LOG,
@@ -800,12 +801,12 @@ parse_hba(List *line, int line_num, hbaPort *port,
800801
token,HbaFileName,line_num,
801802
gai_strerror(ret))));
802803
if (gai_result)
803-
freeaddrinfo_all(hints.ai_family,gai_result);
804+
pg_freeaddrinfo_all(hints.ai_family,gai_result);
804805
gotohba_other_error;
805806
}
806807

807808
memcpy(&mask,gai_result->ai_addr,gai_result->ai_addrlen);
808-
freeaddrinfo_all(hints.ai_family,gai_result);
809+
pg_freeaddrinfo_all(hints.ai_family,gai_result);
809810

810811
if (addr.ss_family!=mask.ss_family)
811812
{
@@ -828,8 +829,8 @@ parse_hba(List *line, int line_num, hbaPort *port,
828829
if (addr.ss_family==AF_INET&&
829830
port->raddr.addr.ss_family==AF_INET6)
830831
{
831-
promote_v4_to_v6_addr(&addr);
832-
promote_v4_to_v6_mask(&mask);
832+
pg_promote_v4_to_v6_addr(&addr);
833+
pg_promote_v4_to_v6_mask(&mask);
833834
}
834835
else
835836
#endif/* HAVE_IPV6 */
@@ -840,7 +841,7 @@ parse_hba(List *line, int line_num, hbaPort *port,
840841
}
841842

842843
/* Ignore line if client port is not in the matching addr range. */
843-
if (!rangeSockAddr(&port->raddr.addr,&addr,&mask))
844+
if (!pg_range_sockaddr(&port->raddr.addr,&addr,&mask))
844845
return;
845846

846847
/* Read the rest of the line. */
@@ -1296,14 +1297,14 @@ ident_inet(const SockAddr remote_addr,
12961297
* Might look a little weird to first convert it to text and then back to
12971298
* sockaddr, but it's protocol independent.
12981299
*/
1299-
getnameinfo_all(&remote_addr.addr,remote_addr.salen,
1300-
remote_addr_s,sizeof(remote_addr_s),
1301-
remote_port,sizeof(remote_port),
1302-
NI_NUMERICHOST |NI_NUMERICSERV);
1303-
getnameinfo_all(&local_addr.addr,local_addr.salen,
1304-
local_addr_s,sizeof(local_addr_s),
1305-
local_port,sizeof(local_port),
1306-
NI_NUMERICHOST |NI_NUMERICSERV);
1300+
pg_getnameinfo_all(&remote_addr.addr,remote_addr.salen,
1301+
remote_addr_s,sizeof(remote_addr_s),
1302+
remote_port,sizeof(remote_port),
1303+
NI_NUMERICHOST |NI_NUMERICSERV);
1304+
pg_getnameinfo_all(&local_addr.addr,local_addr.salen,
1305+
local_addr_s,sizeof(local_addr_s),
1306+
local_port,sizeof(local_port),
1307+
NI_NUMERICHOST |NI_NUMERICSERV);
13071308

13081309
snprintf(ident_port,sizeof(ident_port),"%d",IDENT_PORT);
13091310
hints.ai_flags=AI_NUMERICHOST;
@@ -1314,11 +1315,11 @@ ident_inet(const SockAddr remote_addr,
13141315
hints.ai_canonname=NULL;
13151316
hints.ai_addr=NULL;
13161317
hints.ai_next=NULL;
1317-
rc=getaddrinfo_all(remote_addr_s,ident_port,&hints,&ident_serv);
1318+
rc=pg_getaddrinfo_all(remote_addr_s,ident_port,&hints,&ident_serv);
13181319
if (rc|| !ident_serv)
13191320
{
13201321
if (ident_serv)
1321-
freeaddrinfo_all(hints.ai_family,ident_serv);
1322+
pg_freeaddrinfo_all(hints.ai_family,ident_serv);
13221323
return false;/* we don't expect this to happen */
13231324
}
13241325

@@ -1330,11 +1331,11 @@ ident_inet(const SockAddr remote_addr,
13301331
hints.ai_canonname=NULL;
13311332
hints.ai_addr=NULL;
13321333
hints.ai_next=NULL;
1333-
rc=getaddrinfo_all(local_addr_s,NULL,&hints,&la);
1334+
rc=pg_getaddrinfo_all(local_addr_s,NULL,&hints,&la);
13341335
if (rc|| !la)
13351336
{
13361337
if (la)
1337-
freeaddrinfo_all(hints.ai_family,la);
1338+
pg_freeaddrinfo_all(hints.ai_family,la);
13381339
return false;/* we don't expect this to happen */
13391340
}
13401341

@@ -1422,8 +1423,8 @@ ident_inet(const SockAddr remote_addr,
14221423
ident_inet_done:
14231424
if (sock_fd >=0)
14241425
closesocket(sock_fd);
1425-
freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1426-
freeaddrinfo_all(local_addr.addr.ss_family,la);
1426+
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1427+
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
14271428
returnident_return;
14281429
}
14291430

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp