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