Return-Path: Received: from pch.mit.edu (PCH.MIT.EDU [18.7.21.90]) by krbdev.mit.edu (Postfix) with ESMTP id E0CE3CCF26; Wed, 23 Dec 2009 02:29:30 +0000 (UTC) Received: from pch.mit.edu (pch.mit.edu [127.0.0.1]) by pch.mit.edu (8.13.6/8.12.8) with ESMTP id nBN2TUH8017146; Tue, 22 Dec 2009 21:29:30 -0500 Received: from fort-point-station.mit.edu (FORT-POINT-STATION.MIT.EDU [18.7.7.76]) by pch.mit.edu (8.13.6/8.12.8) with ESMTP id nBN11NBA005457 for ; Tue, 22 Dec 2009 20:01:23 -0500 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by fort-point-station.mit.edu (8.13.6/8.9.2) with ESMTP id nBN10PlD028397 for ; Tue, 22 Dec 2009 20:01:22 -0500 (EST) X-Auditid: 1209190f-b7c03ae000006948-7f-4b316bc9cf26 Received: from outbound.mse3.exchange.ms (outbound.mse3.exchange.ms [69.25.50.242]) by (Symantec Brightmail Gateway) with SMTP id 9C.FA.26952.9CB613B4; Tue, 22 Dec 2009 20:00:58 -0500 (EST) X-Mimeole: Produced By Microsoft Exchange V6.5 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-CR-Puzzleid: {1E9A6E1E-DA97-4994-8C41-700E18E7C3D8} X-CR-Hashedpuzzle: ndE= BBos BaBP CLmL ElH1 GDbB HTXQ H7XP ICBd ItFi I5Fz JXEm KFAO KdkH LLdu L3Cx; 1; awByAGIANQAtAGIAdQBnAHMAQABtAGkAdAAuAGUAZAB1AA==; Sosha1_v1; 7; {1E9A6E1E-DA97-4994-8C41-700E18E7C3D8}; YQBiAGUAcgByAHkAQABsAGkAawBlAHcAaQBzAGUALgBjAG8AbQA=; Wed, 23 Dec 2009 01:00:50 GMT; aQBzAHMAdQBlAHMAIAB3AGkAdABoACAAZwBzAHMAXwBpAG4AcQB1AGkAcgBlAF8AYwBvAG4AdABlAHgAdAAgAGEAbgBkACAAZwBzAHMAXwBkAGkAcwBwAGwAYQB5AF8AYwBvAG4AdABlAHgAdAAgAHcAaABlAG4AIAB1AHMAaQBuAGcAIABTAFAATgBFAEcATwA= Content-Class: urn:content-classes:message Subject: issues with gss_inquire_context and gss_display_context when using SPNEGO Date: Tue, 22 Dec 2009 20:00:50 -0500 Message-ID: <23447137FA0DAA4D95EF535FF356BE4603B75823@mse3be2.mse3.exchange.ms> X-MS-Has-Attach: X-MS-Tnef-Correlator: Thread-Topic: issues with gss_inquire_context and gss_display_context when using SPNEGO Thread-Index: AcqDa16Ojy0KrVFPSxy3DP2l0D4j6Q== From: "Arlene Berry" To: X-Brightmail-Tracker: AAAAARIzKxY= X-Spam-Score: -2.599 X-Spam-Flag: NO X-Scanned-BY: MIMEDefang 2.42 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by pch.mit.edu id nBN11NBA005457 X-Mailman-Approved-At: Tue, 22 Dec 2009 21:29:28 -0500 X-Beenthere: krb5-bugs-incoming@mailman.mit.edu X-Mailman-Version: 2.1.6 Precedence: list Sender: krb5-bugs-incoming-bounces@PCH.mit.edu Errors-To: krb5-bugs-incoming-bounces@PCH.mit.edu X-RT-Original-Encoding: us-ascii Content-Length: 4817 When using SPNEGO the resulting security context is a union context with type SPNEGO which contains another union context which contains the actual mechanism. This double union context causes gss_inquire_context to report SPNEGO for the mechanism rather than the actual mechanism and causes gss_display_status to not work for mechanism error codes since the SPNEGO version of gss_display_status only translates SPNEGO error codes. Per Sam Hartman there was talk of collapsing the double union context into a single context. This patch does that which fixes both issues. Note that this requires the fix for bug #6598. Index: src/lib/gssapi/mechglue/g_accept_sec_context.c =================================================================== --- src/lib/gssapi/mechglue/g_accept_sec_context.c (revision 23482) +++ src/lib/gssapi/mechglue/g_accept_sec_context.c (working copy) @@ -333,6 +333,23 @@ } } + if (status == GSS_S_COMPLETE && actual_mech) { + gss_OID temp_mech_type = union_ctx_id->mech_type; + + status = generic_gss_copy_oid(minor_status, actual_mech, + &union_ctx_id->mech_type); + if (status != GSS_S_COMPLETE) { + gssint_delete_internal_sec_context(&temp_minor_status, + actual_mech, + &union_ctx_id->internal_ctx_id, + NULL); + free(union_ctx_id); + *context_handle = GSS_C_NO_CONTEXT; + } + free(temp_mech_type->elements); + free(temp_mech_type); + } + if (mech_type != NULL) *mech_type = actual_mech; else Index: src/lib/gssapi/mechglue/g_init_sec_context.c =================================================================== --- src/lib/gssapi/mechglue/g_init_sec_context.c (revision 23482) +++ src/lib/gssapi/mechglue/g_init_sec_context.c (working copy) @@ -117,6 +117,7 @@ gss_name_t internal_name; gss_union_ctx_id_t union_ctx_id; gss_OID mech_type = (gss_OID) req_mech_type; + gss_OID local_actual_mech = GSS_C_NO_OID; gss_mechanism mech; gss_cred_id_t input_cred_handle; @@ -218,7 +219,7 @@ time_req, input_chan_bindings, input_token, - actual_mech_type, + &local_actual_mech, output_token, ret_flags, time_rec); @@ -240,7 +241,28 @@ union_ctx_id->loopback = union_ctx_id; *context_handle = (gss_ctx_id_t)union_ctx_id; } + if (status == GSS_S_COMPLETE && local_actual_mech) { + gss_OID temp_mech_type = union_ctx_id->mech_type; + status = generic_gss_copy_oid(minor_status, local_actual_mech, + &union_ctx_id->mech_type); + if (status != GSS_S_COMPLETE) { + gssint_delete_internal_sec_context(&temp_minor_status, + local_actual_mech, + &union_ctx_id->internal_ctx_id, + NULL); + free(union_ctx_id); + *context_handle = GSS_C_NO_CONTEXT; + } + + free(temp_mech_type->elements); + free(temp_mech_type); + } + + if (actual_mech_type != NULL) { + *actual_mech_type = local_actual_mech; + } + end: if (union_name->mech_name == NULL || union_name->mech_name != internal_name) { Index: src/lib/gssapi/spnego/spnego_mech.c =================================================================== --- src/lib/gssapi/spnego/spnego_mech.c (revision 23482) +++ src/lib/gssapi/spnego/spnego_mech.c (working copy) @@ -967,11 +967,14 @@ * Now, switch the output context to refer to the * negotiated mechanism's context. */ - *context_handle = (gss_ctx_id_t)spnego_ctx->ctx_handle; + *context_handle = (gss_union_ctx_id_t)(spnego_ctx->ctx_handle)->internal_ctx_id; if (actual_mech != NULL) *actual_mech = spnego_ctx->actual_mech; if (ret_flags != NULL) *ret_flags = spnego_ctx->ctx_flags; + free(((gss_union_ctx_id_t)spnego_ctx->ctx_handle)->mech_type->elements); + free(((gss_union_ctx_id_t)spnego_ctx->ctx_handle)->mech_type); + free(spnego_ctx->ctx_handle); release_spnego_ctx(&spnego_ctx); } else if (ret != GSS_S_CONTINUE_NEEDED) { if (spnego_ctx != NULL) { @@ -1686,11 +1689,14 @@ ret = GSS_S_FAILURE; } if (ret == GSS_S_COMPLETE) { - *context_handle = (gss_ctx_id_t)sc->ctx_handle; + *context_handle = (gss_union_ctx_id_t)(sc->ctx_handle)->internal_ctx_id; if (sc->internal_name != GSS_C_NO_NAME && src_name != NULL) { *src_name = sc->internal_name; } + free(((gss_union_ctx_id_t)sc->ctx_handle)->mech_type->elements); + free(((gss_union_ctx_id_t)sc->ctx_handle)->mech_type); + free(sc->ctx_handle); release_spnego_ctx(&sc); } else if (ret != GSS_S_CONTINUE_NEEDED) { if (sc != NULL) {