remove pyzfs
[unleashed.git] / usr / src / lib / libgss / g_inquire_names.c
blob8f8a658341d244773aa616879964a63df2829339
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
26 * glue routine for gss_inquire_context
29 #include <mechglueP.h>
30 #include "gssapiP_generic.h"
32 #define MAX_MECH_OID_PAIRS 32
34 /* Last argument new for V2 */
35 OM_uint32
36 gss_inquire_names_for_mech(minor_status, mechanism, name_types)
38 OM_uint32 * minor_status;
39 const gss_OID mechanism;
40 gss_OID_set * name_types;
43 OM_uint32 status;
44 gss_mechanism mech;
46 /* Initialize outputs. */
48 if (minor_status != NULL)
49 *minor_status = 0;
51 if (name_types != NULL)
52 *name_types = GSS_C_NO_OID_SET;
54 /* Validate arguments. */
56 if (minor_status == NULL)
57 return (GSS_S_CALL_INACCESSIBLE_WRITE);
59 if (name_types == NULL)
60 return (GSS_S_CALL_INACCESSIBLE_WRITE);
63 * select the approprate underlying mechanism routine and
64 * call it.
67 mech = __gss_get_mechanism(mechanism);
69 if (mech) {
71 if (mech->gss_inquire_names_for_mech) {
72 status = mech->gss_inquire_names_for_mech(
73 mech->context,
74 minor_status,
75 mechanism,
76 name_types);
77 if (status != GSS_S_COMPLETE)
78 map_error(minor_status, mech);
79 } else
80 status = GSS_S_UNAVAILABLE;
82 return (status);
85 return (GSS_S_BAD_MECH);
88 static OM_uint32 val_inq_mechs4name_args(
89 OM_uint32 *minor_status,
90 const gss_name_t input_name,
91 gss_OID_set *mech_set)
94 /* Initialize outputs. */
95 if (minor_status != NULL)
96 *minor_status = 0;
98 if (mech_set != NULL)
99 *mech_set = GSS_C_NO_OID_SET;
101 /* Validate arguments. */
103 if (minor_status == NULL)
104 return (GSS_S_CALL_INACCESSIBLE_WRITE);
106 if (input_name == GSS_C_NO_NAME)
107 return (GSS_S_BAD_NAME);
109 return (GSS_S_COMPLETE);
112 OM_uint32
113 gss_inquire_mechs_for_name(minor_status, input_name, mech_set)
115 OM_uint32 * minor_status;
116 const gss_name_t input_name;
117 gss_OID_set * mech_set;
120 OM_uint32 status;
121 static char *mech_list[MAX_MECH_OID_PAIRS+1];
122 gss_OID_set mech_name_types;
123 int present;
124 char *mechanism;
125 gss_OID mechOid;
126 gss_OID name_type;
127 gss_buffer_desc name_buffer;
128 int i;
130 status = val_inq_mechs4name_args(minor_status, input_name, mech_set);
131 if (status != GSS_S_COMPLETE)
132 return (status);
134 status = gss_create_empty_oid_set(minor_status, mech_set);
135 if (status != GSS_S_COMPLETE)
136 return (status);
137 *mech_list = NULL;
138 status = __gss_get_mechanisms(mech_list, MAX_MECH_OID_PAIRS+1);
139 if (status != GSS_S_COMPLETE)
140 return (status);
141 for (i = 0; i < MAX_MECH_OID_PAIRS && mech_list[i] != NULL; i++) {
142 mechanism = mech_list[i];
143 if (__gss_mech_to_oid(mechanism, &mechOid) == GSS_S_COMPLETE) {
144 status = gss_inquire_names_for_mech(
145 minor_status,
146 mechOid,
147 &mech_name_types);
148 if (status == GSS_S_COMPLETE) {
149 status = gss_display_name(minor_status,
150 input_name,
151 &name_buffer,
152 &name_type);
154 (void) gss_release_buffer(NULL, &name_buffer);
156 if (status == GSS_S_COMPLETE && name_type) {
157 status = gss_test_oid_set_member(
158 minor_status,
159 name_type,
160 mech_name_types,
161 &present);
162 if (status == GSS_S_COMPLETE &&
163 present) {
164 status = gss_add_oid_set_member(
165 minor_status,
166 mechOid,
167 mech_set);
168 if (status != GSS_S_COMPLETE) {
169 (void) gss_release_oid_set(
170 minor_status,
171 &mech_name_types);
172 (void) gss_release_oid_set(
173 minor_status,
174 mech_set);
175 return (status);
179 (void) gss_release_oid_set(
180 minor_status,
181 &mech_name_types);
183 } else {
184 (void) gss_release_oid_set(
185 minor_status,
186 mech_set);
187 return (GSS_S_FAILURE);
190 return (GSS_S_COMPLETE);