|
|
27aa74 |
Back-port of upstream 9.3 patch to support multiple sockets
|
|
|
27aa74 |
(upstream git commits c9b0cbe98bd783e24a8c4d8d8ac472a494b81292 and
|
|
|
27aa74 |
d2286a98ef3fb88bafb57381b4c20b8b878827f1, plus updates of derived
|
|
|
27aa74 |
documentation files).
|
|
|
27aa74 |
|
|
|
27aa74 |
Note the patch also touches html-stamp and man-stamp in doc/src/sgml/;
|
|
|
27aa74 |
this is to keep the makefiles from trying to rebuild the derived doc
|
|
|
27aa74 |
files. We don't want that to happen because the BuildRequires for the
|
|
|
27aa74 |
package don't include the necessary documentation tools. Those diff
|
|
|
27aa74 |
hunks *must be at the end* so that those files are newer than the
|
|
|
27aa74 |
master doc files.
|
|
|
27aa74 |
|
|
|
27aa74 |
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/contrib/pg_upgrade/server.c postgresql-9.2.5/contrib/pg_upgrade/server.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/contrib/pg_upgrade/server.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/contrib/pg_upgrade/server.c 2013-10-21 17:51:03.057675930 +0200
|
|
|
27aa74 |
@@ -197,7 +197,8 @@
|
|
|
27aa74 |
snprintf(socket_string + strlen(socket_string),
|
|
|
27aa74 |
sizeof(socket_string) - strlen(socket_string),
|
|
|
27aa74 |
" -c %s='%s'",
|
|
|
27aa74 |
- (GET_MAJOR_VERSION(cluster->major_version) < 903) ?
|
|
|
27aa74 |
+ /* assume 9.1 build will not have unix_socket_directories patch */
|
|
|
27aa74 |
+ (GET_MAJOR_VERSION(cluster->major_version) < 902) ?
|
|
|
27aa74 |
"unix_socket_directory" : "unix_socket_directories",
|
|
|
27aa74 |
cluster->sockdir);
|
|
|
27aa74 |
#endif
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/client-auth.sgml postgresql-9.2.5/doc/src/sgml/client-auth.sgml
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/client-auth.sgml 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/client-auth.sgml 2013-10-21 17:51:03.058675937 +0200
|
|
|
27aa74 |
@@ -838,7 +838,7 @@
|
|
|
27aa74 |
<varname>unix_socket_permissions</varname> (and possibly
|
|
|
27aa74 |
<varname>unix_socket_group</varname>) configuration parameters as
|
|
|
27aa74 |
described in <xref linkend="runtime-config-connection">. Or you
|
|
|
27aa74 |
- could set the <varname>unix_socket_directory</varname>
|
|
|
27aa74 |
+ could set the <varname>unix_socket_directories</varname>
|
|
|
27aa74 |
configuration parameter to place the socket file in a suitably
|
|
|
27aa74 |
restricted directory.
|
|
|
27aa74 |
</para>
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/config.sgml postgresql-9.2.5/doc/src/sgml/config.sgml
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/config.sgml 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/config.sgml 2013-10-21 17:51:03.059675944 +0200
|
|
|
27aa74 |
@@ -453,17 +453,24 @@
|
|
|
27aa74 |
</listitem>
|
|
|
27aa74 |
</varlistentry>
|
|
|
27aa74 |
|
|
|
27aa74 |
- <varlistentry id="guc-unix-socket-directory" xreflabel="unix_socket_directory">
|
|
|
27aa74 |
- <term><varname>unix_socket_directory</varname> (<type>string</type>)</term>
|
|
|
27aa74 |
+ <varlistentry id="guc-unix-socket-directories" xreflabel="unix_socket_directories">
|
|
|
27aa74 |
+ <term><varname>unix_socket_directories</varname> (<type>string</type>)</term>
|
|
|
27aa74 |
<indexterm>
|
|
|
27aa74 |
- <primary><varname>unix_socket_directory configuration parameter</primary>
|
|
|
27aa74 |
+ <primary><varname>unix_socket_directories configuration parameter</primary>
|
|
|
27aa74 |
</indexterm>
|
|
|
27aa74 |
<listitem>
|
|
|
27aa74 |
<para>
|
|
|
27aa74 |
- Specifies the directory of the Unix-domain socket on which the
|
|
|
27aa74 |
- server is to listen for
|
|
|
27aa74 |
- connections from client applications. The default is normally
|
|
|
27aa74 |
- <filename>/tmp</filename>, but can be changed at build time.
|
|
|
27aa74 |
+ Specifies the directory of the Unix-domain socket(s) on which the
|
|
|
27aa74 |
+ server is to listen for connections from client applications.
|
|
|
27aa74 |
+ Multiple sockets can be created by listing multiple directories
|
|
|
27aa74 |
+ separated by commas. Whitespace between entries is
|
|
|
27aa74 |
+ ignored; surround a directory name with double quotes if you need
|
|
|
27aa74 |
+ to include whitespace or commas in the name.
|
|
|
27aa74 |
+ An empty value
|
|
|
27aa74 |
+ specifies not listening on any Unix-domain sockets, in which case
|
|
|
27aa74 |
+ only TCP/IP sockets can be used to connect to the server.
|
|
|
27aa74 |
+ The default value is normally
|
|
|
27aa74 |
+ <filename>/tmp</filename>, but that can be changed at build time.
|
|
|
27aa74 |
This parameter can only be set at server start.
|
|
|
27aa74 |
</para>
|
|
|
27aa74 |
|
|
|
27aa74 |
@@ -472,8 +479,8 @@
|
|
|
27aa74 |
<literal>.s.PGSQL.<replaceable>nnnn</literal> where
|
|
|
27aa74 |
<replaceable>nnnn is the server's port number, an ordinary file
|
|
|
27aa74 |
named <literal>.s.PGSQL.<replaceable>nnnn.lock</literal> will be
|
|
|
27aa74 |
- created in the <varname>unix_socket_directory directory. Neither
|
|
|
27aa74 |
- file should ever be removed manually.
|
|
|
27aa74 |
+ created in each of the <varname>unix_socket_directories directories.
|
|
|
27aa74 |
+ Neither file should ever be removed manually.
|
|
|
27aa74 |
</para>
|
|
|
27aa74 |
|
|
|
27aa74 |
<para>
|
|
|
27aa74 |
@@ -490,8 +497,8 @@
|
|
|
27aa74 |
</indexterm>
|
|
|
27aa74 |
<listitem>
|
|
|
27aa74 |
<para>
|
|
|
27aa74 |
- Sets the owning group of the Unix-domain socket. (The owning
|
|
|
27aa74 |
- user of the socket is always the user that starts the
|
|
|
27aa74 |
+ Sets the owning group of the Unix-domain socket(s). (The owning
|
|
|
27aa74 |
+ user of the sockets is always the user that starts the
|
|
|
27aa74 |
server.) In combination with the parameter
|
|
|
27aa74 |
<varname>unix_socket_permissions</varname> this can be used as
|
|
|
27aa74 |
an additional access control mechanism for Unix-domain connections.
|
|
|
27aa74 |
@@ -514,7 +521,7 @@
|
|
|
27aa74 |
</indexterm>
|
|
|
27aa74 |
<listitem>
|
|
|
27aa74 |
<para>
|
|
|
27aa74 |
- Sets the access permissions of the Unix-domain socket. Unix-domain
|
|
|
27aa74 |
+ Sets the access permissions of the Unix-domain socket(s). Unix-domain
|
|
|
27aa74 |
sockets use the usual Unix file system permission set.
|
|
|
27aa74 |
The parameter value is expected to be a numeric mode
|
|
|
27aa74 |
specified in the format accepted by the
|
|
|
27aa74 |
@@ -6618,7 +6625,7 @@
|
|
|
27aa74 |
</row>
|
|
|
27aa74 |
<row>
|
|
|
27aa74 |
<entry><option>-k <replaceable>x</replaceable></option></entry>
|
|
|
27aa74 |
- <entry><literal>unix_socket_directory = <replaceable>x</replaceable></entry>
|
|
|
27aa74 |
+ <entry><literal>unix_socket_directories = <replaceable>x</replaceable></entry>
|
|
|
27aa74 |
</row>
|
|
|
27aa74 |
<row>
|
|
|
27aa74 |
<entry><option>-l</option></entry>
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/html/app-postgres.html postgresql-9.2.5/doc/src/sgml/html/app-postgres.html
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/html/app-postgres.html 2013-10-08 05:47:38.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/html/app-postgres.html 2013-10-21 17:51:03.060675950 +0200
|
|
|
27aa74 |
@@ -574,11 +574,19 @@
|
|
|
27aa74 |
CLASS="COMMAND"
|
|
|
27aa74 |
>postgres
|
|
|
27aa74 |
> is to listen for
|
|
|
27aa74 |
- connections from client applications. The default is normally
|
|
|
27aa74 |
+ connections from client applications. The value can also be a
|
|
|
27aa74 |
+ comma-separated list of directories. An empty value
|
|
|
27aa74 |
+ specifies not listening on any Unix-domain sockets, in which case
|
|
|
27aa74 |
+ only TCP/IP sockets can be used to connect to the server.
|
|
|
27aa74 |
+ The default value is normally
|
|
|
27aa74 |
|
|
|
27aa74 |
CLASS="FILENAME"
|
|
|
27aa74 |
>/tmp
|
|
|
27aa74 |
->, but can be changed at build time.
|
|
|
27aa74 |
+>, but that can be changed at build time.
|
|
|
27aa74 |
+ Specifying this option is equivalent to setting the
|
|
|
27aa74 |
+HREF="runtime-config-connection.html#GUC-UNIX-SOCKET-DIRECTORIES"
|
|
|
27aa74 |
+>unix_socket_directories
|
|
|
27aa74 |
+> configuration parameter.
|
|
|
27aa74 |
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/html/auth-methods.html postgresql-9.2.5/doc/src/sgml/html/auth-methods.html
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/html/auth-methods.html 2013-10-08 05:47:22.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/html/auth-methods.html 2013-10-21 17:51:03.060675950 +0200
|
|
|
27aa74 |
@@ -161,7 +161,7 @@
|
|
|
27aa74 |
>. Or you
|
|
|
27aa74 |
could set the
|
|
|
27aa74 |
CLASS="VARNAME"
|
|
|
27aa74 |
->unix_socket_directory
|
|
|
27aa74 |
+>unix_socket_directories
|
|
|
27aa74 |
>
|
|
|
27aa74 |
configuration parameter to place the socket file in a suitably
|
|
|
27aa74 |
restricted directory.
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/html/bookindex.html postgresql-9.2.5/doc/src/sgml/html/bookindex.html
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/html/bookindex.html 2013-10-08 05:48:15.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/html/bookindex.html 2013-10-21 17:51:03.062675963 +0200
|
|
|
27aa74 |
@@ -17250,7 +17250,7 @@
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
->unix_socket_directory configuration parameter,
|
|
|
27aa74 |
+>unix_socket_directories configuration parameter,
|
|
|
27aa74 |
|
|
|
27aa74 |
HREF="runtime-config-connection.html#RUNTIME-CONFIG-CONNECTION-SETTINGS"
|
|
|
27aa74 |
>Connection Settings
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/html/preventing-server-spoofing.html postgresql-9.2.5/doc/src/sgml/html/preventing-server-spoofing.html
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/html/preventing-server-spoofing.html 2013-10-08 05:47:21.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/html/preventing-server-spoofing.html 2013-10-21 17:51:03.063675969 +0200
|
|
|
27aa74 |
@@ -115,8 +115,8 @@
|
|
|
27aa74 |
>local
|
|
|
27aa74 |
>
|
|
|
27aa74 |
connections is to use a Unix domain socket directory (
|
|
|
27aa74 |
-HREF="runtime-config-connection.html#GUC-UNIX-SOCKET-DIRECTORY"
|
|
|
27aa74 |
->unix_socket_directory
|
|
|
27aa74 |
+HREF="runtime-config-connection.html#GUC-UNIX-SOCKET-DIRECTORIES"
|
|
|
27aa74 |
+>unix_socket_directories
|
|
|
27aa74 |
>) that has write permission only
|
|
|
27aa74 |
for a trusted local user. This prevents a malicious user from creating
|
|
|
27aa74 |
their own socket file in that directory. If you are concerned that
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/html/runtime-config-connection.html postgresql-9.2.5/doc/src/sgml/html/runtime-config-connection.html
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/html/runtime-config-connection.html 2013-10-08 05:47:21.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/html/runtime-config-connection.html 2013-10-21 17:51:03.063675969 +0200
|
|
|
27aa74 |
@@ -274,24 +274,31 @@
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
-NAME="GUC-UNIX-SOCKET-DIRECTORY"
|
|
|
27aa74 |
+NAME="GUC-UNIX-SOCKET-DIRECTORIES"
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
CLASS="VARNAME"
|
|
|
27aa74 |
->unix_socket_directory
|
|
|
27aa74 |
+>unix_socket_directories
|
|
|
27aa74 |
> (
|
|
|
27aa74 |
CLASS="TYPE"
|
|
|
27aa74 |
>string
|
|
|
27aa74 |
>)
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
-> Specifies the directory of the Unix-domain socket on which the
|
|
|
27aa74 |
- server is to listen for
|
|
|
27aa74 |
- connections from client applications. The default is normally
|
|
|
27aa74 |
+> Specifies the directory of the Unix-domain socket(s) on which the
|
|
|
27aa74 |
+ server is to listen for connections from client applications.
|
|
|
27aa74 |
+ Multiple sockets can be created by listing multiple directories
|
|
|
27aa74 |
+ separated by commas. Whitespace between entries is
|
|
|
27aa74 |
+ ignored; surround a directory name with double quotes if you need
|
|
|
27aa74 |
+ to include whitespace or commas in the name.
|
|
|
27aa74 |
+ An empty value
|
|
|
27aa74 |
+ specifies not listening on any Unix-domain sockets, in which case
|
|
|
27aa74 |
+ only TCP/IP sockets can be used to connect to the server.
|
|
|
27aa74 |
+ The default value is normally
|
|
|
27aa74 |
|
|
|
27aa74 |
CLASS="FILENAME"
|
|
|
27aa74 |
>/tmp
|
|
|
27aa74 |
->, but can be changed at build time.
|
|
|
27aa74 |
+>, but that can be changed at build time.
|
|
|
27aa74 |
This parameter can only be set at server start.
|
|
|
27aa74 |
|
|
|
27aa74 |
>
|
|
|
27aa74 |
@@ -320,11 +327,11 @@
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>.lock
|
|
|
27aa74 |
> will be
|
|
|
27aa74 |
- created in the
|
|
|
27aa74 |
+ created in each of the
|
|
|
27aa74 |
CLASS="VARNAME"
|
|
|
27aa74 |
->unix_socket_directory
|
|
|
27aa74 |
-> directory. Neither
|
|
|
27aa74 |
- file should ever be removed manually.
|
|
|
27aa74 |
+>unix_socket_directories
|
|
|
27aa74 |
+> directories.
|
|
|
27aa74 |
+ Neither file should ever be removed manually.
|
|
|
27aa74 |
|
|
|
27aa74 |
>
|
|
|
27aa74 |
> This parameter is irrelevant on Windows, which does not have
|
|
|
27aa74 |
@@ -344,8 +351,8 @@
|
|
|
27aa74 |
>)
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
-> Sets the owning group of the Unix-domain socket. (The owning
|
|
|
27aa74 |
- user of the socket is always the user that starts the
|
|
|
27aa74 |
+> Sets the owning group of the Unix-domain socket(s). (The owning
|
|
|
27aa74 |
+ user of the sockets is always the user that starts the
|
|
|
27aa74 |
server.) In combination with the parameter
|
|
|
27aa74 |
|
|
|
27aa74 |
CLASS="VARNAME"
|
|
|
27aa74 |
@@ -374,7 +381,7 @@
|
|
|
27aa74 |
>)
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
-> Sets the access permissions of the Unix-domain socket. Unix-domain
|
|
|
27aa74 |
+> Sets the access permissions of the Unix-domain socket(s). Unix-domain
|
|
|
27aa74 |
sockets use the usual Unix file system permission set.
|
|
|
27aa74 |
The parameter value is expected to be a numeric mode
|
|
|
27aa74 |
specified in the format accepted by the
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/html/runtime-config-short.html postgresql-9.2.5/doc/src/sgml/html/runtime-config-short.html
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/html/runtime-config-short.html 2013-10-08 05:47:21.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/html/runtime-config-short.html 2013-10-21 17:51:03.063675969 +0200
|
|
|
27aa74 |
@@ -330,7 +330,7 @@
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>
|
|
|
27aa74 |
CLASS="LITERAL"
|
|
|
27aa74 |
->unix_socket_directory =
|
|
|
27aa74 |
+>unix_socket_directories =
|
|
|
27aa74 |
CLASS="REPLACEABLE"
|
|
|
27aa74 |
>
|
|
|
27aa74 |
>x
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/man1/postgres.1 postgresql-9.2.5/doc/src/sgml/man1/postgres.1
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/man1/postgres.1 2013-10-08 05:49:16.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/man1/postgres.1 2013-10-21 17:51:03.063675969 +0200
|
|
|
27aa74 |
@@ -195,8 +195,10 @@
|
|
|
27aa74 |
.RS 4
|
|
|
27aa74 |
Specifies the directory of the Unix\-domain socket on which
|
|
|
27aa74 |
\fBpostgres\fR
|
|
|
27aa74 |
-is to listen for connections from client applications\&. The default is normally
|
|
|
27aa74 |
-/tmp, but can be changed at build time\&.
|
|
|
27aa74 |
+is to listen for connections from client applications\&. The value can also be a comma\-separated list of directories\&. An empty value specifies not listening on any Unix\-domain sockets, in which case only TCP/IP sockets can be used to connect to the server\&. The default value is normally
|
|
|
27aa74 |
+/tmp, but that can be changed at build time\&. Specifying this option is equivalent to setting the
|
|
|
27aa74 |
+unix_socket_directories
|
|
|
27aa74 |
+configuration parameter\&.
|
|
|
27aa74 |
.RE
|
|
|
27aa74 |
.PP
|
|
|
27aa74 |
\fB\-l\fR
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/ref/postgres-ref.sgml postgresql-9.2.5/doc/src/sgml/ref/postgres-ref.sgml
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/ref/postgres-ref.sgml 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/ref/postgres-ref.sgml 2013-10-21 17:51:03.064675976 +0200
|
|
|
27aa74 |
@@ -254,8 +254,14 @@
|
|
|
27aa74 |
<para>
|
|
|
27aa74 |
Specifies the directory of the Unix-domain socket on which
|
|
|
27aa74 |
<command>postgres</command> is to listen for
|
|
|
27aa74 |
- connections from client applications. The default is normally
|
|
|
27aa74 |
- <filename>/tmp</filename>, but can be changed at build time.
|
|
|
27aa74 |
+ connections from client applications. The value can also be a
|
|
|
27aa74 |
+ comma-separated list of directories. An empty value
|
|
|
27aa74 |
+ specifies not listening on any Unix-domain sockets, in which case
|
|
|
27aa74 |
+ only TCP/IP sockets can be used to connect to the server.
|
|
|
27aa74 |
+ The default value is normally
|
|
|
27aa74 |
+ <filename>/tmp</filename>, but that can be changed at build time.
|
|
|
27aa74 |
+ Specifying this option is equivalent to setting the
|
|
|
27aa74 |
+ linkend="guc-unix-socket-directories"> configuration parameter.
|
|
|
27aa74 |
</para>
|
|
|
27aa74 |
</listitem>
|
|
|
27aa74 |
</varlistentry>
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/runtime.sgml postgresql-9.2.5/doc/src/sgml/runtime.sgml
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/runtime.sgml 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/runtime.sgml 2013-10-21 17:51:03.064675976 +0200
|
|
|
27aa74 |
@@ -1798,7 +1798,7 @@
|
|
|
27aa74 |
<para>
|
|
|
27aa74 |
The simplest way to prevent spoofing for <literal>local
|
|
|
27aa74 |
connections is to use a Unix domain socket directory (
|
|
|
27aa74 |
- linkend="guc-unix-socket-directory">) that has write permission only
|
|
|
27aa74 |
+ linkend="guc-unix-socket-directories">) that has write permission only
|
|
|
27aa74 |
for a trusted local user. This prevents a malicious user from creating
|
|
|
27aa74 |
their own socket file in that directory. If you are concerned that
|
|
|
27aa74 |
some applications might still reference <filename>/tmp for the
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/backend/libpq/pqcomm.c postgresql-9.2.5/src/backend/libpq/pqcomm.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/backend/libpq/pqcomm.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/backend/libpq/pqcomm.c 2013-10-21 17:51:03.065675983 +0200
|
|
|
27aa74 |
@@ -42,7 +42,7 @@
|
|
|
27aa74 |
* StreamServerPort - Open postmaster's server port
|
|
|
27aa74 |
* StreamConnection - Create new connection with client
|
|
|
27aa74 |
* StreamClose - Close a client/backend connection
|
|
|
27aa74 |
- * TouchSocketFile - Protect socket file against /tmp cleaners
|
|
|
27aa74 |
+ * TouchSocketFiles - Protect socket files against /tmp cleaners
|
|
|
27aa74 |
* pq_init - initialize libpq at backend startup
|
|
|
27aa74 |
* pq_comm_reset - reset libpq during error recovery
|
|
|
27aa74 |
* pq_close - shutdown libpq at backend exit
|
|
|
27aa74 |
@@ -103,8 +103,8 @@
|
|
|
27aa74 |
char *Unix_socket_group;
|
|
|
27aa74 |
|
|
|
27aa74 |
|
|
|
27aa74 |
-/* Where the Unix socket file is */
|
|
|
27aa74 |
-static char sock_path[MAXPGPATH];
|
|
|
27aa74 |
+/* Where the Unix socket files are (list of palloc'd strings) */
|
|
|
27aa74 |
+static List *sock_paths = NIL;
|
|
|
27aa74 |
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
@@ -140,8 +140,8 @@
|
|
|
27aa74 |
static void pq_set_nonblocking(bool nonblocking);
|
|
|
27aa74 |
|
|
|
27aa74 |
#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
-static int Lock_AF_UNIX(unsigned short portNumber, char *unixSocketName);
|
|
|
27aa74 |
-static int Setup_AF_UNIX(void);
|
|
|
27aa74 |
+static int Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath);
|
|
|
27aa74 |
+static int Setup_AF_UNIX(char *sock_path);
|
|
|
27aa74 |
#endif /* HAVE_UNIX_SOCKETS */
|
|
|
27aa74 |
|
|
|
27aa74 |
|
|
|
27aa74 |
@@ -234,29 +234,43 @@
|
|
|
27aa74 |
|
|
|
27aa74 |
/* StreamDoUnlink()
|
|
|
27aa74 |
* Shutdown routine for backend connection
|
|
|
27aa74 |
- * If a Unix socket is used for communication, explicitly close it.
|
|
|
27aa74 |
+ * If any Unix sockets are used for communication, explicitly close them.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
static void
|
|
|
27aa74 |
StreamDoUnlink(int code, Datum arg)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- Assert(sock_path[0]);
|
|
|
27aa74 |
- unlink(sock_path);
|
|
|
27aa74 |
+ ListCell *l;
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* Loop through all created sockets... */
|
|
|
27aa74 |
+ foreach(l, sock_paths)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ char *sock_path = (char *) lfirst(l);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ unlink(sock_path);
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+ /* Since we're about to exit, no need to reclaim storage */
|
|
|
27aa74 |
+ sock_paths = NIL;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
#endif /* HAVE_UNIX_SOCKETS */
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* StreamServerPort -- open a "listening" port to accept connections.
|
|
|
27aa74 |
*
|
|
|
27aa74 |
- * Successfully opened sockets are added to the ListenSocket[] array,
|
|
|
27aa74 |
- * at the first position that isn't PGINVALID_SOCKET.
|
|
|
27aa74 |
+ * family should be AF_UNIX or AF_UNSPEC; portNumber is the port number.
|
|
|
27aa74 |
+ * For AF_UNIX ports, hostName should be NULL and unixSocketDir must be
|
|
|
27aa74 |
+ * specified. For TCP ports, hostName is either NULL for all interfaces or
|
|
|
27aa74 |
+ * the interface to listen on, and unixSocketDir is ignored (can be NULL).
|
|
|
27aa74 |
+ *
|
|
|
27aa74 |
+ * Successfully opened sockets are added to the ListenSocket[] array (of
|
|
|
27aa74 |
+ * length MaxListen), at the first position that isn't PGINVALID_SOCKET.
|
|
|
27aa74 |
*
|
|
|
27aa74 |
* RETURNS: STATUS_OK or STATUS_ERROR
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
|
|
|
27aa74 |
int
|
|
|
27aa74 |
StreamServerPort(int family, char *hostName, unsigned short portNumber,
|
|
|
27aa74 |
- char *unixSocketName,
|
|
|
27aa74 |
+ char *unixSocketDir,
|
|
|
27aa74 |
pgsocket ListenSocket[], int MaxListen)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
pgsocket fd;
|
|
|
27aa74 |
@@ -273,6 +287,9 @@
|
|
|
27aa74 |
int listen_index = 0;
|
|
|
27aa74 |
int added = 0;
|
|
|
27aa74 |
|
|
|
27aa74 |
+#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
+ char unixSocketPath[MAXPGPATH];
|
|
|
27aa74 |
+#endif
|
|
|
27aa74 |
#if !defined(WIN32) || defined(IPV6_V6ONLY)
|
|
|
27aa74 |
int one = 1;
|
|
|
27aa74 |
#endif
|
|
|
27aa74 |
@@ -286,10 +303,22 @@
|
|
|
27aa74 |
#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
if (family == AF_UNIX)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- /* Lock_AF_UNIX will also fill in sock_path. */
|
|
|
27aa74 |
- if (Lock_AF_UNIX(portNumber, unixSocketName) != STATUS_OK)
|
|
|
27aa74 |
+ /*
|
|
|
27aa74 |
+ * Create unixSocketPath from portNumber and unixSocketDir and lock
|
|
|
27aa74 |
+ * that file path
|
|
|
27aa74 |
+ */
|
|
|
27aa74 |
+ UNIXSOCK_PATH(unixSocketPath, portNumber, unixSocketDir);
|
|
|
27aa74 |
+ if (strlen(unixSocketPath) >= UNIXSOCK_PATH_BUFLEN)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ ereport(LOG,
|
|
|
27aa74 |
+ (errmsg("Unix-domain socket path \"%s\" is too long (maximum %d bytes)",
|
|
|
27aa74 |
+ unixSocketPath,
|
|
|
27aa74 |
+ (int) (UNIXSOCK_PATH_BUFLEN - 1))));
|
|
|
27aa74 |
+ return STATUS_ERROR;
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+ if (Lock_AF_UNIX(unixSocketDir, unixSocketPath) != STATUS_OK)
|
|
|
27aa74 |
return STATUS_ERROR;
|
|
|
27aa74 |
- service = sock_path;
|
|
|
27aa74 |
+ service = unixSocketPath;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
else
|
|
|
27aa74 |
#endif /* HAVE_UNIX_SOCKETS */
|
|
|
27aa74 |
@@ -432,7 +461,7 @@
|
|
|
27aa74 |
(IS_AF_UNIX(addr->ai_family)) ?
|
|
|
27aa74 |
errhint("Is another postmaster already running on port %d?"
|
|
|
27aa74 |
" If not, remove socket file \"%s\" and retry.",
|
|
|
27aa74 |
- (int) portNumber, sock_path) :
|
|
|
27aa74 |
+ (int) portNumber, service) :
|
|
|
27aa74 |
errhint("Is another postmaster already running on port %d?"
|
|
|
27aa74 |
" If not, wait a few seconds and retry.",
|
|
|
27aa74 |
(int) portNumber)));
|
|
|
27aa74 |
@@ -443,7 +472,7 @@
|
|
|
27aa74 |
#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
if (addr->ai_family == AF_UNIX)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- if (Setup_AF_UNIX() != STATUS_OK)
|
|
|
27aa74 |
+ if (Setup_AF_UNIX(service) != STATUS_OK)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
closesocket(fd);
|
|
|
27aa74 |
break;
|
|
|
27aa74 |
@@ -490,18 +519,8 @@
|
|
|
27aa74 |
* Lock_AF_UNIX -- configure unix socket file path
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
static int
|
|
|
27aa74 |
-Lock_AF_UNIX(unsigned short portNumber, char *unixSocketName)
|
|
|
27aa74 |
+Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- UNIXSOCK_PATH(sock_path, portNumber, unixSocketName);
|
|
|
27aa74 |
- if (strlen(sock_path) >= UNIXSOCK_PATH_BUFLEN)
|
|
|
27aa74 |
- {
|
|
|
27aa74 |
- ereport(LOG,
|
|
|
27aa74 |
- (errmsg("Unix-domain socket path \"%s\" is too long (maximum %d bytes)",
|
|
|
27aa74 |
- sock_path,
|
|
|
27aa74 |
- (int) (UNIXSOCK_PATH_BUFLEN - 1))));
|
|
|
27aa74 |
- return STATUS_ERROR;
|
|
|
27aa74 |
- }
|
|
|
27aa74 |
-
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* Grab an interlock file associated with the socket file.
|
|
|
27aa74 |
*
|
|
|
27aa74 |
@@ -510,13 +529,23 @@
|
|
|
27aa74 |
* more portable, and second, it lets us remove any pre-existing socket
|
|
|
27aa74 |
* file without race conditions.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
- CreateSocketLockFile(sock_path, true);
|
|
|
27aa74 |
+ CreateSocketLockFile(unixSocketPath, true, unixSocketDir);
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* Once we have the interlock, we can safely delete any pre-existing
|
|
|
27aa74 |
* socket file to avoid failure at bind() time.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
- unlink(sock_path);
|
|
|
27aa74 |
+ unlink(unixSocketPath);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /*
|
|
|
27aa74 |
+ * Arrange to unlink the socket file(s) at proc_exit. If this is the
|
|
|
27aa74 |
+ * first one, set up the on_proc_exit function to do it; then add this
|
|
|
27aa74 |
+ * socket file to the list of files to unlink.
|
|
|
27aa74 |
+ */
|
|
|
27aa74 |
+ if (sock_paths == NIL)
|
|
|
27aa74 |
+ on_proc_exit(StreamDoUnlink, 0);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ sock_paths = lappend(sock_paths, pstrdup(unixSocketPath));
|
|
|
27aa74 |
|
|
|
27aa74 |
return STATUS_OK;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
@@ -526,11 +555,8 @@
|
|
|
27aa74 |
* Setup_AF_UNIX -- configure unix socket permissions
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
static int
|
|
|
27aa74 |
-Setup_AF_UNIX(void)
|
|
|
27aa74 |
+Setup_AF_UNIX(char *sock_path)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- /* Arrange to unlink the socket file at exit */
|
|
|
27aa74 |
- on_proc_exit(StreamDoUnlink, 0);
|
|
|
27aa74 |
-
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* Fix socket ownership/permission if requested. Note we must do this
|
|
|
27aa74 |
* before we listen() to avoid a window where unwanted connections could
|
|
|
27aa74 |
@@ -712,20 +738,24 @@
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
- * TouchSocketFile -- mark socket file as recently accessed
|
|
|
27aa74 |
+ * TouchSocketFiles -- mark socket files as recently accessed
|
|
|
27aa74 |
*
|
|
|
27aa74 |
* This routine should be called every so often to ensure that the socket
|
|
|
27aa74 |
- * file has a recent mod date (ordinary operations on sockets usually won't
|
|
|
27aa74 |
- * change the mod date). That saves it from being removed by
|
|
|
27aa74 |
+ * files have a recent mod date (ordinary operations on sockets usually won't
|
|
|
27aa74 |
+ * change the mod date). That saves them from being removed by
|
|
|
27aa74 |
* overenthusiastic /tmp-directory-cleaner daemons. (Another reason we should
|
|
|
27aa74 |
* never have put the socket file in /tmp...)
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
void
|
|
|
27aa74 |
-TouchSocketFile(void)
|
|
|
27aa74 |
+TouchSocketFiles(void)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- /* Do nothing if we did not create a socket... */
|
|
|
27aa74 |
- if (sock_path[0] != '\0')
|
|
|
27aa74 |
+ ListCell *l;
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* Loop through all created sockets... */
|
|
|
27aa74 |
+ foreach(l, sock_paths)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
+ char *sock_path = (char *) lfirst(l);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* utime() is POSIX standard, utimes() is a common alternative. If we
|
|
|
27aa74 |
* have neither, there's no way to affect the mod or access time of
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/backend/postmaster/postmaster.c postgresql-9.2.5/src/backend/postmaster/postmaster.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/backend/postmaster/postmaster.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/backend/postmaster/postmaster.c 2013-10-21 17:51:03.066675990 +0200
|
|
|
27aa74 |
@@ -156,7 +156,9 @@
|
|
|
27aa74 |
|
|
|
27aa74 |
/* The socket number we are listening for connections on */
|
|
|
27aa74 |
int PostPortNumber;
|
|
|
27aa74 |
-char *UnixSocketDir;
|
|
|
27aa74 |
+/* The directory names for Unix socket(s) */
|
|
|
27aa74 |
+char *Unix_socket_directories;
|
|
|
27aa74 |
+/* The TCP listen address(es) */
|
|
|
27aa74 |
char *ListenAddresses;
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
@@ -608,7 +610,7 @@
|
|
|
27aa74 |
break;
|
|
|
27aa74 |
|
|
|
27aa74 |
case 'k':
|
|
|
27aa74 |
- SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
|
|
27aa74 |
+ SetConfigOption("unix_socket_directories", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
|
|
27aa74 |
break;
|
|
|
27aa74 |
|
|
|
27aa74 |
case 'l':
|
|
|
27aa74 |
@@ -852,7 +854,7 @@
|
|
|
27aa74 |
/* Need a modifiable copy of ListenAddresses */
|
|
|
27aa74 |
rawstring = pstrdup(ListenAddresses);
|
|
|
27aa74 |
|
|
|
27aa74 |
- /* Parse string into list of identifiers */
|
|
|
27aa74 |
+ /* Parse string into list of hostnames */
|
|
|
27aa74 |
if (!SplitIdentifierString(rawstring, ',', &elemlist))
|
|
|
27aa74 |
{
|
|
|
27aa74 |
/* syntax error in list */
|
|
|
27aa74 |
@@ -868,12 +870,12 @@
|
|
|
27aa74 |
if (strcmp(curhost, "*") == 0)
|
|
|
27aa74 |
status = StreamServerPort(AF_UNSPEC, NULL,
|
|
|
27aa74 |
(unsigned short) PostPortNumber,
|
|
|
27aa74 |
- UnixSocketDir,
|
|
|
27aa74 |
+ NULL,
|
|
|
27aa74 |
ListenSocket, MAXLISTEN);
|
|
|
27aa74 |
else
|
|
|
27aa74 |
status = StreamServerPort(AF_UNSPEC, curhost,
|
|
|
27aa74 |
(unsigned short) PostPortNumber,
|
|
|
27aa74 |
- UnixSocketDir,
|
|
|
27aa74 |
+ NULL,
|
|
|
27aa74 |
ListenSocket, MAXLISTEN);
|
|
|
27aa74 |
|
|
|
27aa74 |
if (status == STATUS_OK)
|
|
|
27aa74 |
@@ -892,7 +894,7 @@
|
|
|
27aa74 |
curhost)));
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
- if (!success && list_length(elemlist))
|
|
|
27aa74 |
+ if (!success && elemlist != NIL)
|
|
|
27aa74 |
ereport(FATAL,
|
|
|
27aa74 |
(errmsg("could not create any TCP/IP sockets")));
|
|
|
27aa74 |
|
|
|
27aa74 |
@@ -939,13 +941,54 @@
|
|
|
27aa74 |
#endif
|
|
|
27aa74 |
|
|
|
27aa74 |
#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
- status = StreamServerPort(AF_UNIX, NULL,
|
|
|
27aa74 |
- (unsigned short) PostPortNumber,
|
|
|
27aa74 |
- UnixSocketDir,
|
|
|
27aa74 |
- ListenSocket, MAXLISTEN);
|
|
|
27aa74 |
- if (status != STATUS_OK)
|
|
|
27aa74 |
- ereport(WARNING,
|
|
|
27aa74 |
- (errmsg("could not create Unix-domain socket")));
|
|
|
27aa74 |
+ if (Unix_socket_directories)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ char *rawstring;
|
|
|
27aa74 |
+ List *elemlist;
|
|
|
27aa74 |
+ ListCell *l;
|
|
|
27aa74 |
+ int success = 0;
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* Need a modifiable copy of Unix_socket_directories */
|
|
|
27aa74 |
+ rawstring = pstrdup(Unix_socket_directories);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* Parse string into list of directories */
|
|
|
27aa74 |
+ if (!SplitDirectoriesString(rawstring, ',', &elemlist))
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ /* syntax error in list */
|
|
|
27aa74 |
+ ereport(FATAL,
|
|
|
27aa74 |
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
|
|
27aa74 |
+ errmsg("invalid list syntax for \"unix_socket_directories\"")));
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ foreach(l, elemlist)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ char *socketdir = (char *) lfirst(l);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ status = StreamServerPort(AF_UNIX, NULL,
|
|
|
27aa74 |
+ (unsigned short) PostPortNumber,
|
|
|
27aa74 |
+ socketdir,
|
|
|
27aa74 |
+ ListenSocket, MAXLISTEN);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ if (status == STATUS_OK)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ success++;
|
|
|
27aa74 |
+ /* record the first successful Unix socket in lockfile */
|
|
|
27aa74 |
+ if (success == 1)
|
|
|
27aa74 |
+ AddToDataDirLockFile(LOCK_FILE_LINE_SOCKET_DIR, socketdir);
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+ else
|
|
|
27aa74 |
+ ereport(WARNING,
|
|
|
27aa74 |
+ (errmsg("could not create Unix-domain socket in directory \"%s\"",
|
|
|
27aa74 |
+ socketdir)));
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ if (!success && elemlist != NIL)
|
|
|
27aa74 |
+ ereport(FATAL,
|
|
|
27aa74 |
+ (errmsg("could not create any Unix-domain sockets")));
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ list_free_deep(elemlist);
|
|
|
27aa74 |
+ pfree(rawstring);
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
#endif
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
@@ -1435,15 +1478,15 @@
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
- * Touch the socket and lock file every 58 minutes, to ensure that
|
|
|
27aa74 |
+ * Touch Unix socket and lock files every 58 minutes, to ensure that
|
|
|
27aa74 |
* they are not removed by overzealous /tmp-cleaning tasks. We assume
|
|
|
27aa74 |
* no one runs cleaners with cutoff times of less than an hour ...
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
now = time(NULL);
|
|
|
27aa74 |
if (now - last_touch_time >= 58 * SECS_PER_MINUTE)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- TouchSocketFile();
|
|
|
27aa74 |
- TouchSocketLockFile();
|
|
|
27aa74 |
+ TouchSocketFiles();
|
|
|
27aa74 |
+ TouchSocketLockFiles();
|
|
|
27aa74 |
last_touch_time = now;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
}
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/backend/tcop/postgres.c postgresql-9.2.5/src/backend/tcop/postgres.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/backend/tcop/postgres.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/backend/tcop/postgres.c 2013-10-21 17:51:03.066675990 +0200
|
|
|
27aa74 |
@@ -3344,7 +3344,7 @@
|
|
|
27aa74 |
break;
|
|
|
27aa74 |
|
|
|
27aa74 |
case 'k':
|
|
|
27aa74 |
- SetConfigOption("unix_socket_directory", optarg, ctx, gucsource);
|
|
|
27aa74 |
+ SetConfigOption("unix_socket_directories", optarg, ctx, gucsource);
|
|
|
27aa74 |
break;
|
|
|
27aa74 |
|
|
|
27aa74 |
case 'l':
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/backend/utils/adt/varlena.c postgresql-9.2.5/src/backend/utils/adt/varlena.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/backend/utils/adt/varlena.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/backend/utils/adt/varlena.c 2013-10-21 17:51:03.067675996 +0200
|
|
|
27aa74 |
@@ -2446,6 +2446,119 @@
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
|
|
|
27aa74 |
+/*
|
|
|
27aa74 |
+ * SplitDirectoriesString --- parse a string containing directory names
|
|
|
27aa74 |
+ *
|
|
|
27aa74 |
+ * This is similar to SplitIdentifierString, except that the parsing
|
|
|
27aa74 |
+ * rules are meant to handle pathnames instead of identifiers: there is
|
|
|
27aa74 |
+ * no downcasing, embedded spaces are allowed, the max length is MAXPGPATH-1,
|
|
|
27aa74 |
+ * and we apply canonicalize_path() to each extracted string. Because of the
|
|
|
27aa74 |
+ * last, the returned strings are separately palloc'd rather than being
|
|
|
27aa74 |
+ * pointers into rawstring --- but we still scribble on rawstring.
|
|
|
27aa74 |
+ *
|
|
|
27aa74 |
+ * Inputs:
|
|
|
27aa74 |
+ * rawstring: the input string; must be modifiable!
|
|
|
27aa74 |
+ * separator: the separator punctuation expected between directories
|
|
|
27aa74 |
+ * (typically ',' or ';'). Whitespace may also appear around
|
|
|
27aa74 |
+ * directories.
|
|
|
27aa74 |
+ * Outputs:
|
|
|
27aa74 |
+ * namelist: filled with a palloc'd list of directory names.
|
|
|
27aa74 |
+ * Caller should list_free_deep() this even on error return.
|
|
|
27aa74 |
+ *
|
|
|
27aa74 |
+ * Returns TRUE if okay, FALSE if there is a syntax error in the string.
|
|
|
27aa74 |
+ *
|
|
|
27aa74 |
+ * Note that an empty string is considered okay here.
|
|
|
27aa74 |
+ */
|
|
|
27aa74 |
+bool
|
|
|
27aa74 |
+SplitDirectoriesString(char *rawstring, char separator,
|
|
|
27aa74 |
+ List **namelist)
|
|
|
27aa74 |
+{
|
|
|
27aa74 |
+ char *nextp = rawstring;
|
|
|
27aa74 |
+ bool done = false;
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ *namelist = NIL;
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ while (isspace((unsigned char) *nextp))
|
|
|
27aa74 |
+ nextp++; /* skip leading whitespace */
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ if (*nextp == '\0')
|
|
|
27aa74 |
+ return true; /* allow empty string */
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* At the top of the loop, we are at start of a new directory. */
|
|
|
27aa74 |
+ do
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ char *curname;
|
|
|
27aa74 |
+ char *endp;
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ if (*nextp == '\"')
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ /* Quoted name --- collapse quote-quote pairs */
|
|
|
27aa74 |
+ curname = nextp + 1;
|
|
|
27aa74 |
+ for (;;)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ endp = strchr(nextp + 1, '\"');
|
|
|
27aa74 |
+ if (endp == NULL)
|
|
|
27aa74 |
+ return false; /* mismatched quotes */
|
|
|
27aa74 |
+ if (endp[1] != '\"')
|
|
|
27aa74 |
+ break; /* found end of quoted name */
|
|
|
27aa74 |
+ /* Collapse adjacent quotes into one quote, and look again */
|
|
|
27aa74 |
+ memmove(endp, endp + 1, strlen(endp));
|
|
|
27aa74 |
+ nextp = endp;
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+ /* endp now points at the terminating quote */
|
|
|
27aa74 |
+ nextp = endp + 1;
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+ else
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ /* Unquoted name --- extends to separator or end of string */
|
|
|
27aa74 |
+ curname = endp = nextp;
|
|
|
27aa74 |
+ while (*nextp && *nextp != separator)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ /* trailing whitespace should not be included in name */
|
|
|
27aa74 |
+ if (!isspace((unsigned char) *nextp))
|
|
|
27aa74 |
+ endp = nextp + 1;
|
|
|
27aa74 |
+ nextp++;
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+ if (curname == endp)
|
|
|
27aa74 |
+ return false; /* empty unquoted name not allowed */
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ while (isspace((unsigned char) *nextp))
|
|
|
27aa74 |
+ nextp++; /* skip trailing whitespace */
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ if (*nextp == separator)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ nextp++;
|
|
|
27aa74 |
+ while (isspace((unsigned char) *nextp))
|
|
|
27aa74 |
+ nextp++; /* skip leading whitespace for next */
|
|
|
27aa74 |
+ /* we expect another name, so done remains false */
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
+ else if (*nextp == '\0')
|
|
|
27aa74 |
+ done = true;
|
|
|
27aa74 |
+ else
|
|
|
27aa74 |
+ return false; /* invalid syntax */
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* Now safe to overwrite separator with a null */
|
|
|
27aa74 |
+ *endp = '\0';
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* Truncate path if it's overlength */
|
|
|
27aa74 |
+ if (strlen(curname) >= MAXPGPATH)
|
|
|
27aa74 |
+ curname[MAXPGPATH - 1] = '\0';
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /*
|
|
|
27aa74 |
+ * Finished isolating current name --- add it to list
|
|
|
27aa74 |
+ */
|
|
|
27aa74 |
+ curname = pstrdup(curname);
|
|
|
27aa74 |
+ canonicalize_path(curname);
|
|
|
27aa74 |
+ *namelist = lappend(*namelist, curname);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* Loop back if we didn't reach end of string */
|
|
|
27aa74 |
+ } while (!done);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ return true;
|
|
|
27aa74 |
+}
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+
|
|
|
27aa74 |
/*****************************************************************************
|
|
|
27aa74 |
* Comparison Functions used for bytea
|
|
|
27aa74 |
*
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/backend/utils/init/miscinit.c postgresql-9.2.5/src/backend/utils/init/miscinit.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/backend/utils/init/miscinit.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/backend/utils/init/miscinit.c 2013-10-21 17:51:03.067675996 +0200
|
|
|
27aa74 |
@@ -49,8 +49,8 @@
|
|
|
27aa74 |
|
|
|
27aa74 |
ProcessingMode Mode = InitProcessing;
|
|
|
27aa74 |
|
|
|
27aa74 |
-/* Note: we rely on this to initialize as zeroes */
|
|
|
27aa74 |
-static char socketLockFile[MAXPGPATH];
|
|
|
27aa74 |
+/* List of lock files to be removed at proc exit */
|
|
|
27aa74 |
+static List *lock_files = NIL;
|
|
|
27aa74 |
|
|
|
27aa74 |
|
|
|
27aa74 |
/* ----------------------------------------------------------------
|
|
|
27aa74 |
@@ -640,32 +640,35 @@
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
- * proc_exit callback to remove a lockfile.
|
|
|
27aa74 |
+ * proc_exit callback to remove lockfiles.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
static void
|
|
|
27aa74 |
-UnlinkLockFile(int status, Datum filename)
|
|
|
27aa74 |
+UnlinkLockFiles(int status, Datum arg)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- char *fname = (char *) DatumGetPointer(filename);
|
|
|
27aa74 |
+ ListCell *l;
|
|
|
27aa74 |
|
|
|
27aa74 |
- if (fname != NULL)
|
|
|
27aa74 |
+ foreach(l, lock_files)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- if (unlink(fname) != 0)
|
|
|
27aa74 |
- {
|
|
|
27aa74 |
- /* Should we complain if the unlink fails? */
|
|
|
27aa74 |
- }
|
|
|
27aa74 |
- free(fname);
|
|
|
27aa74 |
+ char *curfile = (char *) lfirst(l);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ unlink(curfile);
|
|
|
27aa74 |
+ /* Should we complain if the unlink fails? */
|
|
|
27aa74 |
}
|
|
|
27aa74 |
+ /* Since we're about to exit, no need to reclaim storage */
|
|
|
27aa74 |
+ lock_files = NIL;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* Create a lockfile.
|
|
|
27aa74 |
*
|
|
|
27aa74 |
- * filename is the name of the lockfile to create.
|
|
|
27aa74 |
+ * filename is the path name of the lockfile to create.
|
|
|
27aa74 |
* amPostmaster is used to determine how to encode the output PID.
|
|
|
27aa74 |
+ * socketDir is the Unix socket directory path to include (possibly empty).
|
|
|
27aa74 |
* isDDLock and refName are used to determine what error message to produce.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
static void
|
|
|
27aa74 |
CreateLockFile(const char *filename, bool amPostmaster,
|
|
|
27aa74 |
+ const char *socketDir,
|
|
|
27aa74 |
bool isDDLock, const char *refName)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
int fd;
|
|
|
27aa74 |
@@ -891,12 +894,7 @@
|
|
|
27aa74 |
DataDir,
|
|
|
27aa74 |
(long) MyStartTime,
|
|
|
27aa74 |
PostPortNumber,
|
|
|
27aa74 |
-#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
- (*UnixSocketDir != '\0') ? UnixSocketDir : DEFAULT_PGSOCKET_DIR
|
|
|
27aa74 |
-#else
|
|
|
27aa74 |
- ""
|
|
|
27aa74 |
-#endif
|
|
|
27aa74 |
- );
|
|
|
27aa74 |
+ socketDir);
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* In a standalone backend, the next line (LOCK_FILE_LINE_LISTEN_ADDR)
|
|
|
27aa74 |
@@ -941,9 +939,14 @@
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
- * Arrange for automatic removal of lockfile at proc_exit.
|
|
|
27aa74 |
+ * Arrange to unlink the lock file(s) at proc_exit. If this is the
|
|
|
27aa74 |
+ * first one, set up the on_proc_exit function to do it; then add this
|
|
|
27aa74 |
+ * lock file to the list of files to unlink.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
- on_proc_exit(UnlinkLockFile, PointerGetDatum(strdup(filename)));
|
|
|
27aa74 |
+ if (lock_files == NIL)
|
|
|
27aa74 |
+ on_proc_exit(UnlinkLockFiles, 0);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ lock_files = lappend(lock_files, pstrdup(filename));
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
@@ -952,41 +955,50 @@
|
|
|
27aa74 |
* When this is called, we must have already switched the working
|
|
|
27aa74 |
* directory to DataDir, so we can just use a relative path. This
|
|
|
27aa74 |
* helps ensure that we are locking the directory we should be.
|
|
|
27aa74 |
+ *
|
|
|
27aa74 |
+ * Note that the socket directory path line is initially written as empty.
|
|
|
27aa74 |
+ * postmaster.c will rewrite it upon creating the first Unix socket.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
void
|
|
|
27aa74 |
CreateDataDirLockFile(bool amPostmaster)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- CreateLockFile(DIRECTORY_LOCK_FILE, amPostmaster, true, DataDir);
|
|
|
27aa74 |
+ CreateLockFile(DIRECTORY_LOCK_FILE, amPostmaster, "", true, DataDir);
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* Create a lockfile for the specified Unix socket file.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
void
|
|
|
27aa74 |
-CreateSocketLockFile(const char *socketfile, bool amPostmaster)
|
|
|
27aa74 |
+CreateSocketLockFile(const char *socketfile, bool amPostmaster,
|
|
|
27aa74 |
+ const char *socketDir)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
char lockfile[MAXPGPATH];
|
|
|
27aa74 |
|
|
|
27aa74 |
snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);
|
|
|
27aa74 |
- CreateLockFile(lockfile, amPostmaster, false, socketfile);
|
|
|
27aa74 |
- /* Save name of lockfile for TouchSocketLockFile */
|
|
|
27aa74 |
- strcpy(socketLockFile, lockfile);
|
|
|
27aa74 |
+ CreateLockFile(lockfile, amPostmaster, socketDir, false, socketfile);
|
|
|
27aa74 |
}
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
- * TouchSocketLockFile -- mark socket lock file as recently accessed
|
|
|
27aa74 |
+ * TouchSocketLockFiles -- mark socket lock files as recently accessed
|
|
|
27aa74 |
*
|
|
|
27aa74 |
- * This routine should be called every so often to ensure that the lock file
|
|
|
27aa74 |
- * has a recent mod or access date. That saves it
|
|
|
27aa74 |
+ * This routine should be called every so often to ensure that the socket
|
|
|
27aa74 |
+ * lock files have a recent mod or access date. That saves them
|
|
|
27aa74 |
* from being removed by overenthusiastic /tmp-directory-cleaner daemons.
|
|
|
27aa74 |
* (Another reason we should never have put the socket file in /tmp...)
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
void
|
|
|
27aa74 |
-TouchSocketLockFile(void)
|
|
|
27aa74 |
+TouchSocketLockFiles(void)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- /* Do nothing if we did not create a socket... */
|
|
|
27aa74 |
- if (socketLockFile[0] != '\0')
|
|
|
27aa74 |
+ ListCell *l;
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ foreach(l, lock_files)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
+ char *socketLockFile = (char *) lfirst(l);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /* No need to touch the data directory lock file, we trust */
|
|
|
27aa74 |
+ if (strcmp(socketLockFile, DIRECTORY_LOCK_FILE) == 0)
|
|
|
27aa74 |
+ continue;
|
|
|
27aa74 |
+
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* utime() is POSIX standard, utimes() is a common alternative; if we
|
|
|
27aa74 |
* have neither, fall back to actually reading the file (which only
|
|
|
27aa74 |
@@ -1018,8 +1030,10 @@
|
|
|
27aa74 |
* Add (or replace) a line in the data directory lock file.
|
|
|
27aa74 |
* The given string should not include a trailing newline.
|
|
|
27aa74 |
*
|
|
|
27aa74 |
- * Caution: this erases all following lines. In current usage that is OK
|
|
|
27aa74 |
- * because lines are added in order. We could improve it if needed.
|
|
|
27aa74 |
+ * Note: because we don't truncate the file, if we were to rewrite a line
|
|
|
27aa74 |
+ * with less data than it had before, there would be garbage after the last
|
|
|
27aa74 |
+ * line. We don't ever actually do that, so not worth adding another kernel
|
|
|
27aa74 |
+ * call to cover the possibility.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
void
|
|
|
27aa74 |
AddToDataDirLockFile(int target_line, const char *str)
|
|
|
27aa74 |
@@ -1027,8 +1041,10 @@
|
|
|
27aa74 |
int fd;
|
|
|
27aa74 |
int len;
|
|
|
27aa74 |
int lineno;
|
|
|
27aa74 |
- char *ptr;
|
|
|
27aa74 |
- char buffer[BLCKSZ];
|
|
|
27aa74 |
+ char *srcptr;
|
|
|
27aa74 |
+ char *destptr;
|
|
|
27aa74 |
+ char srcbuffer[BLCKSZ];
|
|
|
27aa74 |
+ char destbuffer[BLCKSZ];
|
|
|
27aa74 |
|
|
|
27aa74 |
fd = open(DIRECTORY_LOCK_FILE, O_RDWR | PG_BINARY, 0);
|
|
|
27aa74 |
if (fd < 0)
|
|
|
27aa74 |
@@ -1039,7 +1055,7 @@
|
|
|
27aa74 |
DIRECTORY_LOCK_FILE)));
|
|
|
27aa74 |
return;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
- len = read(fd, buffer, sizeof(buffer) - 1);
|
|
|
27aa74 |
+ len = read(fd, srcbuffer, sizeof(srcbuffer) - 1);
|
|
|
27aa74 |
if (len < 0)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
ereport(LOG,
|
|
|
27aa74 |
@@ -1049,37 +1065,51 @@
|
|
|
27aa74 |
close(fd);
|
|
|
27aa74 |
return;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
- buffer[len] = '\0';
|
|
|
27aa74 |
+ srcbuffer[len] = '\0';
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
- * Skip over lines we are not supposed to rewrite.
|
|
|
27aa74 |
+ * Advance over lines we are not supposed to rewrite, then copy them
|
|
|
27aa74 |
+ * to destbuffer.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
- ptr = buffer;
|
|
|
27aa74 |
+ srcptr = srcbuffer;
|
|
|
27aa74 |
for (lineno = 1; lineno < target_line; lineno++)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- if ((ptr = strchr(ptr, '\n')) == NULL)
|
|
|
27aa74 |
+ if ((srcptr = strchr(srcptr, '\n')) == NULL)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
elog(LOG, "incomplete data in \"%s\": found only %d newlines while trying to add line %d",
|
|
|
27aa74 |
DIRECTORY_LOCK_FILE, lineno - 1, target_line);
|
|
|
27aa74 |
close(fd);
|
|
|
27aa74 |
return;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
- ptr++;
|
|
|
27aa74 |
+ srcptr++;
|
|
|
27aa74 |
}
|
|
|
27aa74 |
+ memcpy(destbuffer, srcbuffer, srcptr - srcbuffer);
|
|
|
27aa74 |
+ destptr = destbuffer + (srcptr - srcbuffer);
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* Write or rewrite the target line.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
- snprintf(ptr, buffer + sizeof(buffer) - ptr, "%s\n", str);
|
|
|
27aa74 |
+ snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s\n", str);
|
|
|
27aa74 |
+ destptr += strlen(destptr);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
+ /*
|
|
|
27aa74 |
+ * If there are more lines in the old file, append them to destbuffer.
|
|
|
27aa74 |
+ */
|
|
|
27aa74 |
+ if ((srcptr = strchr(srcptr, '\n')) != NULL)
|
|
|
27aa74 |
+ {
|
|
|
27aa74 |
+ srcptr++;
|
|
|
27aa74 |
+ snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s",
|
|
|
27aa74 |
+ srcptr);
|
|
|
27aa74 |
+ }
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* And rewrite the data. Since we write in a single kernel call, this
|
|
|
27aa74 |
* update should appear atomic to onlookers.
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
- len = strlen(buffer);
|
|
|
27aa74 |
+ len = strlen(destbuffer);
|
|
|
27aa74 |
errno = 0;
|
|
|
27aa74 |
if (lseek(fd, (off_t) 0, SEEK_SET) != 0 ||
|
|
|
27aa74 |
- (int) write(fd, buffer, len) != len)
|
|
|
27aa74 |
+ (int) write(fd, destbuffer, len) != len)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
/* if write didn't set errno, assume problem is no disk space */
|
|
|
27aa74 |
if (errno == 0)
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/backend/utils/misc/guc.c postgresql-9.2.5/src/backend/utils/misc/guc.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/backend/utils/misc/guc.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/backend/utils/misc/guc.c 2013-10-21 17:51:03.069676008 +0200
|
|
|
27aa74 |
@@ -2894,14 +2894,18 @@
|
|
|
27aa74 |
},
|
|
|
27aa74 |
|
|
|
27aa74 |
{
|
|
|
27aa74 |
- {"unix_socket_directory", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
|
|
|
27aa74 |
- gettext_noop("Sets the directory where the Unix-domain socket will be created."),
|
|
|
27aa74 |
+ {"unix_socket_directories", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
|
|
|
27aa74 |
+ gettext_noop("Sets the directories where Unix-domain sockets will be created."),
|
|
|
27aa74 |
NULL,
|
|
|
27aa74 |
GUC_SUPERUSER_ONLY
|
|
|
27aa74 |
},
|
|
|
27aa74 |
- &UnixSocketDir,
|
|
|
27aa74 |
+ &Unix_socket_directories,
|
|
|
27aa74 |
+#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
+ DEFAULT_PGSOCKET_DIR,
|
|
|
27aa74 |
+#else
|
|
|
27aa74 |
"",
|
|
|
27aa74 |
- check_canonical_path, NULL, NULL
|
|
|
27aa74 |
+#endif
|
|
|
27aa74 |
+ NULL, NULL, NULL
|
|
|
27aa74 |
},
|
|
|
27aa74 |
|
|
|
27aa74 |
{
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/backend/utils/misc/postgresql.conf.sample postgresql-9.2.5/src/backend/utils/misc/postgresql.conf.sample
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/backend/utils/misc/postgresql.conf.sample 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/backend/utils/misc/postgresql.conf.sample 2013-10-21 17:51:03.069676008 +0200
|
|
|
27aa74 |
@@ -65,7 +65,8 @@
|
|
|
27aa74 |
# Note: Increasing max_connections costs ~400 bytes of shared memory per
|
|
|
27aa74 |
# connection slot, plus lock space (see max_locks_per_transaction).
|
|
|
27aa74 |
#superuser_reserved_connections = 3 # (change requires restart)
|
|
|
27aa74 |
-#unix_socket_directory = '' # (change requires restart)
|
|
|
27aa74 |
+#unix_socket_directories = '/tmp' # comma-separated list of directories
|
|
|
27aa74 |
+ # (change requires restart)
|
|
|
27aa74 |
#unix_socket_group = '' # (change requires restart)
|
|
|
27aa74 |
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
|
|
|
27aa74 |
# (change requires restart)
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/bin/initdb/initdb.c postgresql-9.2.5/src/bin/initdb/initdb.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/bin/initdb/initdb.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/bin/initdb/initdb.c 2013-10-21 17:51:03.070676015 +0200
|
|
|
27aa74 |
@@ -991,7 +991,7 @@
|
|
|
27aa74 |
setup_config(void)
|
|
|
27aa74 |
{
|
|
|
27aa74 |
char **conflines;
|
|
|
27aa74 |
- char repltok[TZ_STRLEN_MAX + 100];
|
|
|
27aa74 |
+ char repltok[MAXPGPATH];
|
|
|
27aa74 |
char path[MAXPGPATH];
|
|
|
27aa74 |
const char *default_timezone;
|
|
|
27aa74 |
|
|
|
27aa74 |
@@ -1013,6 +1013,15 @@
|
|
|
27aa74 |
n_buffers * (BLCKSZ / 1024));
|
|
|
27aa74 |
conflines = replace_token(conflines, "#shared_buffers = 32MB", repltok);
|
|
|
27aa74 |
|
|
|
27aa74 |
+#ifdef HAVE_UNIX_SOCKETS
|
|
|
27aa74 |
+ snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
|
|
|
27aa74 |
+ DEFAULT_PGSOCKET_DIR);
|
|
|
27aa74 |
+#else
|
|
|
27aa74 |
+ snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
|
|
|
27aa74 |
+#endif
|
|
|
27aa74 |
+ conflines = replace_token(conflines, "#unix_socket_directories = '/tmp'",
|
|
|
27aa74 |
+ repltok);
|
|
|
27aa74 |
+
|
|
|
27aa74 |
#if DEF_PGPORT != 5432
|
|
|
27aa74 |
snprintf(repltok, sizeof(repltok), "#port = %d", DEF_PGPORT);
|
|
|
27aa74 |
conflines = replace_token(conflines, "#port = 5432", repltok);
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/bin/pg_ctl/pg_ctl.c postgresql-9.2.5/src/bin/pg_ctl/pg_ctl.c
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/bin/pg_ctl/pg_ctl.c 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/bin/pg_ctl/pg_ctl.c 2013-10-21 17:51:03.070676015 +0200
|
|
|
27aa74 |
@@ -559,7 +559,7 @@
|
|
|
27aa74 |
hostaddr = optlines[LOCK_FILE_LINE_LISTEN_ADDR - 1];
|
|
|
27aa74 |
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
- * While unix_socket_directory can accept relative
|
|
|
27aa74 |
+ * While unix_socket_directories can accept relative
|
|
|
27aa74 |
* directories, libpq's host parameter must have a
|
|
|
27aa74 |
* leading slash to indicate a socket directory. So,
|
|
|
27aa74 |
* ignore sockdir if it's relative, and try to use TCP
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/include/libpq/libpq.h postgresql-9.2.5/src/include/libpq/libpq.h
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/include/libpq/libpq.h 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/include/libpq/libpq.h 2013-10-21 17:51:03.070676015 +0200
|
|
|
27aa74 |
@@ -44,12 +44,12 @@
|
|
|
27aa74 |
/*
|
|
|
27aa74 |
* prototypes for functions in pqcomm.c
|
|
|
27aa74 |
*/
|
|
|
27aa74 |
-extern int StreamServerPort(int family, char *hostName,
|
|
|
27aa74 |
- unsigned short portNumber, char *unixSocketName, pgsocket ListenSocket[],
|
|
|
27aa74 |
- int MaxListen);
|
|
|
27aa74 |
+extern int StreamServerPort(int family, char *hostName,
|
|
|
27aa74 |
+ unsigned short portNumber, char *unixSocketDir,
|
|
|
27aa74 |
+ pgsocket ListenSocket[], int MaxListen);
|
|
|
27aa74 |
extern int StreamConnection(pgsocket server_fd, Port *port);
|
|
|
27aa74 |
extern void StreamClose(pgsocket sock);
|
|
|
27aa74 |
-extern void TouchSocketFile(void);
|
|
|
27aa74 |
+extern void TouchSocketFiles(void);
|
|
|
27aa74 |
extern void pq_init(void);
|
|
|
27aa74 |
extern void pq_comm_reset(void);
|
|
|
27aa74 |
extern int pq_getbytes(char *s, size_t len);
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/include/miscadmin.h postgresql-9.2.5/src/include/miscadmin.h
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/include/miscadmin.h 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/include/miscadmin.h 2013-10-21 17:51:03.070676015 +0200
|
|
|
27aa74 |
@@ -411,7 +411,7 @@
|
|
|
27aa74 |
* 2 data directory path
|
|
|
27aa74 |
* 3 postmaster start timestamp (time_t representation)
|
|
|
27aa74 |
* 4 port number
|
|
|
27aa74 |
- * 5 socket directory path (empty on Windows)
|
|
|
27aa74 |
+ * 5 first Unix socket directory path (empty if none)
|
|
|
27aa74 |
* 6 first listen_address (IP address or "*"; empty if no TCP port)
|
|
|
27aa74 |
* 7 shared memory key (not present on Windows)
|
|
|
27aa74 |
*
|
|
|
27aa74 |
@@ -429,8 +429,9 @@
|
|
|
27aa74 |
#define LOCK_FILE_LINE_SHMEM_KEY 7
|
|
|
27aa74 |
|
|
|
27aa74 |
extern void CreateDataDirLockFile(bool amPostmaster);
|
|
|
27aa74 |
-extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster);
|
|
|
27aa74 |
-extern void TouchSocketLockFile(void);
|
|
|
27aa74 |
+extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster,
|
|
|
27aa74 |
+ const char *socketDir);
|
|
|
27aa74 |
+extern void TouchSocketLockFiles(void);
|
|
|
27aa74 |
extern void AddToDataDirLockFile(int target_line, const char *str);
|
|
|
27aa74 |
extern void ValidatePgVersion(const char *path);
|
|
|
27aa74 |
extern void process_shared_preload_libraries(void);
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/include/postmaster/postmaster.h postgresql-9.2.5/src/include/postmaster/postmaster.h
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/include/postmaster/postmaster.h 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/include/postmaster/postmaster.h 2013-10-21 17:51:03.071676021 +0200
|
|
|
27aa74 |
@@ -19,7 +19,7 @@
|
|
|
27aa74 |
extern int PostPortNumber;
|
|
|
27aa74 |
extern int Unix_socket_permissions;
|
|
|
27aa74 |
extern char *Unix_socket_group;
|
|
|
27aa74 |
-extern char *UnixSocketDir;
|
|
|
27aa74 |
+extern char *Unix_socket_directories;
|
|
|
27aa74 |
extern char *ListenAddresses;
|
|
|
27aa74 |
extern bool ClientAuthInProgress;
|
|
|
27aa74 |
extern int PreAuthDelay;
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/src/include/utils/builtins.h postgresql-9.2.5/src/include/utils/builtins.h
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/src/include/utils/builtins.h 2013-10-08 05:16:13.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/src/include/utils/builtins.h 2013-10-21 17:51:03.071676021 +0200
|
|
|
27aa74 |
@@ -754,6 +754,8 @@
|
|
|
27aa74 |
extern List *textToQualifiedNameList(text *textval);
|
|
|
27aa74 |
extern bool SplitIdentifierString(char *rawstring, char separator,
|
|
|
27aa74 |
List **namelist);
|
|
|
27aa74 |
+extern bool SplitDirectoriesString(char *rawstring, char separator,
|
|
|
27aa74 |
+ List **namelist);
|
|
|
27aa74 |
extern Datum replace_text(PG_FUNCTION_ARGS);
|
|
|
27aa74 |
extern text *replace_text_regexp(text *src_text, void *regexp,
|
|
|
27aa74 |
text *replace_text, bool glob);
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/html-stamp postgresql-9.2.5/doc/src/sgml/html-stamp
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/html-stamp 2013-10-08 05:48:15.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/html-stamp 2013-10-21 17:51:03.071676021 +0200
|
|
|
27aa74 |
@@ -0,0 +1 @@
|
|
|
27aa74 |
+hack
|
|
|
27aa74 |
diff -Naur -r postgresql-9.2.5.orig/doc/src/sgml/man-stamp postgresql-9.2.5/doc/src/sgml/man-stamp
|
|
|
27aa74 |
--- postgresql-9.2.5.orig/doc/src/sgml/man-stamp 2013-10-08 05:49:22.000000000 +0200
|
|
|
27aa74 |
+++ postgresql-9.2.5/doc/src/sgml/man-stamp 2013-10-21 17:51:03.071676021 +0200
|
|
|
27aa74 |
@@ -0,0 +1 @@
|
|
|
27aa74 |
+hack
|