Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a472b55

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 6ac1c52 commit a472b55

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/test/regress/pg_regress.c

+26
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ config_sspi_auth(const char *pgdata)
10351035
*domainname;
10361036
const char *username;
10371037
char *errstr;
1038+
bool have_ipv6;
10381039
char fname[MAXPGPATH];
10391040
int res;
10401041
FILE *hba,
@@ -1054,6 +1055,28 @@ config_sspi_auth(const char *pgdata)
10541055
exit(2);
10551056
}
10561057

1058+
/*
1059+
* Like initdb.c:setup_config(), determine whether the platform recognizes
1060+
* ::1 (IPv6 loopback) as a numeric host address string.
1061+
*/
1062+
{
1063+
struct addrinfo *gai_result;
1064+
struct addrinfo hints;
1065+
WSADATA wsaData;
1066+
1067+
hints.ai_flags = AI_NUMERICHOST;
1068+
hints.ai_family = AF_UNSPEC;
1069+
hints.ai_socktype = 0;
1070+
hints.ai_protocol = 0;
1071+
hints.ai_addrlen = 0;
1072+
hints.ai_canonname = NULL;
1073+
hints.ai_addr = NULL;
1074+
hints.ai_next = NULL;
1075+
1076+
have_ipv6 = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0 &&
1077+
getaddrinfo("::1", NULL, &hints, &gai_result) == 0);
1078+
}
1079+
10571080
/* Check a Write outcome and report any error. */
10581081
#define CW(cond) \
10591082
do { \
@@ -1085,6 +1108,9 @@ config_sspi_auth(const char *pgdata)
10851108
CW(fputs("# Configuration written by config_sspi_auth()\n", hba) >= 0);
10861109
CW(fputs("host all all 127.0.0.1/32 sspi include_realm=1 map=regress\n",
10871110
hba) >= 0);
1111+
if (have_ipv6)
1112+
CW(fputs("host all all ::1/128 sspi include_realm=1 map=regress\n",
1113+
hba) >= 0);
10881114
CW(fclose(hba) == 0);
10891115

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

src/tools/msvc/Mkvcbuild.pm

+4
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ sub mkvcbuild
331331
$pgregress_ecpg->AddIncludeDir('src\test\regress');
332332
$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
333333
$pgregress_ecpg->AddDefine('FRONTEND');
334+
$pgregress_ecpg->AddLibrary('ws2_32.lib');
334335
$pgregress_ecpg->AddReference($libpgcommon, $libpgport);
335336

336337
my $isolation_tester =
@@ -356,6 +357,7 @@ sub mkvcbuild
356357
$pgregress_isolation->AddIncludeDir('src\test\regress');
357358
$pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
358359
$pgregress_isolation->AddDefine('FRONTEND');
360+
$pgregress_isolation->AddLibrary('ws2_32.lib');
359361
$pgregress_isolation->AddReference($libpgcommon, $libpgport);
360362

361363
# src/bin
@@ -594,6 +596,8 @@ sub mkvcbuild
594596
$pgregress->AddFile('src\test\regress\pg_regress_main.c');
595597
$pgregress->AddIncludeDir('src\port');
596598
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
599+
$pgregress->AddDefine('FRONTEND');
600+
$pgregress->AddLibrary('ws2_32.lib');
597601
$pgregress->AddReference($libpgcommon, $libpgport);
598602

599603
# fix up pg_xlogdump once it's been set up

0 commit comments

Comments
 (0)