0002-Remove-configure-probes-for-sys-un.h-and-struct-sock.patch
application/octet-stream
Filename: 0002-Remove-configure-probes-for-sys-un.h-and-struct-sock.patch
Type: application/octet-stream
Part: 1
Patch
Format: format-patch
Series: patch 0002
Subject: Remove configure probes for sys/un.h and struct sockaddr_un.
| File | + | − |
|---|---|---|
| config/c-library.m4 | 0 | 14 |
| configure | 1 | 16 |
| configure.ac | 0 | 2 |
| src/backend/libpq/hba.c | 0 | 10 |
| src/backend/libpq/pqcomm.c | 0 | 18 |
| src/backend/postmaster/postmaster.c | 0 | 2 |
| src/backend/utils/misc/guc.c | 0 | 4 |
| src/bin/initdb/initdb.c | 0 | 41 |
| src/bin/pg_upgrade/option.c | 2 | 2 |
| src/bin/pg_upgrade/server.c | 1 | 1 |
| src/common/ip.c | 0 | 11 |
| src/include/c.h | 0 | 4 |
| src/include/libpq/pqcomm.h | 1 | 3 |
| src/include/pg_config.h.in | 0 | 6 |
| src/include/port/win32.h | 0 | 11 |
| src/include/port/win32/sys/un.h | 17 | 0 |
| src/interfaces/libpq/fe-connect.c | 0 | 12 |
| src/port/getpeereid.c | 1 | 3 |
| src/test/regress/pg_regress.c | 2 | 17 |
| src/tools/msvc/Solution.pm | 0 | 2 |
From df84d3160c2917981c62dc3a6f3fd6cde5486b7e Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 11 Aug 2022 15:30:38 +1200
Subject: [PATCH 2/7] Remove configure probes for sys/un.h and struct
sockaddr_un.
<sys/un.h> and the struct it defines are in SUSv2 and every targeted
Unix has it. Windows doesn't, you have to define it yourself, but we do
that. To avoid the need to make the #include conditional, move our
definition into src/include/port/win32/sys/un.h.
This implies that we can also get rid of HAVE_UNIX_SOCKETS, since we
always have them, even on Windows. We can therefore drop some
conditional branches and a small amount of dead code.
---
config/c-library.m4 | 14 ----------
configure | 17 +-----------
configure.ac | 2 --
src/backend/libpq/hba.c | 10 -------
src/backend/libpq/pqcomm.c | 18 -------------
src/backend/postmaster/postmaster.c | 2 --
src/backend/utils/misc/guc.c | 4 ---
src/bin/initdb/initdb.c | 41 -----------------------------
src/bin/pg_upgrade/option.c | 4 +--
src/bin/pg_upgrade/server.c | 2 +-
src/common/ip.c | 11 --------
src/include/c.h | 4 ---
src/include/libpq/pqcomm.h | 4 +--
src/include/pg_config.h.in | 6 -----
src/include/port/win32.h | 11 --------
src/include/port/win32/sys/un.h | 17 ++++++++++++
src/interfaces/libpq/fe-connect.c | 12 ---------
src/port/getpeereid.c | 4 +--
src/test/regress/pg_regress.c | 19 ++-----------
src/tools/msvc/Solution.pm | 2 --
20 files changed, 25 insertions(+), 179 deletions(-)
create mode 100644 src/include/port/win32/sys/un.h
diff --git a/config/c-library.m4 b/config/c-library.m4
index 35fdc63afe..76552ac6ed 100644
--- a/config/c-library.m4
+++ b/config/c-library.m4
@@ -76,20 +76,6 @@ AC_DEFUN([PGAC_UNION_SEMUN],
#endif])])# PGAC_UNION_SEMUN
-# PGAC_STRUCT_SOCKADDR_UN
-# -----------------------
-# If `struct sockaddr_un' exists, define HAVE_STRUCT_SOCKADDR_UN.
-# If it is missing then one could define it.
-# (Requires test for <sys/un.h>!)
-AC_DEFUN([PGAC_STRUCT_SOCKADDR_UN],
-[AC_CHECK_TYPES([struct sockaddr_un], [], [],
-[#include <sys/types.h>
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#endif
-])])# PGAC_STRUCT_SOCKADDR_UN
-
-
# PGAC_STRUCT_SOCKADDR_STORAGE
# ----------------------------
# If `struct sockaddr_storage' exists, define HAVE_STRUCT_SOCKADDR_STORAGE.
diff --git a/configure b/configure
index ef5334a12d..b0bc818af8 100755
--- a/configure
+++ b/configure
@@ -13874,7 +13874,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
fi
-for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h net/if.h netinet/tcp.h sys/epoll.h sys/event.h sys/ipc.h sys/personality.h sys/prctl.h sys/procctl.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/signalfd.h sys/sockio.h sys/ucred.h sys/un.h termios.h ucred.h
+for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h net/if.h netinet/tcp.h sys/epoll.h sys/event.h sys/ipc.h sys/personality.h sys/prctl.h sys/procctl.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/signalfd.h sys/sockio.h sys/ucred.h termios.h ucred.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -15117,21 +15117,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-fi
-
-ac_fn_c_check_type "$LINENO" "struct sockaddr_un" "ac_cv_type_struct_sockaddr_un" "#include <sys/types.h>
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#endif
-
-"
-if test "x$ac_cv_type_struct_sockaddr_un" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_SOCKADDR_UN 1
-_ACEOF
-
-
fi
ac_fn_c_check_type "$LINENO" "struct sockaddr_storage" "ac_cv_type_struct_sockaddr_storage" "#include <sys/types.h>
diff --git a/configure.ac b/configure.ac
index c1b75e0f34..666ad7dbcb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1467,7 +1467,6 @@ AC_CHECK_HEADERS(m4_normalize([
sys/signalfd.h
sys/sockio.h
sys/ucred.h
- sys/un.h
termios.h
ucred.h
]))
@@ -1625,7 +1624,6 @@ PGAC_C_COMPUTED_GOTO
PGAC_STRUCT_TIMEZONE
PGAC_UNION_SEMUN
AC_CHECK_TYPES(socklen_t, [], [], [#include <sys/socket.h>])
-PGAC_STRUCT_SOCKADDR_UN
PGAC_STRUCT_SOCKADDR_STORAGE
PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
PGAC_STRUCT_ADDRINFO
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index deee05c197..66f2156cde 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -973,17 +973,7 @@ parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
token = linitial(tokens);
if (strcmp(token->string, "local") == 0)
{
-#ifdef HAVE_UNIX_SOCKETS
parsedline->conntype = ctLocal;
-#else
- ereport(elevel,
- (errcode(ERRCODE_CONFIG_FILE_ERROR),
- errmsg("local connections are not supported by this build"),
- errcontext("line %d of configuration file \"%s\"",
- line_num, HbaFileName)));
- *err_msg = "local connections are not supported by this build";
- return NULL;
-#endif
}
else if (strcmp(token->string, "host") == 0 ||
strcmp(token->string, "hostssl") == 0 ||
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 75392a8bb7..3ec4328613 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -149,10 +149,8 @@ static void socket_putmessage_noblock(char msgtype, const char *s, size_t len);
static int internal_putbytes(const char *s, size_t len);
static int internal_flush(void);
-#ifdef HAVE_UNIX_SOCKETS
static int Lock_AF_UNIX(const char *unixSocketDir, const char *unixSocketPath);
static int Setup_AF_UNIX(const char *sock_path);
-#endif /* HAVE_UNIX_SOCKETS */
static const PQcommMethods PqCommSocketMethods = {
socket_comm_reset,
@@ -334,10 +332,7 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
struct addrinfo hint;
int listen_index = 0;
int added = 0;
-
-#ifdef HAVE_UNIX_SOCKETS
char unixSocketPath[MAXPGPATH];
-#endif
#if !defined(WIN32) || defined(IPV6_V6ONLY)
int one = 1;
#endif
@@ -348,7 +343,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
hint.ai_flags = AI_PASSIVE;
hint.ai_socktype = SOCK_STREAM;
-#ifdef HAVE_UNIX_SOCKETS
if (family == AF_UNIX)
{
/*
@@ -369,7 +363,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
service = unixSocketPath;
}
else
-#endif /* HAVE_UNIX_SOCKETS */
{
snprintf(portNumberStr, sizeof(portNumberStr), "%d", portNumber);
service = portNumberStr;
@@ -427,11 +420,9 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
familyDesc = _("IPv6");
break;
#endif
-#ifdef HAVE_UNIX_SOCKETS
case AF_UNIX:
familyDesc = _("Unix");
break;
-#endif
default:
snprintf(familyDescBuf, sizeof(familyDescBuf),
_("unrecognized address family %d"),
@@ -441,11 +432,9 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
}
/* set up text form of address for log messages */
-#ifdef HAVE_UNIX_SOCKETS
if (addr->ai_family == AF_UNIX)
addrDesc = unixSocketPath;
else
-#endif
{
pg_getnameinfo_all((const struct sockaddr_storage *) addr->ai_addr,
addr->ai_addrlen,
@@ -540,7 +529,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
continue;
}
-#ifdef HAVE_UNIX_SOCKETS
if (addr->ai_family == AF_UNIX)
{
if (Setup_AF_UNIX(service) != STATUS_OK)
@@ -549,7 +537,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
break;
}
}
-#endif
/*
* Select appropriate accept-queue length limit. PG_SOMAXCONN is only
@@ -572,13 +559,11 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
continue;
}
-#ifdef HAVE_UNIX_SOCKETS
if (addr->ai_family == AF_UNIX)
ereport(LOG,
(errmsg("listening on Unix socket \"%s\"",
addrDesc)));
else
-#endif
ereport(LOG,
/* translator: first %s is IPv4 or IPv6 */
(errmsg("listening on %s address \"%s\", port %d",
@@ -597,8 +582,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
}
-#ifdef HAVE_UNIX_SOCKETS
-
/*
* Lock_AF_UNIX -- configure unix socket file path
*/
@@ -699,7 +682,6 @@ Setup_AF_UNIX(const char *sock_path)
}
return STATUS_OK;
}
-#endif /* HAVE_UNIX_SOCKETS */
/*
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 81cb585891..a85b32db69 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -1300,7 +1300,6 @@ PostmasterMain(int argc, char *argv[])
}
#endif
-#ifdef HAVE_UNIX_SOCKETS
if (Unix_socket_directories)
{
char *rawstring;
@@ -1350,7 +1349,6 @@ PostmasterMain(int argc, char *argv[])
list_free_deep(elemlist);
pfree(rawstring);
}
-#endif
/*
* check that we have some socket to listen on
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 5db5df6285..9fbbfb1be5 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -4452,11 +4452,7 @@ static struct config_string ConfigureNamesString[] =
GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
},
&Unix_socket_directories,
-#ifdef HAVE_UNIX_SOCKETS
DEFAULT_PGSOCKET_DIR,
-#else
- "",
-#endif
NULL, NULL, NULL
},
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 2c93ffe811..4feb5db3fa 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -242,9 +242,6 @@ static char backend_exec[MAXPGPATH];
static char **replace_token(char **lines,
const char *token, const char *replacement);
-#ifndef HAVE_UNIX_SOCKETS
-static char **filter_lines_with_token(char **lines, const char *token);
-#endif
static char **readfile(const char *path);
static void writefile(char *path, char **lines);
static FILE *popen_check(const char *command, const char *mode);
@@ -418,36 +415,6 @@ replace_token(char **lines, const char *token, const char *replacement)
return result;
}
-/*
- * make a copy of lines without any that contain the token
- *
- * a sort of poor man's grep -v
- */
-#ifndef HAVE_UNIX_SOCKETS
-static char **
-filter_lines_with_token(char **lines, const char *token)
-{
- int numlines = 1;
- int i,
- src,
- dst;
- char **result;
-
- for (i = 0; lines[i]; i++)
- numlines++;
-
- result = (char **) pg_malloc(numlines * sizeof(char *));
-
- for (src = 0, dst = 0; src < numlines; src++)
- {
- if (lines[src] == NULL || strstr(lines[src], token) == NULL)
- result[dst++] = lines[src];
- }
-
- return result;
-}
-#endif
-
/*
* get the lines from a text file
*/
@@ -1045,12 +1012,8 @@ setup_config(void)
n_buffers * (BLCKSZ / 1024));
conflines = replace_token(conflines, "#shared_buffers = 128MB", repltok);
-#ifdef HAVE_UNIX_SOCKETS
snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
DEFAULT_PGSOCKET_DIR);
-#else
- snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
-#endif
conflines = replace_token(conflines, "#unix_socket_directories = '/tmp'",
repltok);
@@ -1210,11 +1173,7 @@ setup_config(void)
conflines = readfile(hba_file);
-#ifndef HAVE_UNIX_SOCKETS
- conflines = filter_lines_with_token(conflines, "@remove-line-for-nolocal@");
-#else
conflines = replace_token(conflines, "@remove-line-for-nolocal@", "");
-#endif
#ifdef HAVE_IPV6
diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c
index 0954b75ec0..fbab1c4fb7 100644
--- a/src/bin/pg_upgrade/option.c
+++ b/src/bin/pg_upgrade/option.c
@@ -444,7 +444,7 @@ adjust_data_dir(ClusterInfo *cluster)
void
get_sock_dir(ClusterInfo *cluster, bool live_check)
{
-#if defined(HAVE_UNIX_SOCKETS) && !defined(WIN32)
+#if !defined(WIN32)
if (!live_check)
cluster->sockdir = user_opts.socketdir;
else
@@ -490,7 +490,7 @@ get_sock_dir(ClusterInfo *cluster, bool live_check)
pg_log(PG_WARNING, "user-supplied old port number %hu corrected to %hu",
orig_port, cluster->port);
}
-#else /* !HAVE_UNIX_SOCKETS || WIN32 */
+#else /* WIN32 */
cluster->sockdir = NULL;
#endif
}
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
index 79479edc0e..9a1a20fb27 100644
--- a/src/bin/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -212,7 +212,7 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
socket_string[0] = '\0';
-#if defined(HAVE_UNIX_SOCKETS) && !defined(WIN32)
+#if !defined(WIN32)
/* prevent TCP/IP connections, restrict socket access */
strcat(socket_string,
" -c listen_addresses='' -c unix_socket_permissions=0700");
diff --git a/src/common/ip.c b/src/common/ip.c
index 267103efb9..dd9193feb1 100644
--- a/src/common/ip.c
+++ b/src/common/ip.c
@@ -38,7 +38,6 @@
-#ifdef HAVE_UNIX_SOCKETS
static int getaddrinfo_unix(const char *path,
const struct addrinfo *hintsp,
struct addrinfo **result);
@@ -47,7 +46,6 @@ static int getnameinfo_unix(const struct sockaddr_un *sa, int salen,
char *node, int nodelen,
char *service, int servicelen,
int flags);
-#endif
/*
@@ -62,10 +60,8 @@ pg_getaddrinfo_all(const char *hostname, const char *servname,
/* not all versions of getaddrinfo() zero *result on failure */
*result = NULL;
-#ifdef HAVE_UNIX_SOCKETS
if (hintp->ai_family == AF_UNIX)
return getaddrinfo_unix(servname, hintp, result);
-#endif
/* NULL has special meaning to getaddrinfo(). */
rc = getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
@@ -87,7 +83,6 @@ pg_getaddrinfo_all(const char *hostname, const char *servname,
void
pg_freeaddrinfo_all(int hint_ai_family, struct addrinfo *ai)
{
-#ifdef HAVE_UNIX_SOCKETS
if (hint_ai_family == AF_UNIX)
{
/* struct was built by getaddrinfo_unix (see pg_getaddrinfo_all) */
@@ -101,7 +96,6 @@ pg_freeaddrinfo_all(int hint_ai_family, struct addrinfo *ai)
}
}
else
-#endif /* HAVE_UNIX_SOCKETS */
{
/* struct was built by getaddrinfo() */
if (ai != NULL)
@@ -126,14 +120,12 @@ pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen,
{
int rc;
-#ifdef HAVE_UNIX_SOCKETS
if (addr && addr->ss_family == AF_UNIX)
rc = getnameinfo_unix((const struct sockaddr_un *) addr, salen,
node, nodelen,
service, servicelen,
flags);
else
-#endif
rc = getnameinfo((const struct sockaddr *) addr, salen,
node, nodelen,
service, servicelen,
@@ -151,8 +143,6 @@ pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen,
}
-#if defined(HAVE_UNIX_SOCKETS)
-
/* -------
* getaddrinfo_unix - get unix socket info using IPv6-compatible API
*
@@ -286,4 +276,3 @@ getnameinfo_unix(const struct sockaddr_un *sa, int salen,
return 0;
}
-#endif /* HAVE_UNIX_SOCKETS */
diff --git a/src/include/c.h b/src/include/c.h
index de9ec04d49..65e91a6b89 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -1113,10 +1113,6 @@ extern void ExceptionalCondition(const char *conditionName,
* ----------------------------------------------------------------
*/
-#ifdef HAVE_STRUCT_SOCKADDR_UN
-#define HAVE_UNIX_SOCKETS 1
-#endif
-
/*
* Invert the sign of a qsort-style comparison result, ie, exchange negative
* and positive integer values, being careful not to get the wrong answer
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index b418283d5f..3bcc06b2d6 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -17,10 +17,8 @@
#define PQCOMM_H
#include <sys/socket.h>
-#include <netdb.h>
-#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
-#endif
+#include <netdb.h>
#include <netinet/in.h>
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index ed6185343e..b6c73ccd71 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -478,9 +478,6 @@
/* Define to 1 if `__ss_len' is a member of `struct sockaddr_storage'. */
#undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN
-/* Define to 1 if the system has the type `struct sockaddr_un'. */
-#undef HAVE_STRUCT_SOCKADDR_UN
-
/* Define to 1 if `tm_zone' is a member of `struct tm'. */
#undef HAVE_STRUCT_TM_TM_ZONE
@@ -538,9 +535,6 @@
/* Define to 1 if you have the <sys/ucred.h> header file. */
#undef HAVE_SYS_UCRED_H
-/* Define to 1 if you have the <sys/un.h> header file. */
-#undef HAVE_SYS_UN_H
-
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
diff --git a/src/include/port/win32.h b/src/include/port/win32.h
index 5f3b17a500..67755aadc4 100644
--- a/src/include/port/win32.h
+++ b/src/include/port/win32.h
@@ -55,14 +55,3 @@
#ifdef _MSC_VER
#define PGDLLEXPORT __declspec (dllexport)
#endif
-
-/*
- * Windows headers don't define this structure, but you can define it yourself
- * to use the functionality.
- */
-struct sockaddr_un
-{
- unsigned short sun_family;
- char sun_path[108];
-};
-#define HAVE_STRUCT_SOCKADDR_UN 1
diff --git a/src/include/port/win32/sys/un.h b/src/include/port/win32/sys/un.h
new file mode 100644
index 0000000000..aec0c4a1a7
--- /dev/null
+++ b/src/include/port/win32/sys/un.h
@@ -0,0 +1,17 @@
+/*
+ * src/include/port/win32/sys/un.h
+ */
+#ifndef WIN32_SYS_UN_H
+#define WIN32_SYS_UN_H
+
+/*
+ * Windows headers don't define this structure, but you can define it yourself
+ * to use the functionality.
+ */
+struct sockaddr_un
+{
+ unsigned short sun_family;
+ char sun_path[108];
+};
+
+#endif
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index dc49387d6c..730e79a31d 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -1102,10 +1102,8 @@ connectOptions2(PGconn *conn)
else if (ch->host != NULL && ch->host[0] != '\0')
{
ch->type = CHT_HOST_NAME;
-#ifdef HAVE_UNIX_SOCKETS
if (is_unixsock_path(ch->host))
ch->type = CHT_UNIX_SOCKET;
-#endif
}
else
{
@@ -1115,14 +1113,12 @@ connectOptions2(PGconn *conn)
* This bit selects the default host location. If you change
* this, see also pg_regress.
*/
-#ifdef HAVE_UNIX_SOCKETS
if (DEFAULT_PGSOCKET_DIR[0])
{
ch->host = strdup(DEFAULT_PGSOCKET_DIR);
ch->type = CHT_UNIX_SOCKET;
}
else
-#endif
{
ch->host = strdup(DefaultHost);
ch->type = CHT_HOST_NAME;
@@ -1684,7 +1680,6 @@ getHostaddr(PGconn *conn, char *host_addr, int host_addr_len)
static void
emitHostIdentityInfo(PGconn *conn, const char *host_addr)
{
-#ifdef HAVE_UNIX_SOCKETS
if (conn->raddr.addr.ss_family == AF_UNIX)
{
char service[NI_MAXHOST];
@@ -1698,7 +1693,6 @@ emitHostIdentityInfo(PGconn *conn, const char *host_addr)
service);
}
else
-#endif /* HAVE_UNIX_SOCKETS */
{
const char *displayed_host;
const char *displayed_port;
@@ -1748,12 +1742,10 @@ connectFailureMessage(PGconn *conn, int errorno)
"%s\n",
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)));
-#ifdef HAVE_UNIX_SOCKETS
if (conn->raddr.addr.ss_family == AF_UNIX)
appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("\tIs the server running locally and accepting connections on that socket?\n"));
else
-#endif
appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("\tIs the server running on that host and accepting TCP/IP connections?\n"));
}
@@ -2415,7 +2407,6 @@ keep_going: /* We will come back to here until there is
break;
case CHT_UNIX_SOCKET:
-#ifdef HAVE_UNIX_SOCKETS
conn->addrlist_family = hint.ai_family = AF_UNIX;
UNIXSOCK_PATH(portstr, thisport, ch->host);
if (strlen(portstr) >= UNIXSOCK_PATH_BUFLEN)
@@ -2440,9 +2431,6 @@ keep_going: /* We will come back to here until there is
portstr, gai_strerror(ret));
goto keep_going;
}
-#else
- Assert(false);
-#endif
break;
}
diff --git a/src/port/getpeereid.c b/src/port/getpeereid.c
index 56ae141040..0bb07782ba 100644
--- a/src/port/getpeereid.c
+++ b/src/port/getpeereid.c
@@ -16,10 +16,8 @@
#include <sys/param.h>
#include <sys/socket.h>
-#include <unistd.h>
-#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
-#endif
+#include <unistd.h>
#ifdef HAVE_UCRED_H
#include <ucred.h>
#endif
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 04ab513b7c..b7aa5752f4 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -102,11 +102,9 @@ static char *logfilename;
static FILE *logfile;
static char *difffilename;
static const char *sockdir;
-#ifdef HAVE_UNIX_SOCKETS
static const char *temp_sockdir;
static char sockself[MAXPGPATH];
static char socklock[MAXPGPATH];
-#endif
static _resultmap *resultmap = NULL;
@@ -288,7 +286,6 @@ stop_postmaster(void)
}
}
-#ifdef HAVE_UNIX_SOCKETS
/*
* Remove the socket temporary directory. pg_regress never waits for a
* postmaster exit, so it is indeterminate whether the postmaster has yet to
@@ -363,7 +360,6 @@ make_temp_sockdir(void)
return temp_sockdir;
}
-#endif /* HAVE_UNIX_SOCKETS */
/*
* Check whether string matches pattern
@@ -686,7 +682,6 @@ initialize_environment(void)
/* PGPORT, see below */
/* PGHOST, see below */
-#ifdef HAVE_UNIX_SOCKETS
if (hostname != NULL)
setenv("PGHOST", hostname, 1);
else
@@ -696,10 +691,6 @@ initialize_environment(void)
sockdir = make_temp_sockdir();
setenv("PGHOST", sockdir, 1);
}
-#else
- Assert(hostname != NULL);
- setenv("PGHOST", hostname, 1);
-#endif
unsetenv("PGHOSTADDR");
if (port != -1)
{
@@ -749,11 +740,9 @@ initialize_environment(void)
if (!pghost)
{
/* Keep this bit in sync with libpq's default host location: */
-#ifdef HAVE_UNIX_SOCKETS
if (DEFAULT_PGSOCKET_DIR[0])
/* do nothing, we'll print "Unix socket" below */ ;
else
-#endif
pghost = "localhost"; /* DefaultHost in fe-connect.c */
}
@@ -2071,9 +2060,7 @@ regression_main(int argc, char *argv[],
atexit(stop_postmaster);
-#if !defined(HAVE_UNIX_SOCKETS)
- use_unix_sockets = false;
-#elif defined(WIN32)
+#if defined(WIN32)
/*
* We don't use Unix-domain sockets on Windows by default, even if the
@@ -2212,7 +2199,7 @@ regression_main(int argc, char *argv[],
/*
* To reduce chances of interference with parallel installations, use
* a port number starting in the private range (49152-65535)
- * calculated from the version number. This aids !HAVE_UNIX_SOCKETS
+ * calculated from the version number. This aids non-Unix socket mode
* systems; elsewhere, the use of a private socket directory already
* prevents interference.
*/
@@ -2332,8 +2319,6 @@ regression_main(int argc, char *argv[],
snprintf(buf, sizeof(buf), "%s/data", temp_instance);
config_sspi_auth(buf, NULL);
}
-#elif !defined(HAVE_UNIX_SOCKETS)
-#error Platform has no means to secure the test installation.
#endif
/*
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 741998a103..ed437ce084 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -355,7 +355,6 @@ sub GenerateFiles
HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN => undef,
HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY => undef,
HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN => undef,
- HAVE_STRUCT_SOCKADDR_UN => undef,
HAVE_STRUCT_TM_TM_ZONE => undef,
HAVE_SYNC_FILE_RANGE => undef,
HAVE_SYNCFS => undef,
@@ -375,7 +374,6 @@ sub GenerateFiles
HAVE_SYS_STAT_H => 1,
HAVE_SYS_TYPES_H => 1,
HAVE_SYS_UCRED_H => undef,
- HAVE_SYS_UN_H => undef,
HAVE_TERMIOS_H => undef,
HAVE_TYPEOF => undef,
HAVE_UCRED_H => undef,
--
2.32.1 (Apple Git-133)