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