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