From: Ken Raeburn Date: Fri, 19 Mar 2004 23:25:17 +0000 (+0000) Subject: acquire_cred.c: revert previous change, it breaks the test suite X-Git-Tag: krb5-1.4-beta1~529 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=36d1efe07ead3b1167ca380437783e816549bb7b;p=krb5.git acquire_cred.c: revert previous change, it breaks the test suite git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16192 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index d41060132..838f35265 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -1,8 +1,7 @@ 2004-03-19 Ken Raeburn - * acquire_cred.c (krb5_gss_acquire_cred): Create and destroy a - local krb5 context. - * add_cred.c (krb5_gss_add_cred): Likewise. + * add_cred.c (krb5_gss_add_cred): Create and destroy a local krb5 + context. * compare_name.c (krb5_gss_compare_name): Likewise. * copy_ccache.c (gss_krb5_copy_ccache): Likewise. * disp_name.c (krb5_gss_display_name): Likewise. diff --git a/src/lib/gssapi/krb5/acquire_cred.c b/src/lib/gssapi/krb5/acquire_cred.c index e652c664c..0a0de14b9 100644 --- a/src/lib/gssapi/krb5/acquire_cred.c +++ b/src/lib/gssapi/krb5/acquire_cred.c @@ -331,6 +331,9 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, OM_uint32 ret; krb5_error_code code; + if (GSS_ERROR(kg_get_context(minor_status, &context))) + return(GSS_S_FAILURE); + /* make sure all outputs are valid */ *output_cred_handle = NULL; @@ -399,13 +402,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, /* if requested, acquire credentials for accepting */ /* this will fill in cred->princ if the desired_name is not specified */ - code = krb5_init_context(&context); - if (code) { - xfree(cred); - *minor_status = (OM_uint32) code; - return GSS_S_FAILURE; - } - if ((cred_usage == GSS_C_ACCEPT) || (cred_usage == GSS_C_BOTH)) if ((ret = acquire_accept_cred(context, minor_status, desired_name, @@ -414,7 +410,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, if (cred->princ) krb5_free_principal(context, cred->princ); xfree(cred); - krb5_free_context(context); /* minor_status set by acquire_accept_cred() */ return(ret); } @@ -435,7 +430,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, if (cred->princ) krb5_free_principal(context, cred->princ); xfree(cred); - krb5_free_context(context); /* minor_status set by acquire_init_cred() */ return(ret); } @@ -450,7 +444,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, if (cred->keytab) (void)krb5_kt_close(context, cred->keytab); xfree(cred); - krb5_free_context(context); *minor_status = code; return(GSS_S_FAILURE); } @@ -473,7 +466,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, if (cred->princ) krb5_free_principal(context, cred->princ); xfree(cred); - krb5_free_context(context); *minor_status = code; return(GSS_S_FAILURE); } @@ -502,7 +494,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, if (cred->princ) krb5_free_principal(context, cred->princ); xfree(cred); - krb5_free_context(context); /* *minor_status set above */ return(ret); } @@ -520,7 +511,6 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, if (cred->princ) krb5_free_principal(context, cred->princ); xfree(cred); - krb5_free_context(context); *minor_status = (OM_uint32) G_VALIDATE_FAILED; return(GSS_S_FAILURE); } @@ -532,6 +522,5 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, if (actual_mechs) *actual_mechs = ret_mechs; - krb5_free_context(context); return(GSS_S_COMPLETE); } diff --git a/src/lib/gssapi/krb5/export_name.c b/src/lib/gssapi/krb5/export_name.c index cab284cc3..c949d471e 100644 --- a/src/lib/gssapi/krb5/export_name.c +++ b/src/lib/gssapi/krb5/export_name.c @@ -36,8 +36,11 @@ OM_uint32 krb5_gss_export_name(OM_uint32 *minor_status, size_t length; char *str, *cp; - if (GSS_ERROR(kg_get_context(minor_status, &context))) - return(GSS_S_FAILURE); + code = krb5_init_context(&context); + if (code) { + *minor_status = code; + return GSS_S_FAILURE; + } exported_name->length = 0; exported_name->value = NULL; @@ -45,15 +48,18 @@ OM_uint32 krb5_gss_export_name(OM_uint32 *minor_status, if (! kg_validate_name(input_name)) { if (minor_status) *minor_status = (OM_uint32) G_VALIDATE_FAILED; + krb5_free_context(context); return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME); } if ((code = krb5_unparse_name(context, (krb5_principal) input_name, &str))) { *minor_status = code; + krb5_free_context(context); return(GSS_S_FAILURE); } + krb5_free_context(context); length = strlen(str); exported_name->length = 10 + length + gss_mech_krb5->length; exported_name->value = malloc(exported_name->length); @@ -82,9 +88,3 @@ OM_uint32 krb5_gss_export_name(OM_uint32 *minor_status, return(GSS_S_COMPLETE); } - - - - - - diff --git a/src/lib/gssapi/krb5/gssapiP_krb5.h b/src/lib/gssapi/krb5/gssapiP_krb5.h index d207010c1..9fb41ad2d 100644 --- a/src/lib/gssapi/krb5/gssapiP_krb5.h +++ b/src/lib/gssapi/krb5/gssapiP_krb5.h @@ -296,9 +296,6 @@ krb5_error_code kg_ctx_internalize (krb5_context kcontext, krb5_octet **buffer, size_t *lenremain); -OM_uint32 kg_get_context (OM_uint32 *minor_status, - krb5_context *context); - OM_uint32 kg_sync_ccache_name (OM_uint32 *minor_status); OM_uint32 kg_get_ccache_name (OM_uint32 *minor_status, diff --git a/src/lib/gssapi/krb5/import_name.c b/src/lib/gssapi/krb5/import_name.c index d57144fee..c9f95857d 100644 --- a/src/lib/gssapi/krb5/import_name.c +++ b/src/lib/gssapi/krb5/import_name.c @@ -60,8 +60,11 @@ krb5_gss_import_name(minor_status, input_name_buffer, struct passwd *pw; #endif - if (GSS_ERROR(kg_get_context(minor_status, &context))) - return(GSS_S_FAILURE); + code = krb5_init_context(&context); + if (code) { + *minor_status = code; + return GSS_S_FAILURE; + } /* set up default returns */ @@ -78,6 +81,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, if ((tmp = (char *) xmalloc(input_name_buffer->length + 1)) == NULL) { *minor_status = ENOMEM; + krb5_free_context(context); return(GSS_S_FAILURE); } @@ -100,6 +104,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, if (input_name_buffer->length != sizeof(krb5_principal)) { *minor_status = (OM_uint32) G_WRONG_SIZE; + krb5_free_context(context); return(GSS_S_BAD_NAME); } @@ -107,6 +112,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, if ((code = krb5_copy_principal(context, input, &princ))) { *minor_status = code; + krb5_free_context(context); return(GSS_S_FAILURE); } } else { @@ -115,6 +121,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, if ((tmp = (char *) xmalloc(input_name_buffer->length + 1)) == NULL) { *minor_status = ENOMEM; + krb5_free_context(context); return(GSS_S_FAILURE); } tmp2 = 0; @@ -165,6 +172,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, if (tmp2 == NULL) { xfree(tmp); *minor_status = ENOMEM; + krb5_free_context(context); return GSS_S_FAILURE; } strncpy(tmp2, cp, length); @@ -172,6 +180,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, stringrep = tmp2; } else { + krb5_free_context(context); return(GSS_S_BAD_NAMETYPE); } @@ -184,6 +193,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, xfree(tmp); if (tmp2) xfree(tmp2); + krb5_free_context(context); return(GSS_S_BAD_NAME); } @@ -197,6 +207,7 @@ krb5_gss_import_name(minor_status, input_name_buffer, if (code) { *minor_status = (OM_uint32) code; + krb5_free_context(context); return(GSS_S_BAD_NAME); } @@ -204,10 +215,13 @@ krb5_gss_import_name(minor_status, input_name_buffer, if (! kg_save_name((gss_name_t) princ)) { krb5_free_principal(context, princ); + krb5_free_context(context); *minor_status = (OM_uint32) G_VALIDATE_FAILED; return(GSS_S_FAILURE); } + krb5_free_context(context); + /* return it */ *output_name = (gss_name_t) princ;