Skip to content

Commit a99ec2b

Browse files
committed
Have config_sspi_auth() permit IPv6 localhost connections.
Windows versions later than Windows Server 2003 map "localhost" to ::1. Account for that in the generated pg_hba.conf, fixing another oversight in commit f6dc6dd. Back-patch to 9.0, like that commit. David Rowley and Noah Misch
1 parent 8b70023 commit a99ec2b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/test/regress/pg_regress.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ config_sspi_auth(const char *pgdata)
10431043
*domainname;
10441044
char username[128];
10451045
DWORD sz = sizeof(username) - 1;
1046+
bool have_ipv6;
10461047
char fname[MAXPGPATH];
10471048
int res;
10481049
FILE *hba,
@@ -1062,6 +1063,28 @@ config_sspi_auth(const char *pgdata)
10621063
exit(2);
10631064
}
10641065

1066+
/*
1067+
* Like initdb.c:setup_config(), determine whether the platform recognizes
1068+
* ::1 (IPv6 loopback) as a numeric host address string.
1069+
*/
1070+
{
1071+
struct addrinfo *gai_result;
1072+
struct addrinfo hints;
1073+
WSADATA wsaData;
1074+
1075+
hints.ai_flags = AI_NUMERICHOST;
1076+
hints.ai_family = AF_UNSPEC;
1077+
hints.ai_socktype = 0;
1078+
hints.ai_protocol = 0;
1079+
hints.ai_addrlen = 0;
1080+
hints.ai_canonname = NULL;
1081+
hints.ai_addr = NULL;
1082+
hints.ai_next = NULL;
1083+
1084+
have_ipv6 = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0 &&
1085+
getaddrinfo("::1", NULL, &hints, &gai_result) == 0);
1086+
}
1087+
10651088
/* Check a Write outcome and report any error. */
10661089
#define CW(cond) \
10671090
do { \
@@ -1093,6 +1116,9 @@ config_sspi_auth(const char *pgdata)
10931116
CW(fputs("# Configuration written by config_sspi_auth()\n", hba) >= 0);
10941117
CW(fputs("host all all 127.0.0.1/32 sspi include_realm=1 map=regress\n",
10951118
hba) >= 0);
1119+
if (have_ipv6)
1120+
CW(fputs("host all all ::1/128 sspi include_realm=1 map=regress\n",
1121+
hba) >= 0);
10961122
CW(fclose(hba) == 0);
10971123

10981124
snprintf(fname, sizeof(fname), "%s/pg_ident.conf", pgdata);

src/tools/msvc/Mkvcbuild.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ sub mkvcbuild
264264
$pgregress_ecpg->AddIncludeDir('src\test\regress');
265265
$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
266266
$pgregress_ecpg->AddDefine('FRONTEND');
267+
$pgregress_ecpg->AddLibrary('ws2_32.lib');
267268
$pgregress_ecpg->AddReference($libpgport);
268269

269270
# src/bin
@@ -454,6 +455,8 @@ sub mkvcbuild
454455
$pgregress->AddFile('src\test\regress\pg_regress_main.c');
455456
$pgregress->AddIncludeDir('src\port');
456457
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
458+
$pgregress->AddDefine('FRONTEND');
459+
$pgregress->AddLibrary('ws2_32.lib');
457460
$pgregress->AddReference($libpgport);
458461

459462
$solution->Save();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy