svn commit: samba r21937 - in branches/SAMBA_3_0_25/source/libsmb: .

jra at samba.org jra at samba.org
Thu Mar 22 19:00:21 GMT 2007


Author: jra
Date: 2007-03-22 19:00:17 +0000 (Thu, 22 Mar 2007)
New Revision: 21937

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21937

Log:
Merge in changes from SAMBA_3_0 that should have
been done for 3.0.25 pre-release. Janitor for
libsmbclient maintainer :-(.
Jeremy.

Modified:
   branches/SAMBA_3_0_25/source/libsmb/libsmbclient.c


Changeset:
Modified: branches/SAMBA_3_0_25/source/libsmb/libsmbclient.c
===================================================================
--- branches/SAMBA_3_0_25/source/libsmb/libsmbclient.c	2007-03-22 18:43:40 UTC (rev 21936)
+++ branches/SAMBA_3_0_25/source/libsmb/libsmbclient.c	2007-03-22 19:00:17 UTC (rev 21937)
@@ -339,14 +339,15 @@
 	    goto decoding;
 
 	if (*p == '/') {
+		int wl = strlen(context->workgroup);
 
-		strncpy(server, context->workgroup, 
-			((strlen(context->workgroup) < 16)
-                         ? strlen(context->workgroup)
-                         : 16));
-                server[server_len - 1] = '\0';
+		if (wl > 16) {
+			wl = 16;
+		}
+
+		strncpy(server, context->workgroup, wl);
+                server[wl] = '\0';
 		return 0;
-		
 	}
 
 	/*
@@ -499,9 +500,31 @@
 smbc_check_server(SMBCCTX * context,
                   SMBCSRV * server) 
 {
-	if ( send_keepalive(server->cli->fd) == False )
-		return 1;
+        size_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;
 }
@@ -917,6 +940,7 @@
                  fstring password,
                  POLICY_HND *pol)
 {
+        int flags;
         struct in_addr ip;
 	struct cli_state *ipc_cli;
 	struct rpc_pipe_client *pipe_hnd;
@@ -951,12 +975,17 @@
                         }
                 }
         
+                flags = 0;
+                if (context->flags & SMB_CTX_FLAG_USE_KERBEROS) {
+                        flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+                }
+
                 zero_ip(&ip);
                 nt_status = cli_full_connection(&ipc_cli,
                                                 global_myname(), server, 
                                                 &ip, 0, "IPC$", "?????",  
                                                 username, workgroup,
-                                                password, 0,
+                                                password, flags,
                                                 Undefined, NULL);
                 if (! NT_STATUS_IS_OK(nt_status)) {
                         DEBUG(1,("cli_full_connection failed! (%s)\n",



More information about the samba-cvs mailing list