xref: /illumos-gate/usr/src/lib/libgss/g_rel_name.c (revision 1da57d55)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  *  glue routine for gss_release_name
29  */
30 
31 #include <mechglueP.h>
32 #include <stdio.h>
33 #ifdef HAVE_STDLIB_H
34 #include <stdlib.h>
35 #endif
36 #include <string.h>
37 
38 OM_uint32
gss_release_name(minor_status,input_name)39 gss_release_name(minor_status,
40 			input_name)
41 
42 OM_uint32 *minor_status;
43 gss_name_t *input_name;
44 
45 {
46 	gss_union_name_t	union_name;
47 
48 	if (minor_status == NULL)
49 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
50 	*minor_status = 0;
51 
52 	/* if input_name is NULL, return error */
53 	if (input_name == 0)
54 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
55 
56 	/*
57 	 * free up the space for the external_name and then
58 	 * free the union_name descriptor
59 	 */
60 
61 	union_name = (gss_union_name_t)*input_name;
62 	*input_name = 0;
63 	*minor_status = 0;
64 
65 	if (union_name->name_type)
66 		(void) gss_release_oid(minor_status, &union_name->name_type);
67 
68 	free(union_name->external_name->value);
69 	free(union_name->external_name);
70 
71 	if (union_name->mech_type) {
72 		(void) __gss_release_internal_name(minor_status,
73 					union_name->mech_type,
74 					&union_name->mech_name);
75 		(void) gss_release_oid(minor_status, &union_name->mech_type);
76 	}
77 
78 	free(union_name);
79 
80 	return (GSS_S_COMPLETE);
81 }
82