xref: /titanic_50/usr/src/lib/libgss/g_rel_name.c (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  *  glue routine for gss_release_name
31  */
32 
33 #include <mechglueP.h>
34 #include <stdio.h>
35 #ifdef HAVE_STDLIB_H
36 #include <stdlib.h>
37 #endif
38 #include <string.h>
39 
40 OM_uint32
41 gss_release_name(minor_status,
42 			input_name)
43 
44 OM_uint32 *minor_status;
45 gss_name_t *input_name;
46 
47 {
48 	gss_union_name_t	union_name;
49 
50 	if (minor_status == NULL)
51 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
52 	*minor_status = 0;
53 
54 	/* if input_name is NULL, return error */
55 	if (input_name == 0)
56 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
57 
58 	/*
59 	 * free up the space for the external_name and then
60 	 * free the union_name descriptor
61 	 */
62 
63 	union_name = (gss_union_name_t)*input_name;
64 	*input_name = 0;
65 	*minor_status = 0;
66 
67 	if (union_name->name_type)
68 		(void) gss_release_oid(minor_status, &union_name->name_type);
69 
70 	free(union_name->external_name->value);
71 	free(union_name->external_name);
72 
73 	if (union_name->mech_type) {
74 		(void) __gss_release_internal_name(minor_status,
75 					union_name->mech_type,
76 					&union_name->mech_name);
77 		(void) gss_release_oid(minor_status, &union_name->mech_type);
78 	}
79 
80 	free(union_name);
81 
82 	return (GSS_S_COMPLETE);
83 }
84