diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-08-02 23:43:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:00:22 -0500 |
commit | 08ebcb09418a359bbf1eaeb650364fe3ee50f491 (patch) | |
tree | 01715d631e9fc379a6b32f331eab87e46dcca4c5 | |
parent | abb81cfe2688dec69fe154d3abff8eff388c779c (diff) | |
download | samba-08ebcb09418a359bbf1eaeb650364fe3ee50f491.tar.gz samba-08ebcb09418a359bbf1eaeb650364fe3ee50f491.tar.bz2 samba-08ebcb09418a359bbf1eaeb650364fe3ee50f491.zip |
r8961: Merge IRIX fix for socket wrapper
(This used to be commit bd49c3133988300969e64a20c6c85fff768b985b)
-rw-r--r-- | source3/lib/socket_wrapper.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/source3/lib/socket_wrapper.c b/source3/lib/socket_wrapper.c index 808d62601f..9d65aa923a 100644 --- a/source3/lib/socket_wrapper.c +++ b/source3/lib/socket_wrapper.c @@ -94,6 +94,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; @@ -127,12 +140,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; } @@ -204,7 +217,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); } @@ -279,7 +292,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) { |