396089
Change the built-in default socket directory to be /var/run/postgresql.
396089
For backwards compatibility with (probably non-libpq-based) clients that
396089
might still expect to find the socket in /tmp, also create a socket in
396089
/tmp.  This is to resolve communication problems with clients operating
396089
under systemd's PrivateTmp environment, which won't be using the same
396089
global /tmp directory as the server; see bug #825448.
396089
396089
Note that we apply the socket directory change at the level of the
396089
hard-wired defaults in the C code, not by just twiddling the setting in
396089
postgresql.conf.sample; this is so that the change will take effect on
396089
server package update, without requiring any existing postgresql.conf
396089
to be updated.  (Of course, a user who dislikes this behavior can still
396089
override it via postgresql.conf.)
396089
396089
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
396089
index 9481f2d..75532c7 100644
396089
--- a/src/backend/utils/misc/guc.c
396089
+++ b/src/backend/utils/misc/guc.c
396089
@@ -3196,7 +3196,7 @@ static struct config_string ConfigureNamesString[] =
396089
 		},
396089
 		&Unix_socket_directories,
396089
 #ifdef HAVE_UNIX_SOCKETS
396089
-		DEFAULT_PGSOCKET_DIR,
396089
+		DEFAULT_PGSOCKET_DIR ", /tmp",
396089
 #else
396089
 		"",
396089
 #endif
396089
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
396089
index feeff9e..3e3d784 100644
396089
--- a/src/bin/initdb/initdb.c
396089
+++ b/src/bin/initdb/initdb.c
396089
@@ -1234,7 +1234,7 @@ setup_config(void)
396089
 
396089
 #ifdef HAVE_UNIX_SOCKETS
396089
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
396089
-			 DEFAULT_PGSOCKET_DIR);
396089
+			 DEFAULT_PGSOCKET_DIR ", /tmp");
396089
 #else
396089
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
396089
 #endif
396089
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
396089
index e278fa0..9ee15d4 100644
396089
--- a/src/include/pg_config_manual.h
396089
+++ b/src/include/pg_config_manual.h
396089
@@ -201,7 +201,7 @@
396089
  * support them yet.
396089
  */
396089
 #ifndef WIN32
396089
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
396089
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
396089
 #else
396089
 #define DEFAULT_PGSOCKET_DIR ""
396089
 #endif