1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 23 */ 24 25 /* 26 * glue routine for gss_release_cred 27 */ 28 29 #include <mechglueP.h> 30 #include "gssapiP_generic.h" 31 #include <stdio.h> 32 #ifdef HAVE_STDLIB_H 33 #include <stdlib.h> 34 #endif 35 36 OM_uint32 37 gss_release_cred(minor_status, 38 cred_handle) 39 40 OM_uint32 *minor_status; 41 gss_cred_id_t *cred_handle; 42 43 { 44 OM_uint32 status, temp_status; 45 int j; 46 gss_union_cred_t union_cred; 47 gss_mechanism mech; 48 49 if (minor_status == NULL) 50 return (GSS_S_CALL_INACCESSIBLE_WRITE); 51 52 *minor_status = 0; 53 54 if (cred_handle == NULL) 55 return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ); 56 57 /* 58 * Loop through the union_cred struct, selecting the approprate 59 * underlying mechanism routine and calling it. At the end, 60 * release all of the storage taken by the union_cred struct. 61 */ 62 63 union_cred = (gss_union_cred_t)*cred_handle; 64 if (union_cred == (gss_union_cred_t)GSS_C_NO_CREDENTIAL) 65 return (GSS_S_COMPLETE); 66 67 if (GSSINT_CHK_LOOP(union_cred)) 68 return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ); 69 70 *cred_handle = NULL; 71 72 status = GSS_S_COMPLETE; 73 74 for (j = 0; j < union_cred->count; j++) { 75 76 mech = __gss_get_mechanism(&union_cred->mechs_array[j]); 77 78 if (union_cred->mechs_array[j].elements) 79 free(union_cred->mechs_array[j].elements); 80 if (mech) { 81 if (mech->gss_release_cred) { 82 temp_status = mech->gss_release_cred 83 (mech->context, minor_status, 84 &union_cred->cred_array[j]); 85 86 if (temp_status != GSS_S_COMPLETE) { 87 map_error(minor_status, mech); 88 status = GSS_S_NO_CRED; 89 } 90 } else 91 status = GSS_S_UNAVAILABLE; 92 } else 93 status = GSS_S_DEFECTIVE_CREDENTIAL; 94 } 95 96 (void) gss_release_buffer(minor_status, &union_cred->auxinfo.name); 97 free(union_cred->cred_array); 98 free(union_cred->mechs_array); 99 free(union_cred); 100 101 return (status); 102 } 103