svn commit: samba r8671 - in branches/SAMBA_4_0/source:
build/smb_build lib/socket_wrapper script/tests
tridge at samba.org
tridge at samba.org
Thu Jul 21 08:42:18 GMT 2005
Author: tridge
Date: 2005-07-21 08:42:17 +0000 (Thu, 21 Jul 2005)
New Revision: 8671
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8671
Log:
use much shorter names for the selftest directory and socket wrapper
code. I'm afraid this is needed by irix 6.4 which silently truncates
names in unix domain sockets in recvfrom() to 16 chars. My apologies
for having to move to such short names :-(
Modified:
branches/SAMBA_4_0/source/build/smb_build/makefile.pm
branches/SAMBA_4_0/source/lib/socket_wrapper/socket_wrapper.c
branches/SAMBA_4_0/source/script/tests/selftest.sh
Changeset:
Modified: branches/SAMBA_4_0/source/build/smb_build/makefile.pm
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/makefile.pm 2005-07-21 08:34:54 UTC (rev 8670)
+++ branches/SAMBA_4_0/source/build/smb_build/makefile.pm 2005-07-21 08:42:17 UTC (rev 8671)
@@ -148,17 +148,17 @@
test: @DEFAULT_TEST_TARGET@
test-swrap: all
- ./script/tests/selftest.sh @selftest_prefix@/prefix-test all SOCKET_WRAPPER
+ ./script/tests/selftest.sh @selftest_prefix@/st all SOCKET_WRAPPER
test-noswrap: all
- ./script/tests/selftest.sh @selftest_prefix@/prefix-test all
+ ./script/tests/selftest.sh @selftest_prefix@/st all
quicktest: all
- ./script/tests/selftest.sh @selftest_prefix@/prefix-test quick SOCKET_WRAPPER
+ ./script/tests/selftest.sh @selftest_prefix@/st quick SOCKET_WRAPPER
valgrindtest: all
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
- ./script/tests/selftest.sh @selftest_prefix@/prefix-test quick SOCKET_WRAPPER
+ ./script/tests/selftest.sh @selftest_prefix@/st quick SOCKET_WRAPPER
__EOD__
}
Modified: branches/SAMBA_4_0/source/lib/socket_wrapper/socket_wrapper.c
===================================================================
--- branches/SAMBA_4_0/source/lib/socket_wrapper/socket_wrapper.c 2005-07-21 08:34:54 UTC (rev 8670)
+++ branches/SAMBA_4_0/source/lib/socket_wrapper/socket_wrapper.c 2005-07-21 08:42:17 UTC (rev 8671)
@@ -57,6 +57,14 @@
#define real_close close
#endif
+/* we need to use a very terse format here as IRIX 6.4 silently
+ truncates names to 16 chars, so if we use a longer name then we
+ can't tell which port a packet came from with recvfrom()
+
+ with this format we have 8 chars left for the directory name
+*/
+#define SOCKET_FORMAT "%u_%u"
+
static struct sockaddr *sockaddr_dup(const void *data, socklen_t len)
{
struct sockaddr *ret = (struct sockaddr *)malloc(len);
@@ -102,7 +110,7 @@
p = strrchr(un->sun_path, '/');
if (p) p++; else p = un->sun_path;
- if (sscanf(p, "sock_ip_%d_%u", &type, &prt) == 2) {
+ if (sscanf(p, SOCKET_FORMAT, &type, &prt) == 2) {
in->sin_port = htons(prt);
}
in->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
@@ -119,12 +127,12 @@
/* handle auto-allocation of ephemeral ports */
prt = 5000;
do {
- snprintf(un->sun_path, sizeof(un->sun_path), "%s/sock_ip_%d_%u",
+ snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
getenv("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/sock_ip_%d_%u",
+ snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
getenv("SOCKET_WRAPPER_DIR"), type, prt);
return 0;
}
@@ -230,6 +238,8 @@
return real_accept(s, addr, addrlen);
}
+ memset(&un_addr, 0, sizeof(un_addr));
+
ret = real_accept(s, (struct sockaddr *)&un_addr, &un_addrlen);
if (ret == -1) return ret;
@@ -270,7 +280,7 @@
for (i=0;i<1000;i++) {
snprintf(un_addr.sun_path, sizeof(un_addr.sun_path),
- "%s/sock_ip_%u_%u", getenv("SOCKET_WRAPPER_DIR"),
+ "%s/"SOCKET_FORMAT, getenv("SOCKET_WRAPPER_DIR"),
SOCK_DGRAM, i + 10000);
if (bind(si->fd, (struct sockaddr *)&un_addr,
sizeof(un_addr)) == 0) {
@@ -458,6 +468,8 @@
return real_recvfrom(s, buf, len, flags, from, fromlen);
}
+ /* irix 6.4 forgets to null terminate the sun_path string :-( */
+ memset(&un_addr, 0, sizeof(un_addr));
ret = real_recvfrom(s, buf, len, flags, (struct sockaddr *)&un_addr, &un_addrlen);
if (ret == -1)
return ret;
Modified: branches/SAMBA_4_0/source/script/tests/selftest.sh
===================================================================
--- branches/SAMBA_4_0/source/script/tests/selftest.sh 2005-07-21 08:34:54 UTC (rev 8670)
+++ branches/SAMBA_4_0/source/script/tests/selftest.sh 2005-07-21 08:42:17 UTC (rev 8671)
@@ -60,7 +60,7 @@
DO_SOCKET_WRAPPER=$3
if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then
- SOCKET_WRAPPER_DIR="$PREFIX/socket_wrapper_dir"
+ SOCKET_WRAPPER_DIR="$PREFIX/sw"
export SOCKET_WRAPPER_DIR
echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR"
fi
More information about the samba-cvs
mailing list