svn commit: samba r4969 - in trunk/source: include libsmb

jra at samba.org jra at samba.org
Mon Jan 24 20:21:00 GMT 2005


Author: jra
Date: 2005-01-24 20:21:00 +0000 (Mon, 24 Jan 2005)
New Revision: 4969

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

Log:
Fix for bug 2092, allowing fallback after kerberos and allow
gnome vfs to prevent auto-anonymous logon.
Jeremy.

Modified:
   trunk/source/include/client.h
   trunk/source/include/libsmbclient.h
   trunk/source/libsmb/cliconnect.c
   trunk/source/libsmb/libsmbclient.c


Changeset:
Modified: trunk/source/include/client.h
===================================================================
--- trunk/source/include/client.h	2005-01-24 19:33:31 UTC (rev 4968)
+++ trunk/source/include/client.h	2005-01-24 20:21:00 UTC (rev 4969)
@@ -144,6 +144,7 @@
 	uint16 max_recv_frag;
 
 	BOOL use_kerberos;
+	BOOL fallback_after_kerberos;
 	BOOL use_spnego;
 
 	BOOL use_oplocks; /* should we use oplocks? */

Modified: trunk/source/include/libsmbclient.h
===================================================================
--- trunk/source/include/libsmbclient.h	2005-01-24 19:33:31 UTC (rev 4968)
+++ trunk/source/include/libsmbclient.h	2005-01-24 20:21:00 UTC (rev 4969)
@@ -455,9 +455,15 @@
 	 * do _NOT_ touch this from your program !
 	 */
 	struct smbc_internal_data * internal;
+
+	int flags;
 	
 };
 
+/* Flags for SMBCCTX->flags */
+#define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
+#define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
+#define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */
 
 /**@ingroup misc
  * Create a new SBMCCTX (a context).

Modified: trunk/source/libsmb/cliconnect.c
===================================================================
--- trunk/source/libsmb/cliconnect.c	2005-01-24 19:33:31 UTC (rev 4968)
+++ trunk/source/libsmb/cliconnect.c	2005-01-24 20:21:00 UTC (rev 4969)
@@ -757,13 +757,17 @@
 			if (ret){
 				SAFE_FREE(principal);
 				DEBUG(0, ("Kinit failed: %s\n", error_message(ret)));
+				if (cli->fallback_after_kerberos)
+					goto ntlmssp;
 				return ADS_ERROR_KRB5(ret);
 			}
 		}
 		
 		rc = cli_session_setup_kerberos(cli, principal, domain);
-		SAFE_FREE(principal);
-		return rc;
+		if (ADS_ERR_OK(rc) || !cli->fallback_after_kerberos) {
+			SAFE_FREE(principal);
+			return rc;
+		}
 	}
 #endif
 

Modified: trunk/source/libsmb/libsmbclient.c
===================================================================
--- trunk/source/libsmb/libsmbclient.c	2005-01-24 19:33:31 UTC (rev 4968)
+++ trunk/source/libsmb/libsmbclient.c	2005-01-24 20:21:00 UTC (rev 4969)
@@ -584,6 +584,13 @@
 		return NULL;
 	}
 
+	if (context->flags & SMB_CTX_FLAG_USE_KERBEROS) {
+		c.use_kerberos = True;
+	}
+	if (context->flags & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) {
+		c.fallback_after_kerberos = True;
+	}
+
 	c.timeout = context->timeout;
 
         /* Force use of port 139 for first try, so browse lists can work */
@@ -648,8 +655,9 @@
 			       password, strlen(password),
 			       password, strlen(password),
 			       workgroup) &&
-	    /* try an anonymous login if it failed */
-	    !cli_session_setup(&c, "", "", 1,"", 0, workgroup)) {
+			/* Try an anonymous login if it failed and this was allowed by flags. */
+			((context->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) ||
+			!cli_session_setup(&c, "", "", 1,"", 0, workgroup))) {
 		cli_shutdown(&c);
 		errno = EPERM;
 		return NULL;



More information about the samba-cvs mailing list