svn commit: samba r8961 - branches/SAMBA_3_0/source/lib
trunk/source/lib
jelmer at samba.org
jelmer at samba.org
Tue Aug 2 23:43:51 GMT 2005
Author: jelmer
Date: 2005-08-02 23:43:50 +0000 (Tue, 02 Aug 2005)
New Revision: 8961
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8961
Log:
Merge IRIX fix for socket wrapper
Modified:
branches/SAMBA_3_0/source/lib/socket_wrapper.c
trunk/source/lib/socket_wrapper.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/socket_wrapper.c
===================================================================
--- branches/SAMBA_3_0/source/lib/socket_wrapper.c 2005-08-02 23:24:50 UTC (rev 8960)
+++ branches/SAMBA_3_0/source/lib/socket_wrapper.c 2005-08-02 23:43:50 UTC (rev 8961)
@@ -94,6 +94,19 @@
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 @@
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 @@
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 @@
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) {
Modified: trunk/source/lib/socket_wrapper.c
===================================================================
--- trunk/source/lib/socket_wrapper.c 2005-08-02 23:24:50 UTC (rev 8960)
+++ trunk/source/lib/socket_wrapper.c 2005-08-02 23:43:50 UTC (rev 8961)
@@ -94,6 +94,19 @@
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 @@
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 @@
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 @@
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) {
More information about the samba-cvs
mailing list