]> git.decadent.org.uk Git - nfs-utils.git/blob - support/gssapi/g_rel_cred.c
release 1.0.7-pre2
[nfs-utils.git] / support / gssapi / g_rel_cred.c
1 /* #ident  "@(#)gss_release_cred.c 1.15     95/08/07 SMI" */
2
3 /*
4  * Copyright 1996 by Sun Microsystems, Inc.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software
7  * and its documentation for any purpose is hereby granted without fee,
8  * provided that the above copyright notice appears in all copies and
9  * that both that copyright notice and this permission notice appear in
10  * supporting documentation, and that the name of Sun Microsystems not be used
11  * in advertising or publicity pertaining to distribution of the software
12  * without specific, written prior permission. Sun Microsystems makes no
13  * representations about the suitability of this software for any
14  * purpose.  It is provided "as is" without express or implied warranty.
15  *
16  * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18  * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
20  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22  * PERFORMANCE OF THIS SOFTWARE.
23  */
24
25 /*
26  *  glue routine for gss_release_cred
27  */
28
29 #include "mglueP.h"
30 #include <stdio.h>
31 #ifdef HAVE_STDLIB_H
32 #include <stdlib.h>
33 #endif
34
35 OM_uint32 KRB5_CALLCONV
36 gss_release_cred(minor_status,
37                  cred_handle)
38
39 OM_uint32 *             minor_status;
40 gss_cred_id_t *         cred_handle;
41
42 {
43     OM_uint32           status, temp_status;
44     int                 j;
45     gss_union_cred_t    union_cred;
46     gss_mechanism       mech;
47
48     gss_initialize();
49
50     if (minor_status)
51         *minor_status = 0;
52
53     /* if the cred_handle is null, return a NO_CRED error */
54
55     if (cred_handle == GSS_C_NO_CREDENTIAL)
56         return(GSS_S_NO_CRED);
57
58     /*
59      * Loop through the union_cred struct, selecting the approprate
60      * underlying mechanism routine and calling it. At the end,
61      * release all of the storage taken by the union_cred struct.
62      */
63
64     union_cred = (gss_union_cred_t) *cred_handle;
65     *cred_handle = NULL;
66
67     if (union_cred == NULL)
68         return GSS_S_NO_CRED;
69
70     status = GSS_S_COMPLETE;
71
72     for(j=0; j < union_cred->count; j++) {
73
74         mech = __gss_get_mechanism (&union_cred->mechs_array[j]);
75
76         if (union_cred->mechs_array[j].elements)
77                 free(union_cred->mechs_array[j].elements);
78         if (mech) {
79             if (mech->gss_release_cred) {
80                 temp_status = mech->gss_release_cred
81 #ifdef USE_MECH_CONTEXT
82                     (mech->context,
83 #else
84                     (
85 #endif
86                      minor_status,
87                      &union_cred->cred_array[j]);
88
89             if (temp_status != GSS_S_COMPLETE)
90                 status = GSS_S_NO_CRED;
91
92             } else
93                 status = GSS_S_NO_CRED;
94         } else
95             status = GSS_S_NO_CRED;
96     }
97
98     gss_release_buffer(minor_status, &union_cred->auxinfo.name);
99     free(union_cred->cred_array);
100     free(union_cred->mechs_array);
101     free(union_cred);
102
103     return(status);
104 }