xref: /illumos-gate/usr/src/cmd/gss/gssd/gssd_release_name_and_type.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 (c) 1995,1997, by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  *  glue routine for gssd_release_name_and_type -- this is a hack,
31  *  it is only used by the client-side rpc library.  Perhaps it should
32  *  be in there?  Perhaps this should be a part of the release_name
33  *  function?  Or perhaps it should always allocate it?  I don't know
34  *  the right answer.
35  */
36 
37 #include <sys/types.h>
38 #include <stdlib.h>
39 #include <mechglueP.h>
40 
41 /*ARGSUSED*/
42 OM_uint32
43 gssd_release_name_and_type(minor_status, input_name)
44 	OM_uint32 *		minor_status;
45 	gss_name_t *		input_name;
46 
47 {
48 
49 	gss_union_name_t	union_name;
50 
51 	if (input_name == NULL)
52 		return (GSS_S_COMPLETE);
53 
54 	/*
55 	 * free up the space for the external_name and also the name
56 	 * type data. Then free the union_name descriptor.
57 	 */
58 
59 	union_name = (gss_union_name_t) *input_name;
60 	*input_name = NULL;
61 
62 	if (union_name == NULL)
63 		return (GSS_S_COMPLETE);
64 
65 	FREE(union_name->external_name->value,
66 	    union_name->external_name->length);
67 	FREE(union_name->external_name, sizeof (gss_buffer_desc));
68 	FREE(union_name->name_type->elements, union_name->name_type->length);
69 	FREE(union_name->name_type, sizeof (gss_OID_desc));
70 	FREE(union_name, sizeof (gss_union_name_desc));
71 
72 	return (GSS_S_COMPLETE);
73 }
74 
75 OM_uint32
76 gss_release_oid_set_and_oids(minor_status, set)
77 	OM_uint32 *		minor_status;
78 	gss_OID_set *		set;
79 {
80 	int i;
81 
82 	if (minor_status)
83 		*minor_status = 0;
84 
85 	if (set == NULL)
86 		return (GSS_S_COMPLETE);
87 
88 	if (*set == GSS_C_NULL_OID_SET)
89 		return (GSS_S_COMPLETE);
90 
91 	for (i = 0; i < (*set)->count; i++)
92 		FREE((*set)->elements[i].elements, (*set)->elements[i].length);
93 
94 	FREE((*set)->elements, (*set)->count * sizeof (gss_OID_desc));
95 	FREE(*set, sizeof (gss_OID_set_desc));
96 
97 	*set = GSS_C_NULL_OID_SET;
98 
99 	return (GSS_S_COMPLETE);
100 }
101