aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2015-11-08 17:28:53 -0500
committerNoah Misch <noah@leadboat.com>2015-11-08 17:28:53 -0500
commitfed19f312c72778ce7dcbb0670871b22bd06ff85 (patch)
tree6b061d44c03b12345c271c9bc8eaf504e45e230c /src
parentfba60e573e092991dde4f757b88384ab1ec6a0ce (diff)
downloadpostgresql-fed19f312c72778ce7dcbb0670871b22bd06ff85.tar.gz
postgresql-fed19f312c72778ce7dcbb0670871b22bd06ff85.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_ctl/pg_ctl.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index dacdfef323c..03b9770d500 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -646,9 +646,20 @@ test_postmaster_connection(pgpid_t pm_pid, bool do_checkpoint)
return PQPING_NO_ATTEMPT;
}
- /* If postmaster is listening on "*", use localhost */
+ /*
+ * Map listen-only addresses to counterparts usable
+ * for establishing a connection. connect() to "::"
+ * or "0.0.0.0" is not portable to OpenBSD 5.0 or to
+ * Windows Server 2008, and connect() to "::" is
+ * additionally not portable to NetBSD 6.0. (Cygwin
+ * does handle both addresses, though.)
+ */
if (strcmp(host_str, "*") == 0)
strcpy(host_str, "localhost");
+ else if (strcmp(host_str, "0.0.0.0") == 0)
+ strcpy(host_str, "127.0.0.1");
+ else if (strcmp(host_str, "::") == 0)
+ strcpy(host_str, "::1");
/*
* We need to set connect_timeout otherwise on Windows