Path: blob/main/crypto/krb5/src/lib/gssapi/mechglue/g_rel_cred.c
39586 views
/* #pragma ident "@(#)g_rel_cred.c 1.14 04/02/23 SMI" */12/*3* Copyright 1996 by Sun Microsystems, Inc.4*5* Permission to use, copy, modify, distribute, and sell this software6* and its documentation for any purpose is hereby granted without fee,7* provided that the above copyright notice appears in all copies and8* that both that copyright notice and this permission notice appear in9* supporting documentation, and that the name of Sun Microsystems not be used10* in advertising or publicity pertaining to distribution of the software11* without specific, written prior permission. Sun Microsystems makes no12* representations about the suitability of this software for any13* purpose. It is provided "as is" without express or implied warranty.14*15* SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,16* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO17* EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR18* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF19* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR20* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR21* PERFORMANCE OF THIS SOFTWARE.22*/2324/* Glue routine for gss_release_cred */2526#include "mglueP.h"27#include <stdio.h>28#ifdef HAVE_STDLIB_H29#include <stdlib.h>30#endif3132OM_uint32 KRB5_CALLCONV33gss_release_cred(OM_uint32 *minor_status, gss_cred_id_t *cred_handle)34{35OM_uint32 status, temp_status;36int j;37gss_union_cred_t union_cred;38gss_mechanism mech;3940if (minor_status == NULL)41return (GSS_S_CALL_INACCESSIBLE_WRITE);4243*minor_status = 0;4445if (cred_handle == NULL)46return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ);4748/*49* Loop through the union_cred struct, selecting the approprate50* underlying mechanism routine and calling it. At the end,51* release all of the storage taken by the union_cred struct.52*/5354union_cred = (gss_union_cred_t) *cred_handle;55if (union_cred == (gss_union_cred_t)GSS_C_NO_CREDENTIAL)56return (GSS_S_COMPLETE);5758if (GSSINT_CHK_LOOP(union_cred))59return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ);60*cred_handle = NULL;6162status = GSS_S_COMPLETE;6364for(j=0; j < union_cred->count; j++) {6566mech = gssint_get_mechanism (&union_cred->mechs_array[j]);6768if (union_cred->mechs_array[j].elements)69free(union_cred->mechs_array[j].elements);70if (mech) {71if (mech->gss_release_cred) {72temp_status = mech->gss_release_cred73(74minor_status,75&union_cred->cred_array[j]);7677if (temp_status != GSS_S_COMPLETE) {78map_error(minor_status, mech);79status = GSS_S_NO_CRED;80}8182} else83status = GSS_S_UNAVAILABLE;84} else85status = GSS_S_DEFECTIVE_CREDENTIAL;86}8788free(union_cred->cred_array);89free(union_cred->mechs_array);90free(union_cred);9192return(status);93}949596