Blame src/lib/gssapi/mechglue/g_rel_cred.c

Packit fd8b60
/* #pragma ident	"@(#)g_rel_cred.c	1.14	04/02/23 SMI" */
Packit fd8b60
Packit fd8b60
/*
Packit fd8b60
 * Copyright 1996 by Sun Microsystems, Inc.
Packit fd8b60
 *
Packit fd8b60
 * Permission to use, copy, modify, distribute, and sell this software
Packit fd8b60
 * and its documentation for any purpose is hereby granted without fee,
Packit fd8b60
 * provided that the above copyright notice appears in all copies and
Packit fd8b60
 * that both that copyright notice and this permission notice appear in
Packit fd8b60
 * supporting documentation, and that the name of Sun Microsystems not be used
Packit fd8b60
 * in advertising or publicity pertaining to distribution of the software
Packit fd8b60
 * without specific, written prior permission. Sun Microsystems makes no
Packit fd8b60
 * representations about the suitability of this software for any
Packit fd8b60
 * purpose.  It is provided "as is" without express or implied warranty.
Packit fd8b60
 *
Packit fd8b60
 * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
Packit fd8b60
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
Packit fd8b60
 * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
Packit fd8b60
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
Packit fd8b60
 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
Packit fd8b60
 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
Packit fd8b60
 * PERFORMANCE OF THIS SOFTWARE.
Packit fd8b60
 */
Packit fd8b60
Packit fd8b60
/* Glue routine for gss_release_cred */
Packit fd8b60
Packit fd8b60
#include "mglueP.h"
Packit fd8b60
#include <stdio.h>
Packit fd8b60
#ifdef HAVE_STDLIB_H
Packit fd8b60
#include <stdlib.h>
Packit fd8b60
#endif
Packit fd8b60
Packit fd8b60
OM_uint32 KRB5_CALLCONV
Packit fd8b60
gss_release_cred(minor_status,
Packit fd8b60
                 cred_handle)
Packit fd8b60
Packit fd8b60
OM_uint32 *		minor_status;
Packit fd8b60
gss_cred_id_t *		cred_handle;
Packit fd8b60
Packit fd8b60
{
Packit fd8b60
    OM_uint32		status, temp_status;
Packit fd8b60
    int			j;
Packit fd8b60
    gss_union_cred_t	union_cred;
Packit fd8b60
    gss_mechanism	mech;
Packit fd8b60
Packit fd8b60
    if (minor_status == NULL)
Packit fd8b60
	return (GSS_S_CALL_INACCESSIBLE_WRITE);
Packit fd8b60
Packit fd8b60
    *minor_status = 0;
Packit fd8b60
Packit fd8b60
    if (cred_handle == NULL)
Packit fd8b60
	return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ);
Packit fd8b60
Packit fd8b60
    /*
Packit fd8b60
     * Loop through the union_cred struct, selecting the approprate
Packit fd8b60
     * underlying mechanism routine and calling it. At the end,
Packit fd8b60
     * release all of the storage taken by the union_cred struct.
Packit fd8b60
     */
Packit fd8b60
Packit fd8b60
    union_cred = (gss_union_cred_t) *cred_handle;
Packit fd8b60
    if (union_cred == (gss_union_cred_t)GSS_C_NO_CREDENTIAL)
Packit fd8b60
	return (GSS_S_COMPLETE);
Packit fd8b60
Packit fd8b60
    if (GSSINT_CHK_LOOP(union_cred))
Packit fd8b60
	return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ);
Packit fd8b60
    *cred_handle = NULL;
Packit fd8b60
Packit fd8b60
    status = GSS_S_COMPLETE;
Packit fd8b60
Packit fd8b60
    for(j=0; j < union_cred->count; j++) {
Packit fd8b60
Packit fd8b60
	mech = gssint_get_mechanism (&union_cred->mechs_array[j]);
Packit fd8b60
Packit fd8b60
	if (union_cred->mechs_array[j].elements)
Packit fd8b60
		free(union_cred->mechs_array[j].elements);
Packit fd8b60
	if (mech) {
Packit fd8b60
	    if (mech->gss_release_cred) {
Packit fd8b60
		temp_status = mech->gss_release_cred
Packit fd8b60
		    (
Packit fd8b60
		     minor_status,
Packit fd8b60
		     &union_cred->cred_array[j]);
Packit fd8b60
Packit fd8b60
		if (temp_status != GSS_S_COMPLETE) {
Packit fd8b60
		    map_error(minor_status, mech);
Packit fd8b60
		    status = GSS_S_NO_CRED;
Packit fd8b60
		}
Packit fd8b60
Packit fd8b60
	    } else
Packit fd8b60
		status = GSS_S_UNAVAILABLE;
Packit fd8b60
	} else
Packit fd8b60
	    status = GSS_S_DEFECTIVE_CREDENTIAL;
Packit fd8b60
    }
Packit fd8b60
Packit fd8b60
    free(union_cred->cred_array);
Packit fd8b60
    free(union_cred->mechs_array);
Packit fd8b60
    free(union_cred);
Packit fd8b60
Packit fd8b60
    return(status);
Packit fd8b60
}