2 * Copyright 1996 by Sun Microsystems, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without fee,
6 * provided that the above copyright notice appears in all copies and
7 * that both that copyright notice and this permission notice appear in
8 * supporting documentation, and that the name of Sun Microsystems not be used
9 * in advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. Sun Microsystems makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
22 * created andros 2.24.01 from g_compare_name.c
26 * glue routine for gss_duplicate_name
38 OM_uint32 KRB5_CALLCONV
39 gss_duplicate_name (minor_status,
42 OM_uint32 * minor_status;
43 const gss_name_t in_name;
46 OM_uint32 tmp,major_status = GSS_S_COMPLETE;
47 gss_union_name_t union_in_name, union_exp_name;
52 /* if exp_name is NULL, simply return */
54 return (GSS_S_COMPLETE);
59 return (GSS_S_BAD_NAME);
61 union_in_name = (gss_union_name_t) in_name;
64 * Create the union name struct that will hold the exported
65 * name and the name type.
68 union_exp_name = (gss_union_name_t) malloc (sizeof(gss_union_name_desc));
69 if (!union_exp_name) {
70 *minor_status = ENOMEM;
71 goto allocation_failure;
74 fprintf(stderr, "gss_duplicate_name: copying *oid %p\n",
75 union_in_name->mech_type);
77 union_exp_name->gss_mech = union_in_name->gss_mech;
78 union_exp_name->mech_type = GSS_C_NO_OID;
79 if (union_in_name->mech_type != GSS_C_NO_OID &&
80 (generic_gss_copy_oid(&tmp, union_in_name->mech_type,
81 &union_exp_name->mech_type) != GSS_S_COMPLETE)) {
82 *minor_status = ENOMEM;
83 goto allocation_failure;
85 union_exp_name->mech_name = NULL;
86 union_exp_name->name_type = GSS_C_NO_OID;
87 if (union_in_name->name_type != GSS_C_NO_OID &&
88 (generic_gss_copy_oid(&tmp, union_in_name->name_type,
89 &union_exp_name->name_type) != GSS_S_COMPLETE)) {
90 *minor_status = ENOMEM;
91 goto allocation_failure;
93 union_exp_name->external_name = NULL;
94 union_exp_name->external_name =
95 (gss_buffer_t) malloc(sizeof(gss_buffer_desc));
96 if (!union_exp_name->external_name) {
97 *minor_status = ENOMEM;
98 goto allocation_failure;
100 union_exp_name->external_name->length = union_in_name->external_name->length;
102 * we malloc length+1 to stick a NULL on the end, just in case
103 * Note that this NULL is not included in ->length for a reason!
106 union_exp_name->external_name->value =
107 (void *) malloc(union_in_name->external_name->length);
108 if (!union_exp_name->external_name->value) {
109 *minor_status = ENOMEM;
110 goto allocation_failure;
112 memcpy(union_exp_name->external_name->value,
113 union_in_name->external_name->value,
114 union_exp_name->external_name->length);
117 * Mechanism specific name
120 if (union_in_name->mech_type != GSS_C_NO_OID) {
121 mech = __gss_get_mechanism (union_in_name->mech_type);
123 return (GSS_S_BAD_MECH);
124 if (!mech->gss_duplicate_name)
125 return (GSS_S_BAD_BINDINGS);
127 #ifdef USE_MECH_CONTEXT
128 major_status = mech->gss_duplicate_name(mech->context, minor_status,
130 major_status = mech->gss_duplicate_name(minor_status,
132 union_in_name->mech_name, &union_exp_name->mech_name);
133 if (major_status != GSS_S_COMPLETE)
134 return (major_status);
137 fprintf(stderr, "gss_duplicate_name: returning union_exp_name %p\n",
140 *exp_name = union_exp_name;
141 return (major_status);
144 if (union_exp_name) {
145 if (union_exp_name->external_name) {
146 if (union_exp_name->external_name->value)
147 free(union_exp_name->external_name->value);
148 free(union_exp_name->external_name);
150 if (union_exp_name->name_type)
151 generic_gss_release_oid(&tmp, &union_exp_name->name_type);
152 if (union_exp_name->mech_name)
153 __gss_release_internal_name(minor_status, union_exp_name->mech_type,
154 &union_exp_name->mech_name);
155 if (union_exp_name->mech_type)
156 generic_gss_release_oid(&tmp, &union_exp_name->mech_type);
157 free(union_exp_name);
159 return (major_status);