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