svn commit: samba r24863 - in branches/SAMBA_3_0_25:
examples/libsmbclient source/libsmb
derrell at samba.org
derrell at samba.org
Sat Sep 1 18:31:35 GMT 2007
Author: derrell
Date: 2007-09-01 18:31:34 +0000 (Sat, 01 Sep 2007)
New Revision: 24863
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24863
Log:
- Correct failure of libsmbclient against a version of Windows found on a NAS
device. The device resets a NBT connection on port 139 when it receives a
NetBIOS keepalive request. That request should be supported when NetBIOS is
in use; Windows is behaving badly.
libsmbclient needs a way to determine if a connection is still alive, and
was using a NetBIOS keepalive request if port 139 was in use (on the
assumption that it was probably NBT), and getpeername() when port 139 was
not being used (assuming naked transport).
This patch simplifies the code by exclusively using getpeername() to check
whether a connection is still alive. The NetBIOS keepalive request is
optional anyway (with preference being given to using TCP mechanisms for the
same purpose), so this should be both simpler and more reliable.
Derrell
Modified:
branches/SAMBA_3_0_25/examples/libsmbclient/Makefile
branches/SAMBA_3_0_25/source/libsmb/libsmbclient.c
Changeset:
Modified: branches/SAMBA_3_0_25/examples/libsmbclient/Makefile
===================================================================
--- branches/SAMBA_3_0_25/examples/libsmbclient/Makefile 2007-09-01 02:34:12 UTC (rev 24862)
+++ branches/SAMBA_3_0_25/examples/libsmbclient/Makefile 2007-09-01 18:31:34 UTC (rev 24863)
@@ -10,12 +10,12 @@
DEFS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
CFLAGS = -O0 -g -I$(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS)
-LDFLAGS = -L/usr/local/samba/lib
+LDFLAGS = -L/usr/local/samba/lib \
+ -lldap -lkrb5 -lgssapi_krb5
#LIBSMBCLIENT = /usr/local/samba/lib/libsmbclient.so
LIBSMBCLIENT = ../../source/bin/libsmbclient.a -ldl -lresolv
TESTS= testsmbc \
- tree \
testacl \
testacl2 \
testbrowse \
@@ -26,6 +26,8 @@
testutime \
testread
+# tree \
+
all: $(TESTS) smbsh
testsmbc: testsmbc.o
@@ -38,11 +40,11 @@
testacl: testacl.o
@echo Linking testacl
- $(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ $< `gtk-config --libs` $(LIBSMBCLIENT) -lpopt
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
testacl2: testacl2.o
@echo Linking testacl2
- $(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ $< `gtk-config --libs` $(LIBSMBCLIENT) -lpopt
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
testbrowse: testbrowse.o
@echo Linking testbrowse
Modified: branches/SAMBA_3_0_25/source/libsmb/libsmbclient.c
===================================================================
--- branches/SAMBA_3_0_25/source/libsmb/libsmbclient.c 2007-09-01 02:34:12 UTC (rev 24862)
+++ branches/SAMBA_3_0_25/source/libsmb/libsmbclient.c 2007-09-01 18:31:34 UTC (rev 24863)
@@ -503,30 +503,8 @@
socklen_t size;
struct sockaddr addr;
- /*
- * Although the use of port 139 is not a guarantee that we're using
- * netbios, we assume so. We don't want to send a keepalive packet if
- * not netbios because it's not valid, and Vista, at least,
- * disconnects the client on such a request.
- */
- if (server->cli->port == 139) {
- /* Assuming netbios. Send a keepalive packet */
- if ( send_keepalive(server->cli->fd) == False ) {
- return 1;
- }
- } else {
- /*
- * Assuming not netbios. Try a different method to detect if
- * the connection is still alive.
- */
- size = sizeof(addr);
- if (getpeername(server->cli->fd, &addr, &size) == -1) {
- return 1;
- }
- }
-
- /* connection is ok */
- return 0;
+ size = sizeof(addr);
+ return (getpeername(server->cli->fd, &addr, &size) == -1);
}
/*
More information about the samba-cvs
mailing list