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

Commit772a596

Browse files
committed
Summary
The ident() function in src/backend/libpq/hba.c doesn't cope whenpostmaster is contacted on an IP alias. This patch fixes it. Malcolm Beattie
1 parent9b7c6ee commit772a596

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

‎src/backend/libpq/hba.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.35 1998/09/01 04:28:48 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.36 1998/10/02 16:18:20 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -565,6 +565,7 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr,
565565
else
566566
{
567567
structsockaddr_inident_server;
568+
structsockaddr_inla;
568569

569570
/*
570571
* Socket address of Ident server on the system from which client
@@ -573,8 +574,22 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr,
573574
ident_server.sin_family=AF_INET;
574575
ident_server.sin_port=htons(IDENT_PORT);
575576
ident_server.sin_addr=remote_ip_addr;
576-
rc=connect(sock_fd,
577-
(structsockaddr*)&ident_server,sizeof(ident_server));
577+
578+
/*
579+
* Bind to the address which the client originally contacted,
580+
* otherwise the ident server won't be able to match up the
581+
* right connection. This is necessary if the PostgreSQL
582+
* server is running on an IP alias.
583+
*/
584+
memset(&la,0,sizeof(la));
585+
la.sin_family=AF_INET;
586+
la.sin_addr=local_ip_addr;
587+
rc=bind(sock_fd, (structsockaddr*)&la,sizeof(la));
588+
if (rc==0)
589+
{
590+
rc=connect(sock_fd,
591+
(structsockaddr*)&ident_server,sizeof(ident_server));
592+
}
578593
if (rc!=0)
579594
{
580595
sprintf(PQerrormsg,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp