Skip to content

Commit 24379a4

Browse files
committed
Don't connect() to a wildcard address in test_postmaster_connection().
At least OpenBSD, NetBSD, and Windows don't support it. This repairs pg_ctl for listen_addresses='0.0.0.0' and listen_addresses='::'. Since pg_ctl prefers to test a Unix-domain socket, Windows users are most likely to need this change. Back-patch to 9.1 (all supported versions). This could change pg_ctl interaction with loopback-interface firewall rules. Therefore, in 9.4 and earlier (released branches), activate the change only on known-affected platforms. Reported (bug #13611) and designed by Kondo Yuta.
1 parent f69c01f commit 24379a4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/bin/pg_ctl/pg_ctl.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,22 @@ test_postmaster_connection(pgpid_t pm_pid, bool do_checkpoint)
647647
return PQPING_NO_ATTEMPT;
648648
}
649649

650-
/* If postmaster is listening on "*", use localhost */
650+
/*
651+
* Map listen-only addresses to counterparts usable
652+
* for establishing a connection. connect() to "::"
653+
* or "0.0.0.0" is not portable to OpenBSD 5.0 or to
654+
* Windows Server 2008, and connect() to "::" is
655+
* additionally not portable to NetBSD 6.0. (Cygwin
656+
* does handle both addresses, though.)
657+
*/
651658
if (strcmp(host_str, "*") == 0)
652659
strcpy(host_str, "localhost");
660+
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(WIN32)
661+
else if (strcmp(host_str, "0.0.0.0") == 0)
662+
strcpy(host_str, "127.0.0.1");
663+
else if (strcmp(host_str, "::") == 0)
664+
strcpy(host_str, "::1");
665+
#endif
653666

654667
/*
655668
* We need to set connect_timeout otherwise on Windows

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