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