Skip to content

Commit 5bd5968

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 0190f0a commit 5bd5968

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
@@ -1040,6 +1040,7 @@ config_sspi_auth(const char *pgdata)
10401040
*domainname;
10411041
char username[128];
10421042
DWORD sz = sizeof(username) - 1;
1043+
bool have_ipv6;
10431044
char fname[MAXPGPATH];
10441045
int res;
10451046
FILE *hba,
@@ -1059,6 +1060,28 @@ config_sspi_auth(const char *pgdata)
10591060
exit(2);
10601061
}
10611062

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

10951121
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
@@ -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($libpgport, $libpgcommon);
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($libpgport, $libpgcommon);
360362

361363
# src/bin
@@ -589,6 +591,8 @@ sub mkvcbuild
589591
$pgregress->AddFile('src\test\regress\pg_regress_main.c');
590592
$pgregress->AddIncludeDir('src\port');
591593
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
594+
$pgregress->AddDefine('FRONTEND');
595+
$pgregress->AddLibrary('ws2_32.lib');
592596
$pgregress->AddReference($libpgport, $libpgcommon);
593597

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

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