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