summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-21 13:45:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:54 -0500
commit5086945689f10db74fbb2a4340c7e22469f9e8d8 (patch)
tree43b421f367091da7c685dc104cc6cf2c94e4d456 /source4/lib
parent563794083834b8e63c7f00ab2986a482adc5fd0c (diff)
downloadsamba-5086945689f10db74fbb2a4340c7e22469f9e8d8.tar.gz
samba-5086945689f10db74fbb2a4340c7e22469f9e8d8.tar.bz2
samba-5086945689f10db74fbb2a4340c7e22469f9e8d8.zip
r8681: if SOCKET_WRAPPER_DIR starts with ./ then strip it internally. This saves us 2 more chars
in the name, which is enough to get IRIX 6.4 working (This used to be commit e6d9cde482ad9f3fa91d9ce3638e2ec6530b3a9c)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
index d0d08d22b9..1c3d5c3bfc 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ b/source4/lib/socket_wrapper/socket_wrapper.c
@@ -95,6 +95,19 @@ struct socket_info
static struct socket_info *sockets = NULL;
+
+static const char *socket_wrapper_dir(void)
+{
+ const char *s = getenv("SOCKET_WRAPPER_DIR");
+ if (s == NULL) {
+ return NULL;
+ }
+ if (strncmp(s, "./", 2) == 0) {
+ s += 2;
+ }
+ return s;
+}
+
static int convert_un_in(const struct sockaddr_un *un, struct sockaddr_in *in, socklen_t *len)
{
unsigned int prt;
@@ -128,12 +141,12 @@ static int convert_in_un(struct socket_info *si, const struct sockaddr_in *in, s
prt = 5000;
do {
snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
- getenv("SOCKET_WRAPPER_DIR"), type, ++prt);
+ socket_wrapper_dir(), type, ++prt);
} while (stat(un->sun_path, &st) == 0 && prt < 10000);
((struct sockaddr_in *)si->myname)->sin_port = htons(prt);
}
snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
- getenv("SOCKET_WRAPPER_DIR"), type, prt);
+ socket_wrapper_dir(), type, prt);
return 0;
}
@@ -205,7 +218,7 @@ int swrap_socket(int domain, int type, int protocol)
struct socket_info *si;
int fd;
- if (!getenv("SOCKET_WRAPPER_DIR")) {
+ if (!socket_wrapper_dir()) {
return real_socket(domain, type, protocol);
}
@@ -280,7 +293,7 @@ static int swrap_auto_bind(struct socket_info *si)
for (i=0;i<1000;i++) {
snprintf(un_addr.sun_path, sizeof(un_addr.sun_path),
- "%s/"SOCKET_FORMAT, getenv("SOCKET_WRAPPER_DIR"),
+ "%s/"SOCKET_FORMAT, socket_wrapper_dir(),
SOCK_DGRAM, i + 10000);
if (bind(si->fd, (struct sockaddr *)&un_addr,
sizeof(un_addr)) == 0) {