xref: /titanic_41/usr/src/uts/common/gssapi/gss_display_name.c (revision c138f478d2bc94e73ab8f6a084e323bec25e62f5)
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_display_name()
31  */
32 
33 #include <mechglueP.h>
34 #include <gssapi/kgssapi_defs.h>
35 
36 OM_uint32
37 gss_display_name(OM_uint32 *minor_status,
38 	const gss_name_t input_name,
39 	gss_buffer_t output_name_buffer,
40 	gss_OID *output_name_type)
41 {
42 	gss_union_name_t	union_name;
43 
44 	if (input_name == 0)
45 		return (GSS_S_BAD_NAME);
46 
47 	union_name = (gss_union_name_t) input_name;
48 
49 	GSSLOG(8, "union_name value %s\n",
50 		(char *)union_name->external_name->value);
51 
52 	/*
53 	 * copy the value of the external_name component of the union
54 	 * name into the output_name_buffer and point the output_name_type
55 	 * to the name_type component of union_name
56 	 */
57 	if (output_name_type != NULL)
58 		*output_name_type = union_name->name_type;
59 
60 	if (output_name_buffer != NULL) {
61 		output_name_buffer->length = union_name->external_name->length;
62 
63 		output_name_buffer->value =
64 			(void *) MALLOC(output_name_buffer->length);
65 
66 		(void) memcpy(output_name_buffer->value,
67 			union_name->external_name->value,
68 			output_name_buffer->length);
69 	}
70 
71 	if (minor_status)
72 		*minor_status = 0;
73 
74 	return (GSS_S_COMPLETE);
75 }
76