Make socket option specify just the directory, not the full path.
authorBruce Momjian
Wed, 22 Nov 2000 01:41:14 +0000 (01:41 +0000)
committerBruce Momjian
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 a3b045e219ca91752a77db4ae6fc2667a5b8507c..43cf4ad1d504aee37c659214ed948f7689a9463a 100644 (file)
@@ -1,5 +1,5 @@
 
 
  
@@ -80,8 +80,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.18 2000/11/13 15:18:
       
        
    PGHOST 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.
        
       
       
@@ -93,8 +93,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.18 2000/11/13 15:18:
       
       
        
-   PGUNIXSOCKET  sets the full Unix domain socket
-   file name for communicating with the Postgres
+   PGUNIXSOCKET  sets the Unix domain socket
+   directory for communicating with the Postgres
    backend.
        
       
index bb6dc844a1b37efbaa79165c5c52e669e993741b..12da7edcca105e402cb0649a585412e09b643f65 100644 (file)
@@ -1,5 +1,5 @@
 
 
  
@@ -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.
      
      
     
@@ -138,7 +138,7 @@ PGconn *PQconnectdb(const char *conninfo)
      unixsocket
      
      
-      Full path to Unix-domain socket file to connect to at the server host.
+      Directory for Unix-domain socket file.
      
      
     
@@ -567,7 +567,7 @@ char *PQport(const PGconn *conn)
 
 
 PQunixsocket
-         Returns the name of the Unix-domain socket of the connection.
+         Returns the directory of the Unix-domain socket of the connection.
 
 char *PQunixsocket(const PGconn *conn)
 
@@ -1839,9 +1839,8 @@ application programs.
 
 
 PGHOST 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.
 
 
 
index eb5292cdc41db48f61142124522eec9b78323a8b..edb52210063b8c77a8f971504d07f422da11d6e0 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -41,7 +41,7 @@ Postgres documentation
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index 3e8242481f6cbd91be7a270df726d1a5ebebad24..03aa19d3e7899074fe6e219cc4f04f7f660fd059 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -86,7 +86,7 @@ Postgres documentation
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index 2a735900a54dc7722af729d29331411aa138d587..ee76f73abf438bced4767fe154b12d2257a57278 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -40,7 +40,7 @@ Postgres documentation
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index ab57c8c883bb7f4e56d34e9baa1354cba4f8edf4..fba806e0351703424f29d48dd80a84041b0029ff 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -40,7 +40,7 @@ Postgres documentation
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index 531d9859f700c2ecc20a614c4ab95db7aa88a70e..41ba3ae042049d3317c631d188f05088136788e6 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -86,7 +86,7 @@ Postgres documentation
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index 7b2a2ee9d4f81c83ded5134157d3c7dbd3465aed..4f7d1fc3a8b764312714082142b3e684f9e39b86 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -40,7 +40,7 @@ Postgres documentation
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index 452cdbf253d5530ec224f412c08209af315a3d16..925e5c72cf8c12014518f0b42bf18e435b7ac7fc 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -323,7 +323,7 @@ pg_dump [ -h host ]
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index a75a0c5e1c4b1c8a3a991c52b1cb7f422da7f78e..907dcbb3b2d931c611cf6b27f0f460e7621c0f51 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -144,7 +144,7 @@ pg_dumpall [ -h host ] [ -p 
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index 1af53a473842942dfa208289664bdbaf0cabe684..8af8226d9485ca8166b5b604fdeccaa05e225ac6 100644 (file)
@@ -308,7 +308,7 @@ pg_restore [ archive-file  ]
    Specifies the hostname of the machine on which the
    postmaster
    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.
        
       
      
index 0c9d1eb32c7a29280763839f33221f042bd39c88..beb6c0ee93f661301e00cc4a85c36e5ec8148298 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -188,13 +188,12 @@ Postgres documentation
       -k filename
       
        
-   Specifies the Unix domain socket file name on which the
+   Specifies the directory for Unix domain socket on which the
    postmaster is to listen for
    connections from client applications.  Defaults to the value
    of the PGUNIXSOCKET environment variable, or if
    PGUNIXSOCKET is not set, then defaults to a
-   file in /tmp constructed from the port
-   number.
+   file in /tmp.
        
       
      
index 69075391d6aaf86bc77b51cc687bfcc2471832d2..a90e98cd7bfb46817c684b7120de39b24a99b3a7 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -1323,7 +1323,7 @@ Access permissions for database "test"
       Specifies the host name of the machine on which the
       postmaster 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.
       
       
     
index 69e9888f56fbcdb1db22c75c2b3019af230c87c7..438af3159cc7a87ebe0c0631f32ed95e29ed1b9f 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -120,7 +120,7 @@ Postgres documentation
    Specifies the hostname of the machine on which the 
    postmaster
    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.
        
       
      
index 510c49a62f8bdb0631d8c9d28165840bd093c710..ffe87c536735cd4405e0e3500c8f0fce6462777c 100644 (file)
@@ -1,5 +1,5 @@
 
 
 
@@ -1063,13 +1063,12 @@ env PGOPTIONS='-c geqo=off' psql
       UNIXSOCKET (string)
       
        
-   Specifies the Unix domain socket file name on which the
+   Specifies the directory of the Unix domain socket on which the
    postmaster is to listen for
    connections from client applications.  Defaults to the value
    of the PGUNIXSOCKET environment variable, or if
-   PGUNIXSOCKET is not set, then defaults to a
-   file in /tmp constructed from the port
-   number.
+   PGUNIXSOCKET is not set, then defaults to 
+        /tmp.
        
       
      
index b013014ef3ee7f57b8e060f17f25af27909631e2..4d55d4a94bd38bc66f44018abbcc81298fbb3776 100644 (file)
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pqcomm.h,v 1.45 2000/11/15 18:36:06 petere Exp $
+ * $Id: pqcomm.h,v 1.46 2000/11/22 01:41:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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