aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2000-11-22 01:41:14 +0000
committerBruce Momjian <bruce@momjian.us>2000-11-22 01:41:14 +0000
commit98e195d23bbf08ec6a8c2b25e0eef6e518fb8124 (patch)
tree899d7f5f5960e7d7f21d514a657547d58f573baa /src
parent9bc6fb37b93d25470c000f86f93ea7509fdd1422 (diff)
downloadpostgresql-98e195d23bbf08ec6a8c2b25e0eef6e518fb8124.tar.gz
postgresql-98e195d23bbf08ec6a8c2b25e0eef6e518fb8124.zip
Make socket option specify just the directory, not the full path.
Diffstat (limited to 'src')
-rw-r--r--src/include/libpq/pqcomm.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index b013014ef3e..4d55d4a94bd 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -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