Index: gss_init_sec_context.c
===================================================================
RCS file: /home/ncvs/src/lib/libgssapi/gss_init_sec_context.c,v
retrieving revision 1.2
diff -u -r1.2 gss_init_sec_context.c
--- gss_init_sec_context.c	4 Apr 2007 02:40:59 -0000	1.2
+++ gss_init_sec_context.c	2 Jun 2007 20:30:48 -0000
@@ -59,10 +59,20 @@
 	struct _gss_cred *cred = (struct _gss_cred *) initiator_cred_handle;
 	struct _gss_mechanism_cred *mc;
 	gss_cred_id_t cred_handle;
+	gss_OID mech;
 	int allocated_ctx;
 
 	*minor_status = 0;
 
+	if (mech_type == GSS_C_NO_OID) {
+		_gss_load_mech();
+		if (!SLIST_FIRST(&_gss_mechs))
+			return (GSS_S_BAD_MECH);
+		mech = &(SLIST_FIRST(&_gss_mechs)->gm_mech_oid);
+	} else {
+		mech = mech_type;
+	}
+
 	/*
 	 * If we haven't allocated a context yet, do so now and lookup
 	 * the mechanism switch table. If we have one already, make
@@ -75,7 +85,7 @@
 			return (GSS_S_FAILURE);
 		}
 		memset(ctx, 0, sizeof(struct _gss_context));
-		m = ctx->gc_mech = _gss_find_mech_switch(mech_type);
+		m = ctx->gc_mech = _gss_find_mech_switch(mech);
 		if (!m) {
 			free(ctx);
 			return (GSS_S_BAD_MECH);
@@ -89,7 +99,7 @@
 	/*
 	 * Find the MN for this mechanism.
 	 */
-	mn = _gss_find_mn(name, mech_type);
+	mn = _gss_find_mn(name, mech);
 
 	/*
 	 * If we have a cred, find the cred for this mechanism.
@@ -97,7 +107,7 @@
 	cred_handle = GSS_C_NO_CREDENTIAL;
 	if (cred) {
 		SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
-			if (_gss_oid_equal(mech_type, mc->gmc_mech_oid)) {
+			if (_gss_oid_equal(mech, mc->gmc_mech_oid)) {
 				cred_handle = mc->gmc_cred;
 				break;
 			}
@@ -108,7 +118,7 @@
 	    cred_handle,
 	    &ctx->gc_ctx,
 	    mn->gmn_name,
-	    mech_type,
+	    mech,
 	    req_flags,
 	    time_req,
 	    input_chan_bindings,
