6198 Let's EOL cachefs
[illumos-gate.git] / usr / src / lib / libgss / g_rel_cred.c
blob9a5d79ac8964ea335ff2f4674f76bfe21e8269a8
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
26 * glue routine for gss_release_cred
29 #include <mechglueP.h>
30 #include "gssapiP_generic.h"
31 #include <stdio.h>
32 #ifdef HAVE_STDLIB_H
33 #include <stdlib.h>
34 #endif
36 OM_uint32
37 gss_release_cred(minor_status,
38 cred_handle)
40 OM_uint32 *minor_status;
41 gss_cred_id_t *cred_handle;
44 OM_uint32 status, temp_status;
45 int j;
46 gss_union_cred_t union_cred;
47 gss_mechanism mech;
49 if (minor_status == NULL)
50 return (GSS_S_CALL_INACCESSIBLE_WRITE);
52 *minor_status = 0;
54 if (cred_handle == NULL)
55 return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ);
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.
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);
67 if (GSSINT_CHK_LOOP(union_cred))
68 return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ);
70 *cred_handle = NULL;
72 status = GSS_S_COMPLETE;
74 for (j = 0; j < union_cred->count; j++) {
76 mech = __gss_get_mechanism(&union_cred->mechs_array[j]);
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]);
86 if (temp_status != GSS_S_COMPLETE) {
87 map_error(minor_status, mech);
88 status = GSS_S_NO_CRED;
90 } else
91 status = GSS_S_UNAVAILABLE;
92 } else
93 status = GSS_S_DEFECTIVE_CREDENTIAL;
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);
101 return (status);