svn commit: samba r21132 - in branches/SAMBA_3_0/source: include libsmb

derrell at samba.org derrell at samba.org
Sat Feb 3 17:13:59 GMT 2007


Author: derrell
Date: 2007-02-03 17:13:58 +0000 (Sat, 03 Feb 2007)
New Revision: 21132

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

Log:
- Fixes bug 4366.  Documentation for smbc_utimes() was incorrect.

- Should fix bug 4115 (but needs confirmation from OP).  If the kerberos use
  flag is set in the context, then also pass it to smbc_attr_server for use by
  cli_full_connection()

- Should fix bug 4309 (but needs confirmation from OP).  We no longer send a
  keepalive packet unconditionally.  Instead, we assume (yes, possibly
  incorrectly, but it's the best guess we can make) that if the connection is
  on port 139, it's netbios and otherwise, it isn't.  If netbios is in use, we
  send a keepalive packet.  Otherwise, we check that the connection is alive
  using getpeername().

Modified:
   branches/SAMBA_3_0/source/include/libsmbclient.h
   branches/SAMBA_3_0/source/libsmb/libsmbclient.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/libsmbclient.h
===================================================================
--- branches/SAMBA_3_0/source/include/libsmbclient.h	2007-02-03 16:53:52 UTC (rev 21131)
+++ branches/SAMBA_3_0/source/include/libsmbclient.h	2007-02-03 17:13:58 UTC (rev 21132)
@@ -1242,14 +1242,16 @@
  */
 int smbc_chmod(const char *url, mode_t mode);
 
-/**@ingroup attribute
+/**
+ * @ingroup attribute
  * Change the last modification time on a file
  *
  * @param url       The smb url of the file or directory to change
  *                  the modification time of
- * 
- * @param tbuf      A timeval structure which contains the desired
- *                  modification time.  NOTE: Only the tv_sec field is
+ *
+ * @param tbuf      An array of two timeval structures which contains,
+ *                  respectively, the desired access and modification times.
+ *                  NOTE: Only the tv_sec field off each timeval structure is
  *                  used.  The tv_usec (microseconds) portion is ignored.
  *
  * @return          0 on success, < 0 on error with errno set:
@@ -1260,16 +1262,16 @@
 int smbc_utimes(const char *url, struct timeval *tbuf);
 
 #ifdef HAVE_UTIME_H
-/**@ingroup attribute
+/**
+ * @ingroup attribute
  * Change the last modification time on a file
  *
  * @param url       The smb url of the file or directory to change
  *                  the modification time of
- * 
- * @param utbuf     A utimebuf structure which contains the desired
- *                  modification time.  NOTE: Although the structure contains
- *                  an access time as well, the access time value is ignored.
  *
+ * @param utbuf     A pointer to a utimebuf structure which contains the
+ *                  desired access and modification times.
+ *
  * @return          0 on success, < 0 on error with errno set:
  *                  - EINVAL The client library is not properly initialized
  *                  - ENOMEM No memory was available for internal needs

Modified: branches/SAMBA_3_0/source/libsmb/libsmbclient.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/libsmbclient.c	2007-02-03 16:53:52 UTC (rev 21131)
+++ branches/SAMBA_3_0/source/libsmb/libsmbclient.c	2007-02-03 17:13:58 UTC (rev 21132)
@@ -499,9 +499,31 @@
 smbc_check_server(SMBCCTX * context,
                   SMBCSRV * server) 
 {
-	if ( send_keepalive(server->cli->fd) == False )
-		return 1;
+        int 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 +939,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 +974,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