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