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