Make socket option specify just the directory, not the full path.
authorBruce Momjian <bruce@momjian.us>
Wed, 22 Nov 2000 01:41:14 +0000 (01:41 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 22 Nov 2000 01:41:14 +0000 (01:41 +0000)
16 files changed:
doc/src/sgml/libpq++.sgml
doc/src/sgml/libpq.sgml
doc/src/sgml/ref/createdb.sgml
doc/src/sgml/ref/createlang.sgml
doc/src/sgml/ref/createuser.sgml
doc/src/sgml/ref/dropdb.sgml
doc/src/sgml/ref/droplang.sgml
doc/src/sgml/ref/dropuser.sgml
doc/src/sgml/ref/pg_dump.sgml
doc/src/sgml/ref/pg_dumpall.sgml
doc/src/sgml/ref/pg_restore.sgml
doc/src/sgml/ref/postmaster.sgml
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/vacuumdb.sgml
doc/src/sgml/runtime.sgml
src/include/libpq/pqcomm.h

index 723d95870624c8cf3b179aba7cf2f085186f4681..a2bd70068b8ec9645b9db9e3af41e53e26a27e62 100644 (file)
@@ -80,8 +80,8 @@ $Header$
       <listitem>
        <para>
        <envar>PGHOST</envar> sets the default server name.
-       If a non-zero-length string is specified, TCP/IP communication is used.
-       Without a host name, libpq will connect using a local Unix domain socket.
+        If it begins with a slash, it is used
+        as the directory for the unix domain socket.
        </para>
       </listitem>
       <listitem>
@@ -93,8 +93,8 @@ $Header$
       </listitem>
       <listitem>
        <para>
-       <envar>PGUNIXSOCKET</envar>  sets the full Unix domain socket
-       file name for communicating with the <productname>Postgres</productname>
+       <envar>PGUNIXSOCKET</envar>  sets the Unix domain socket
+       directory for communicating with the <productname>Postgres</productname>
        backend.
        </para>
       </listitem>
index 3a999f249c61bf99823163b1b8e8851c1c6710e4..19735f836cc457903d434f0078ca3a4ec88f6327 100644 (file)
@@ -90,7 +90,7 @@ PGconn *PQconnectdb(const char *conninfo)
       Name of host to connect to. 
       Using this parameter causes a hostname look-up.  See hostaddr.
       If it begins with a slash, it is used
-      as the path to a unix domain socket.
+      as the directory for the unix domain socket.
      </para>
      </listitem>
     </varlistentry>
@@ -138,7 +138,7 @@ PGconn *PQconnectdb(const char *conninfo)
      <term><literal>unixsocket</literal></term>
      <listitem>
      <para>
-      Full path to Unix-domain socket file to connect to at the server host.
+      Directory for Unix-domain socket file.
      </para>
      </listitem>
     </varlistentry>
@@ -567,7 +567,7 @@ char *PQport(const PGconn *conn)
 <listitem>
 <para>
 <function>PQunixsocket</function>
-         Returns the name of the Unix-domain socket of the connection.
+         Returns the directory of the Unix-domain socket of the connection.
 <synopsis>
 char *PQunixsocket(const PGconn *conn)
 </synopsis>
@@ -1839,9 +1839,8 @@ application programs.
 <listitem>
 <para>
 <envar>PGHOST</envar> sets the default server name.
-If it beings with a slash, it is used as the path to a unix domain
+If it beings with a slash, it is used as the directory for the unix domain
 socket.
-Without a host name, libpq will connect using a local Unix domain socket.
 </para>
 </listitem>
 <listitem>
index ac4561810bb4e414ed9c82ef3cc4d0873b958450..f51bc2b6ff4b3ac7db197ae7fd3f6ad3a73a32b0 100644 (file)
@@ -41,7 +41,7 @@ Postgres documentation
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index 7c4bc2f5e39c2cefd2473ff52e64d360bd50c17c..fbde8b82a2746838ea3be40c8d40eaf47a23ddec 100644 (file)
@@ -86,7 +86,7 @@ Postgres documentation
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index f6ed6469c4b8cb514c013186ce037bccad55c81e..241566acd83e3f4a975a243b4d6fcf9f62b1521c 100644 (file)
@@ -40,7 +40,7 @@ Postgres documentation
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index 3df5779228294d538b856322daecea7af08700e5..83b561059ee8e02fa834c40c88c449dbca9337b8 100644 (file)
@@ -40,7 +40,7 @@ Postgres documentation
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index 1b63c979cf5b2fb8a40f1b3052cb7d71ae754dd2..fc97e42c95650f82e2b5fcc058ad25c96fa153e4 100644 (file)
@@ -86,7 +86,7 @@ Postgres documentation
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index fe2883fd76240c8976b6c5bbe61d689802f69205..03d96856adcf14f82dd049cf397fe1f317329446 100644 (file)
@@ -40,7 +40,7 @@ Postgres documentation
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index c8a651d2463dc2f05ad53dd248513c4be7e608e5..0b62cdf49f40a889ae4a289108ad2092efda089e 100644 (file)
@@ -323,7 +323,7 @@ pg_dump [ -h <replaceable class="parameter">host</replaceable> ]
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index 85d9272a3883809205478212b393f3b9d8ee93aa..f11231a1df0e140188418ce0b024225adc6ac84b 100644 (file)
@@ -144,7 +144,7 @@ pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replac
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index 1af53a473842942dfa208289664bdbaf0cabe684..8af8226d9485ca8166b5b604fdeccaa05e225ac6 100644 (file)
@@ -308,7 +308,7 @@ pg_restore [ <replaceable class="parameter">archive-file</replaceable>  ]
        Specifies the hostname of the machine on which the
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index 525f4fe7ad40bdc8bfdeef5b47d0183d6773ae52..31e8332fcc84d2d5253b9add5af05621e9c0bf1a 100644 (file)
@@ -188,13 +188,12 @@ Postgres documentation
       <term>-k <replaceable class="parameter">filename</replaceable></term>
       <listitem>
        <para>
-       Specifies the Unix domain socket file name on which the
+       Specifies the directory for Unix domain socket on which the
        <application>postmaster</application> is to listen for
        connections from client applications.  Defaults to the value
        of the <envar>PGUNIXSOCKET</envar> environment variable, or if
        <envar>PGUNIXSOCKET</envar> is not set, then defaults to a
-       file in <filename>/tmp</filename> constructed from the port
-       number.
+       file in <filename>/tmp</filename>.
        </para>
       </listitem>
      </varlistentry>
index 4678bfc533c1f2952d3077f02473b6d343bc885e..5ba2f92d029d99645fff1f861762dd15168fb3ed 100644 (file)
@@ -1323,7 +1323,7 @@ Access permissions for database "test"
       Specifies the host name of the machine on which the
       <application>postmaster</application> is running.
       If host begins with a slash, it is used 
-      as the path to a unix domain socket.
+      as the directory for the unix domain socket.
       </para>
       </listitem>
     </varlistentry>
index e41c46d7c366f29f6b4c181f19d73b5f735b4015..4dd9be0591cd84a0a9ad3ad0afc9d96ba9b241f3 100644 (file)
@@ -120,7 +120,7 @@ Postgres documentation
        Specifies the hostname of the machine on which the 
        <application>postmaster</application>
        is running.  If host begins with a slash, it is used 
-       as the path to a unix domain socket.
+       as the directory for the unix domain socket.
        </para>
       </listitem>
      </varlistentry>
index eaecdede9194b6ed4353e9bc89f6f76ddf669c6e..0166c5a0d9f8a07ddf0494d8a1575da74cbae4d6 100644 (file)
@@ -1063,13 +1063,12 @@ env PGOPTIONS='-c geqo=off' psql
       <term>UNIXSOCKET (<type>string</type>)</term>
       <listitem>
        <para>
-       Specifies the Unix domain socket file name on which the
+       Specifies the directory of the Unix domain socket on which the
        <application>postmaster</application> is to listen for
        connections from client applications.  Defaults to the value
        of the <envar>PGUNIXSOCKET</envar> environment variable, or if
-       <envar>PGUNIXSOCKET</envar> is not set, then defaults to a
-       file in <filename>/tmp</filename> constructed from the port
-       number.
+       <envar>PGUNIXSOCKET</envar> is not set, then defaults to 
+        <filename>/tmp</filename>.
        </para>
       </listitem>
      </varlistentry>
index 02edc1d22d947ff992383c61f36443022fe129c0..0c4aa1ba4c6dddf70cecbab618a8e19202a23995 100644 (file)
@@ -51,17 +51,16 @@ typedef union SockAddr
 /* Configure the UNIX socket address for the well known port. */
 
 #if defined(SUN_LEN)
-#define UNIXSOCK_PATH(sun,port,defpath) \
-        ((defpath && defpath[0] != '\0') ? (strncpy((sun).sun_path, defpath, sizeof((sun).sun_path)), (sun).sun_path[sizeof((sun).sun_path)-1] = '\0') : sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)))
 #define UNIXSOCK_LEN(sun) \
         (SUN_LEN(&(sun)))
 #else
-#define UNIXSOCK_PATH(sun,port,defpath) \
-        ((defpath && defpath[0] != '\0') ? (strncpy((sun).sun_path, defpath, sizeof((sun).sun_path)), (sun).sun_path[sizeof((sun).sun_path)-1] = '\0') : sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)))
 #define UNIXSOCK_LEN(sun) \
         (strlen((sun).sun_path)+ offsetof(struct sockaddr_un, sun_path))
 #endif
 
+#define UNIXSOCK_PATH(sun,port,defpath) \
+        (snprintf((sun).sun_path, UNIXSOCK_LEN(sun), "%s/.s.PGSQL.%d", (defpath && *(defpath) != '\0') ? (defpath) : "/tmp", (port)))
+
 /*
  *             We do this because sun_len is in BSD's struct, while others don't.
  *             We never actually set BSD's sun_len, and I can't think of a