mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	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 f6dc6dd5ba.  Back-patch to 9.0,
like that commit.
David Rowley and Noah Misch
			
			
This commit is contained in:
		@@ -1035,6 +1035,7 @@ config_sspi_auth(const char *pgdata)
 | 
				
			|||||||
			   *domainname;
 | 
								   *domainname;
 | 
				
			||||||
	const char *username;
 | 
						const char *username;
 | 
				
			||||||
	char	   *errstr;
 | 
						char	   *errstr;
 | 
				
			||||||
 | 
						bool		have_ipv6;
 | 
				
			||||||
	char		fname[MAXPGPATH];
 | 
						char		fname[MAXPGPATH];
 | 
				
			||||||
	int			res;
 | 
						int			res;
 | 
				
			||||||
	FILE	   *hba,
 | 
						FILE	   *hba,
 | 
				
			||||||
@@ -1054,6 +1055,28 @@ config_sspi_auth(const char *pgdata)
 | 
				
			|||||||
		exit(2);
 | 
							exit(2);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Like initdb.c:setup_config(), determine whether the platform recognizes
 | 
				
			||||||
 | 
						 * ::1 (IPv6 loopback) as a numeric host address string.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							struct addrinfo *gai_result;
 | 
				
			||||||
 | 
							struct addrinfo hints;
 | 
				
			||||||
 | 
							WSADATA		wsaData;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							hints.ai_flags = AI_NUMERICHOST;
 | 
				
			||||||
 | 
							hints.ai_family = AF_UNSPEC;
 | 
				
			||||||
 | 
							hints.ai_socktype = 0;
 | 
				
			||||||
 | 
							hints.ai_protocol = 0;
 | 
				
			||||||
 | 
							hints.ai_addrlen = 0;
 | 
				
			||||||
 | 
							hints.ai_canonname = NULL;
 | 
				
			||||||
 | 
							hints.ai_addr = NULL;
 | 
				
			||||||
 | 
							hints.ai_next = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							have_ipv6 = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0 &&
 | 
				
			||||||
 | 
										 getaddrinfo("::1", NULL, &hints, &gai_result) == 0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Check a Write outcome and report any error. */
 | 
						/* Check a Write outcome and report any error. */
 | 
				
			||||||
#define CW(cond)	\
 | 
					#define CW(cond)	\
 | 
				
			||||||
	do { \
 | 
						do { \
 | 
				
			||||||
@@ -1085,6 +1108,9 @@ config_sspi_auth(const char *pgdata)
 | 
				
			|||||||
	CW(fputs("# Configuration written by config_sspi_auth()\n", hba) >= 0);
 | 
						CW(fputs("# Configuration written by config_sspi_auth()\n", hba) >= 0);
 | 
				
			||||||
	CW(fputs("host all all 127.0.0.1/32  sspi include_realm=1 map=regress\n",
 | 
						CW(fputs("host all all 127.0.0.1/32  sspi include_realm=1 map=regress\n",
 | 
				
			||||||
			 hba) >= 0);
 | 
								 hba) >= 0);
 | 
				
			||||||
 | 
						if (have_ipv6)
 | 
				
			||||||
 | 
							CW(fputs("host all all ::1/128  sspi include_realm=1 map=regress\n",
 | 
				
			||||||
 | 
									 hba) >= 0);
 | 
				
			||||||
	CW(fclose(hba) == 0);
 | 
						CW(fclose(hba) == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	snprintf(fname, sizeof(fname), "%s/pg_ident.conf", pgdata);
 | 
						snprintf(fname, sizeof(fname), "%s/pg_ident.conf", pgdata);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -331,6 +331,7 @@ sub mkvcbuild
 | 
				
			|||||||
	$pgregress_ecpg->AddIncludeDir('src\test\regress');
 | 
						$pgregress_ecpg->AddIncludeDir('src\test\regress');
 | 
				
			||||||
	$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
 | 
						$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
 | 
				
			||||||
	$pgregress_ecpg->AddDefine('FRONTEND');
 | 
						$pgregress_ecpg->AddDefine('FRONTEND');
 | 
				
			||||||
 | 
						$pgregress_ecpg->AddLibrary('ws2_32.lib');
 | 
				
			||||||
	$pgregress_ecpg->AddReference($libpgcommon, $libpgport);
 | 
						$pgregress_ecpg->AddReference($libpgcommon, $libpgport);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	my $isolation_tester =
 | 
						my $isolation_tester =
 | 
				
			||||||
@@ -356,6 +357,7 @@ sub mkvcbuild
 | 
				
			|||||||
	$pgregress_isolation->AddIncludeDir('src\test\regress');
 | 
						$pgregress_isolation->AddIncludeDir('src\test\regress');
 | 
				
			||||||
	$pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
 | 
						$pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
 | 
				
			||||||
	$pgregress_isolation->AddDefine('FRONTEND');
 | 
						$pgregress_isolation->AddDefine('FRONTEND');
 | 
				
			||||||
 | 
						$pgregress_isolation->AddLibrary('ws2_32.lib');
 | 
				
			||||||
	$pgregress_isolation->AddReference($libpgcommon, $libpgport);
 | 
						$pgregress_isolation->AddReference($libpgcommon, $libpgport);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# src/bin
 | 
						# src/bin
 | 
				
			||||||
@@ -594,6 +596,8 @@ sub mkvcbuild
 | 
				
			|||||||
	$pgregress->AddFile('src\test\regress\pg_regress_main.c');
 | 
						$pgregress->AddFile('src\test\regress\pg_regress_main.c');
 | 
				
			||||||
	$pgregress->AddIncludeDir('src\port');
 | 
						$pgregress->AddIncludeDir('src\port');
 | 
				
			||||||
	$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
 | 
						$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
 | 
				
			||||||
 | 
						$pgregress->AddDefine('FRONTEND');
 | 
				
			||||||
 | 
						$pgregress->AddLibrary('ws2_32.lib');
 | 
				
			||||||
	$pgregress->AddReference($libpgcommon, $libpgport);
 | 
						$pgregress->AddReference($libpgcommon, $libpgport);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# fix up pg_xlogdump once it's been set up
 | 
						# fix up pg_xlogdump once it's been set up
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user