xref: /titanic_41/usr/src/lib/libgss/g_export_name.c (revision 8e50dcc9f00b393d43e6aa42b820bcbf1d3e1ce4)
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) 1996,1997, by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * glue routine gss_export_name
31  *
32  * Will either call the mechanism defined gss_export_name, or if one is
33  * not defined will call a generic_gss_export_name routine.
34  */
35 
36 #include <mechglueP.h>
37 #ifdef HAVE_STDLIB_H
38 #include <stdlib.h>
39 #endif
40 #include <string.h>
41 #include <errno.h>
42 
43 OM_uint32
44 gss_export_name(minor_status,
45 			input_name,
46 			exported_name)
47 OM_uint32 *		minor_status;
48 const gss_name_t	input_name;
49 gss_buffer_t		exported_name;
50 {
51 	gss_union_name_t		union_name;
52 
53 
54 	if (minor_status)
55 		*minor_status = 0;
56 
57 	/* check out parameter */
58 	if (!exported_name)
59 		return (GSS_S_CALL_INACCESSIBLE_WRITE);
60 
61 	exported_name->value = NULL;
62 	exported_name->length = 0;
63 
64 	/* check input parameter */
65 	if (!input_name)
66 		return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
67 
68 	union_name = (gss_union_name_t)input_name;
69 
70 	/* the name must be in mechanism specific format */
71 	if (!union_name->mech_type)
72 		return (GSS_S_NAME_NOT_MN);
73 
74 	return __gss_export_internal_name(minor_status, union_name->mech_type,
75 					union_name->mech_name, exported_name);
76 }
77