From 711fbe909b6bda6a557075b0ba6665ac470119e3 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 22 Nov 2000 01:41:14 +0000 Subject: [PATCH] Make socket option specify just the directory, not the full path. --- doc/src/sgml/libpq++.sgml | 8 ++++---- doc/src/sgml/libpq.sgml | 9 ++++----- doc/src/sgml/ref/createdb.sgml | 2 +- doc/src/sgml/ref/createlang.sgml | 2 +- doc/src/sgml/ref/createuser.sgml | 2 +- doc/src/sgml/ref/dropdb.sgml | 2 +- doc/src/sgml/ref/droplang.sgml | 2 +- doc/src/sgml/ref/dropuser.sgml | 2 +- doc/src/sgml/ref/pg_dump.sgml | 2 +- doc/src/sgml/ref/pg_dumpall.sgml | 2 +- doc/src/sgml/ref/pg_restore.sgml | 2 +- doc/src/sgml/ref/postmaster.sgml | 5 ++--- doc/src/sgml/ref/psql-ref.sgml | 2 +- doc/src/sgml/ref/vacuumdb.sgml | 2 +- doc/src/sgml/runtime.sgml | 7 +++---- src/include/libpq/pqcomm.h | 7 +++---- 16 files changed, 27 insertions(+), 31 deletions(-) diff --git a/doc/src/sgml/libpq++.sgml b/doc/src/sgml/libpq++.sgml index 723d958706..a2bd70068b 100644 --- a/doc/src/sgml/libpq++.sgml +++ b/doc/src/sgml/libpq++.sgml @@ -80,8 +80,8 @@ $Header$ 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$ - 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. diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 3a999f249c..19735f836c 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -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. diff --git a/doc/src/sgml/ref/createdb.sgml b/doc/src/sgml/ref/createdb.sgml index ac4561810b..f51bc2b6ff 100644 --- a/doc/src/sgml/ref/createdb.sgml +++ b/doc/src/sgml/ref/createdb.sgml @@ -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. diff --git a/doc/src/sgml/ref/createlang.sgml b/doc/src/sgml/ref/createlang.sgml index 7c4bc2f5e3..fbde8b82a2 100644 --- a/doc/src/sgml/ref/createlang.sgml +++ b/doc/src/sgml/ref/createlang.sgml @@ -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. diff --git a/doc/src/sgml/ref/createuser.sgml b/doc/src/sgml/ref/createuser.sgml index f6ed6469c4..241566acd8 100644 --- a/doc/src/sgml/ref/createuser.sgml +++ b/doc/src/sgml/ref/createuser.sgml @@ -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. diff --git a/doc/src/sgml/ref/dropdb.sgml b/doc/src/sgml/ref/dropdb.sgml index 3df5779228..83b561059e 100644 --- a/doc/src/sgml/ref/dropdb.sgml +++ b/doc/src/sgml/ref/dropdb.sgml @@ -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. diff --git a/doc/src/sgml/ref/droplang.sgml b/doc/src/sgml/ref/droplang.sgml index 1b63c979cf..fc97e42c95 100644 --- a/doc/src/sgml/ref/droplang.sgml +++ b/doc/src/sgml/ref/droplang.sgml @@ -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. diff --git a/doc/src/sgml/ref/dropuser.sgml b/doc/src/sgml/ref/dropuser.sgml index fe2883fd76..03d96856ad 100644 --- a/doc/src/sgml/ref/dropuser.sgml +++ b/doc/src/sgml/ref/dropuser.sgml @@ -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. diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index c8a651d246..0b62cdf49f 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -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. diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml index 85d9272a38..f11231a1df 100644 --- a/doc/src/sgml/ref/pg_dumpall.sgml +++ b/doc/src/sgml/ref/pg_dumpall.sgml @@ -144,7 +144,7 @@ pg_dumpall [ -h host ] [ -p 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. diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index 1af53a4738..8af8226d94 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -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. diff --git a/doc/src/sgml/ref/postmaster.sgml b/doc/src/sgml/ref/postmaster.sgml index 525f4fe7ad..31e8332fcc 100644 --- a/doc/src/sgml/ref/postmaster.sgml +++ b/doc/src/sgml/ref/postmaster.sgml @@ -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. diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 4678bfc533..5ba2f92d02 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -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. diff --git a/doc/src/sgml/ref/vacuumdb.sgml b/doc/src/sgml/ref/vacuumdb.sgml index e41c46d7c3..4dd9be0591 100644 --- a/doc/src/sgml/ref/vacuumdb.sgml +++ b/doc/src/sgml/ref/vacuumdb.sgml @@ -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. diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index eaecdede91..0166c5a0d9 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -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. diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h index 02edc1d22d..0c4aa1ba4c 100644 --- a/src/include/libpq/pqcomm.h +++ b/src/include/libpq/pqcomm.h @@ -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 -- 2.39.5