Skip to content

Commit 7bb78b2

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 5c86658 commit 7bb78b2

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/test/regress/pg_regress.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ config_sspi_auth(const char *pgdata)
10391039
*domainname;
10401040
char username[128];
10411041
DWORD sz = sizeof(username) - 1;
1042+
bool have_ipv6;
10421043
char fname[MAXPGPATH];
10431044
int res;
10441045
FILE *hba,
@@ -1058,6 +1059,28 @@ config_sspi_auth(const char *pgdata)
10581059
exit(2);
10591060
}
10601061

1062+
/*
1063+
* Like initdb.c:setup_config(), determine whether the platform recognizes
1064+
* ::1 (IPv6 loopback) as a numeric host address string.
1065+
*/
1066+
{
1067+
struct addrinfo *gai_result;
1068+
struct addrinfo hints;
1069+
WSADATA wsaData;
1070+
1071+
hints.ai_flags = AI_NUMERICHOST;
1072+
hints.ai_family = AF_UNSPEC;
1073+
hints.ai_socktype = 0;
1074+
hints.ai_protocol = 0;
1075+
hints.ai_addrlen = 0;
1076+
hints.ai_canonname = NULL;
1077+
hints.ai_addr = NULL;
1078+
hints.ai_next = NULL;
1079+
1080+
have_ipv6 = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0 &&
1081+
getaddrinfo("::1", NULL, &hints, &gai_result) == 0);
1082+
}
1083+
10611084
/* Check a Write outcome and report any error. */
10621085
#define CW(cond) \
10631086
do { \
@@ -1089,6 +1112,9 @@ config_sspi_auth(const char *pgdata)
10891112
CW(fputs("# Configuration written by config_sspi_auth()\n", hba) >= 0);
10901113
CW(fputs("host all all 127.0.0.1/32 sspi include_realm=1 map=regress\n",
10911114
hba) >= 0);
1115+
if (have_ipv6)
1116+
CW(fputs("host all all ::1/128 sspi include_realm=1 map=regress\n",
1117+
hba) >= 0);
10921118
CW(fclose(hba) == 0);
10931119

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

src/tools/msvc/Mkvcbuild.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ sub mkvcbuild
307307
$pgregress_ecpg->AddIncludeDir('src\test\regress');
308308
$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
309309
$pgregress_ecpg->AddDefine('FRONTEND');
310+
$pgregress_ecpg->AddLibrary('ws2_32.lib');
310311
$pgregress_ecpg->AddReference($libpgport);
311312

312313
my $isolation_tester =
@@ -332,6 +333,7 @@ sub mkvcbuild
332333
$pgregress_isolation->AddIncludeDir('src\test\regress');
333334
$pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
334335
$pgregress_isolation->AddDefine('FRONTEND');
336+
$pgregress_isolation->AddLibrary('ws2_32.lib');
335337
$pgregress_isolation->AddReference($libpgport);
336338

337339
# src/bin
@@ -561,6 +563,8 @@ sub mkvcbuild
561563
$pgregress->AddFile('src\test\regress\pg_regress_main.c');
562564
$pgregress->AddIncludeDir('src\port');
563565
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
566+
$pgregress->AddDefine('FRONTEND');
567+
$pgregress->AddLibrary('ws2_32.lib');
564568
$pgregress->AddReference($libpgport);
565569

566570
$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