svn commit: samba r13011 - in trunk/source/libsmb: .

jra at samba.org jra at samba.org
Wed Jan 18 19:25:17 GMT 2006


Author: jra
Date: 2006-01-18 19:25:16 +0000 (Wed, 18 Jan 2006)
New Revision: 13011

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

Log:
Fix #3421 - it turns out krb5_kt_get_entry() on MIT
does an implicit open/read/close and blows away an
open keytab handle - so make sure we use a new
handle.
Wonderful analysis from Luke <ldeller at xplantechnology.com>
helped fix this.
Jeremy.

Modified:
   trunk/source/libsmb/clikrb5.c


Changeset:
Modified: trunk/source/libsmb/clikrb5.c
===================================================================
--- trunk/source/libsmb/clikrb5.c	2006-01-18 17:46:56 UTC (rev 13010)
+++ trunk/source/libsmb/clikrb5.c	2006-01-18 19:25:16 UTC (rev 13011)
@@ -770,7 +770,6 @@
 
 static krb5_error_code
 get_key_from_keytab(krb5_context context,
-		    krb5_keytab keytab,
 		    krb5_const_principal server,
 		    krb5_enctype enctype,
 		    krb5_kvno kvno,
@@ -778,13 +777,18 @@
 {
 	krb5_keytab_entry entry;
 	krb5_error_code ret;
-	krb5_keytab real_keytab;
+	krb5_keytab keytab;
 	char *name = NULL;
 
-	if (keytab == NULL) {
-		krb5_kt_default(context, &real_keytab);
-	} else {
-		real_keytab = keytab;
+	/* We have to open a new keytab handle here, as MIT does
+	   an implicit open/getnext/close on krb5_kt_get_entry. We
+	   may be in the middle of a keytab enumeration when this is
+	   called. JRA. */
+
+	ret = krb5_kt_default(context, &keytab);
+	if (ret) {
+		DEBUG(0,("get_key_from_keytab: failed to open keytab: %s\n", error_message(ret)));
+		return ret;
 	}
 
 	if ( DEBUGLEVEL >= 10 ) {
@@ -795,7 +799,7 @@
 	}
 
 	ret = krb5_kt_get_entry(context,
-				real_keytab,
+				keytab,
 				server,
 				kvno,
 				enctype,
@@ -822,10 +826,7 @@
 	smb_krb5_kt_free_entry(context, &entry);
 	
 out:    
-	if (keytab == NULL) {
-		krb5_kt_close(context, real_keytab);
-	}
-		
+	krb5_kt_close(context, keytab);
 	return ret;
 }
 
@@ -916,7 +917,6 @@
 	}
 
 	ret = get_key_from_keytab(context, 
-				  keytab,
 				  server,
 				  enctype,
 				  kvno,



More information about the samba-cvs mailing list