1ae771770SStanislav Sedov /*-
2ae771770SStanislav Sedov * Copyright (c) 2005 Doug Rabson
3ae771770SStanislav Sedov * All rights reserved.
4ae771770SStanislav Sedov *
5ae771770SStanislav Sedov * Redistribution and use in source and binary forms, with or without
6ae771770SStanislav Sedov * modification, are permitted provided that the following conditions
7ae771770SStanislav Sedov * are met:
8ae771770SStanislav Sedov * 1. Redistributions of source code must retain the above copyright
9ae771770SStanislav Sedov * notice, this list of conditions and the following disclaimer.
10ae771770SStanislav Sedov * 2. Redistributions in binary form must reproduce the above copyright
11ae771770SStanislav Sedov * notice, this list of conditions and the following disclaimer in the
12ae771770SStanislav Sedov * documentation and/or other materials provided with the distribution.
13ae771770SStanislav Sedov *
14ae771770SStanislav Sedov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15ae771770SStanislav Sedov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16ae771770SStanislav Sedov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17ae771770SStanislav Sedov * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18ae771770SStanislav Sedov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19ae771770SStanislav Sedov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20ae771770SStanislav Sedov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21ae771770SStanislav Sedov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22ae771770SStanislav Sedov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23ae771770SStanislav Sedov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24ae771770SStanislav Sedov * SUCH DAMAGE.
25ae771770SStanislav Sedov *
26ae771770SStanislav Sedov * $FreeBSD: src/lib/libgssapi/gss_mech_switch.c,v 1.2 2006/02/04 09:40:21 dfr Exp $
27ae771770SStanislav Sedov */
28ae771770SStanislav Sedov
29ae771770SStanislav Sedov #include "mech_locl.h"
30ae771770SStanislav Sedov #include <heim_threads.h>
31ae771770SStanislav Sedov
32ae771770SStanislav Sedov #ifndef _PATH_GSS_MECH
33ae771770SStanislav Sedov #define _PATH_GSS_MECH "/etc/gss/mech"
34ae771770SStanislav Sedov #endif
35ae771770SStanislav Sedov
36ae771770SStanislav Sedov struct _gss_mech_switch_list _gss_mechs = { NULL } ;
37ae771770SStanislav Sedov gss_OID_set _gss_mech_oids;
38ae771770SStanislav Sedov static HEIMDAL_MUTEX _gss_mech_mutex = HEIMDAL_MUTEX_INITIALIZER;
39ae771770SStanislav Sedov
40ae771770SStanislav Sedov /*
41ae771770SStanislav Sedov * Convert a string containing an OID in 'dot' form
42ae771770SStanislav Sedov * (e.g. 1.2.840.113554.1.2.2) to a gss_OID.
43ae771770SStanislav Sedov */
44ae771770SStanislav Sedov static int
_gss_string_to_oid(const char * s,gss_OID oid)45ae771770SStanislav Sedov _gss_string_to_oid(const char* s, gss_OID oid)
46ae771770SStanislav Sedov {
47ae771770SStanislav Sedov int number_count, i, j;
48ae771770SStanislav Sedov size_t byte_count;
49ae771770SStanislav Sedov const char *p, *q;
50ae771770SStanislav Sedov char *res;
51ae771770SStanislav Sedov
52ae771770SStanislav Sedov oid->length = 0;
53ae771770SStanislav Sedov oid->elements = NULL;
54ae771770SStanislav Sedov
55ae771770SStanislav Sedov /*
56ae771770SStanislav Sedov * First figure out how many numbers in the oid, then
57ae771770SStanislav Sedov * calculate the compiled oid size.
58ae771770SStanislav Sedov */
59ae771770SStanislav Sedov number_count = 0;
60ae771770SStanislav Sedov for (p = s; p; p = q) {
61ae771770SStanislav Sedov q = strchr(p, '.');
62ae771770SStanislav Sedov if (q) q = q + 1;
63ae771770SStanislav Sedov number_count++;
64ae771770SStanislav Sedov }
65ae771770SStanislav Sedov
66ae771770SStanislav Sedov /*
67ae771770SStanislav Sedov * The first two numbers are in the first byte and each
68ae771770SStanislav Sedov * subsequent number is encoded in a variable byte sequence.
69ae771770SStanislav Sedov */
70ae771770SStanislav Sedov if (number_count < 2)
71ae771770SStanislav Sedov return (EINVAL);
72ae771770SStanislav Sedov
73ae771770SStanislav Sedov /*
74ae771770SStanislav Sedov * We do this in two passes. The first pass, we just figure
75ae771770SStanislav Sedov * out the size. Second time around, we actually encode the
76ae771770SStanislav Sedov * number.
77ae771770SStanislav Sedov */
78ae771770SStanislav Sedov res = 0;
79ae771770SStanislav Sedov for (i = 0; i < 2; i++) {
80ae771770SStanislav Sedov byte_count = 0;
81ae771770SStanislav Sedov for (p = s, j = 0; p; p = q, j++) {
82ae771770SStanislav Sedov unsigned int number = 0;
83ae771770SStanislav Sedov
84ae771770SStanislav Sedov /*
85ae771770SStanislav Sedov * Find the end of this number.
86ae771770SStanislav Sedov */
87ae771770SStanislav Sedov q = strchr(p, '.');
88ae771770SStanislav Sedov if (q) q = q + 1;
89ae771770SStanislav Sedov
90ae771770SStanislav Sedov /*
91ae771770SStanislav Sedov * Read the number of of the string. Don't
92ae771770SStanislav Sedov * bother with anything except base ten.
93ae771770SStanislav Sedov */
94ae771770SStanislav Sedov while (*p && *p != '.') {
95ae771770SStanislav Sedov number = 10 * number + (*p - '0');
96ae771770SStanislav Sedov p++;
97ae771770SStanislav Sedov }
98ae771770SStanislav Sedov
99ae771770SStanislav Sedov /*
100ae771770SStanislav Sedov * Encode the number. The first two numbers
101ae771770SStanislav Sedov * are packed into the first byte. Subsequent
102ae771770SStanislav Sedov * numbers are encoded in bytes seven bits at
103ae771770SStanislav Sedov * a time with the last byte having the high
104ae771770SStanislav Sedov * bit set.
105ae771770SStanislav Sedov */
106ae771770SStanislav Sedov if (j == 0) {
107ae771770SStanislav Sedov if (res)
108ae771770SStanislav Sedov *res = number * 40;
109ae771770SStanislav Sedov } else if (j == 1) {
110ae771770SStanislav Sedov if (res) {
111ae771770SStanislav Sedov *res += number;
112ae771770SStanislav Sedov res++;
113ae771770SStanislav Sedov }
114ae771770SStanislav Sedov byte_count++;
115ae771770SStanislav Sedov } else if (j >= 2) {
116ae771770SStanislav Sedov /*
117ae771770SStanislav Sedov * The number is encoded in seven bit chunks.
118ae771770SStanislav Sedov */
119ae771770SStanislav Sedov unsigned int t;
120ae771770SStanislav Sedov unsigned int bytes;
121ae771770SStanislav Sedov
122ae771770SStanislav Sedov bytes = 0;
123ae771770SStanislav Sedov for (t = number; t; t >>= 7)
124ae771770SStanislav Sedov bytes++;
125ae771770SStanislav Sedov if (bytes == 0) bytes = 1;
126ae771770SStanislav Sedov while (bytes) {
127ae771770SStanislav Sedov if (res) {
128ae771770SStanislav Sedov int bit = 7*(bytes-1);
129ae771770SStanislav Sedov
130ae771770SStanislav Sedov *res = (number >> bit) & 0x7f;
131ae771770SStanislav Sedov if (bytes != 1)
132ae771770SStanislav Sedov *res |= 0x80;
133ae771770SStanislav Sedov res++;
134ae771770SStanislav Sedov }
135ae771770SStanislav Sedov byte_count++;
136ae771770SStanislav Sedov bytes--;
137ae771770SStanislav Sedov }
138ae771770SStanislav Sedov }
139ae771770SStanislav Sedov }
140*ed549cb0SCy Schubert if (byte_count == 0)
141*ed549cb0SCy Schubert return EINVAL;
142ae771770SStanislav Sedov if (!res) {
143ae771770SStanislav Sedov res = malloc(byte_count);
144ae771770SStanislav Sedov if (!res)
145ae771770SStanislav Sedov return (ENOMEM);
146ae771770SStanislav Sedov oid->length = byte_count;
147ae771770SStanislav Sedov oid->elements = res;
148ae771770SStanislav Sedov }
149ae771770SStanislav Sedov }
150ae771770SStanislav Sedov
151ae771770SStanislav Sedov return (0);
152ae771770SStanislav Sedov }
153ae771770SStanislav Sedov
154ae771770SStanislav Sedov #define SYM(name) \
155ae771770SStanislav Sedov do { \
156ae771770SStanislav Sedov m->gm_mech.gm_ ## name = dlsym(so, "gss_" #name); \
157ae771770SStanislav Sedov if (!m->gm_mech.gm_ ## name || \
158ae771770SStanislav Sedov m->gm_mech.gm_ ##name == gss_ ## name) { \
159ae771770SStanislav Sedov fprintf(stderr, "can't find symbol gss_" #name "\n"); \
160ae771770SStanislav Sedov goto bad; \
161ae771770SStanislav Sedov } \
162ae771770SStanislav Sedov } while (0)
163ae771770SStanislav Sedov
164ae771770SStanislav Sedov #define OPTSYM(name) \
165ae771770SStanislav Sedov do { \
166ae771770SStanislav Sedov m->gm_mech.gm_ ## name = dlsym(so, "gss_" #name); \
167ae771770SStanislav Sedov if (m->gm_mech.gm_ ## name == gss_ ## name) \
168ae771770SStanislav Sedov m->gm_mech.gm_ ## name = NULL; \
169ae771770SStanislav Sedov } while (0)
170ae771770SStanislav Sedov
171ae771770SStanislav Sedov #define OPTSPISYM(name) \
172ae771770SStanislav Sedov do { \
173ae771770SStanislav Sedov m->gm_mech.gm_ ## name = dlsym(so, "gssspi_" #name); \
174ae771770SStanislav Sedov } while (0)
175ae771770SStanislav Sedov
176ae771770SStanislav Sedov #define COMPATSYM(name) \
177ae771770SStanislav Sedov do { \
178ae771770SStanislav Sedov m->gm_mech.gm_compat->gmc_ ## name = dlsym(so, "gss_" #name); \
179ae771770SStanislav Sedov if (m->gm_mech.gm_compat->gmc_ ## name == gss_ ## name) \
180ae771770SStanislav Sedov m->gm_mech.gm_compat->gmc_ ## name = NULL; \
181ae771770SStanislav Sedov } while (0)
182ae771770SStanislav Sedov
183ae771770SStanislav Sedov #define COMPATSPISYM(name) \
184ae771770SStanislav Sedov do { \
185ae771770SStanislav Sedov m->gm_mech.gm_compat->gmc_ ## name = dlsym(so, "gssspi_" #name);\
186ae771770SStanislav Sedov if (m->gm_mech.gm_compat->gmc_ ## name == gss_ ## name) \
187ae771770SStanislav Sedov m->gm_mech.gm_compat->gmc_ ## name = NULL; \
188ae771770SStanislav Sedov } while (0)
189ae771770SStanislav Sedov
190ae771770SStanislav Sedov /*
191ae771770SStanislav Sedov *
192ae771770SStanislav Sedov */
193ae771770SStanislav Sedov static int
add_builtin(gssapi_mech_interface mech)194ae771770SStanislav Sedov add_builtin(gssapi_mech_interface mech)
195ae771770SStanislav Sedov {
196ae771770SStanislav Sedov struct _gss_mech_switch *m;
197ae771770SStanislav Sedov OM_uint32 minor_status;
198ae771770SStanislav Sedov
199ae771770SStanislav Sedov /* not registering any mech is ok */
200ae771770SStanislav Sedov if (mech == NULL)
201ae771770SStanislav Sedov return 0;
202ae771770SStanislav Sedov
203ae771770SStanislav Sedov m = calloc(1, sizeof(*m));
204ae771770SStanislav Sedov if (m == NULL)
205ae771770SStanislav Sedov return ENOMEM;
206ae771770SStanislav Sedov m->gm_so = NULL;
207ae771770SStanislav Sedov m->gm_mech = *mech;
208ae771770SStanislav Sedov m->gm_mech_oid = mech->gm_mech_oid; /* XXX */
209ae771770SStanislav Sedov gss_add_oid_set_member(&minor_status,
210ae771770SStanislav Sedov &m->gm_mech.gm_mech_oid, &_gss_mech_oids);
211ae771770SStanislav Sedov
212ae771770SStanislav Sedov /* pick up the oid sets of names */
213ae771770SStanislav Sedov
214ae771770SStanislav Sedov if (m->gm_mech.gm_inquire_names_for_mech)
215ae771770SStanislav Sedov (*m->gm_mech.gm_inquire_names_for_mech)(&minor_status,
216ae771770SStanislav Sedov &m->gm_mech.gm_mech_oid, &m->gm_name_types);
217ae771770SStanislav Sedov
218ae771770SStanislav Sedov if (m->gm_name_types == NULL)
219ae771770SStanislav Sedov gss_create_empty_oid_set(&minor_status, &m->gm_name_types);
220ae771770SStanislav Sedov
221ae771770SStanislav Sedov HEIM_SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
222ae771770SStanislav Sedov return 0;
223ae771770SStanislav Sedov }
224ae771770SStanislav Sedov
225ae771770SStanislav Sedov /*
226ae771770SStanislav Sedov * Load the mechanisms file (/etc/gss/mech).
227ae771770SStanislav Sedov */
228ae771770SStanislav Sedov void
_gss_load_mech(void)229ae771770SStanislav Sedov _gss_load_mech(void)
230ae771770SStanislav Sedov {
231ae771770SStanislav Sedov OM_uint32 major_status, minor_status;
232ae771770SStanislav Sedov FILE *fp;
233ae771770SStanislav Sedov char buf[256];
234ae771770SStanislav Sedov char *p;
235ae771770SStanislav Sedov char *name, *oid, *lib, *kobj;
236ae771770SStanislav Sedov struct _gss_mech_switch *m;
237ae771770SStanislav Sedov void *so;
238ae771770SStanislav Sedov gss_OID_desc mech_oid;
239ae771770SStanislav Sedov int found;
240ae771770SStanislav Sedov
241ae771770SStanislav Sedov
242ae771770SStanislav Sedov HEIMDAL_MUTEX_lock(&_gss_mech_mutex);
243ae771770SStanislav Sedov
244ae771770SStanislav Sedov if (HEIM_SLIST_FIRST(&_gss_mechs)) {
245ae771770SStanislav Sedov HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
246ae771770SStanislav Sedov return;
247ae771770SStanislav Sedov }
248ae771770SStanislav Sedov
249ae771770SStanislav Sedov major_status = gss_create_empty_oid_set(&minor_status,
250ae771770SStanislav Sedov &_gss_mech_oids);
251ae771770SStanislav Sedov if (major_status) {
252ae771770SStanislav Sedov HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
253ae771770SStanislav Sedov return;
254ae771770SStanislav Sedov }
255ae771770SStanislav Sedov
256ae771770SStanislav Sedov add_builtin(__gss_krb5_initialize());
257ae771770SStanislav Sedov add_builtin(__gss_spnego_initialize());
258ae771770SStanislav Sedov add_builtin(__gss_ntlm_initialize());
259ae771770SStanislav Sedov
260ae771770SStanislav Sedov #ifdef HAVE_DLOPEN
261ae771770SStanislav Sedov fp = fopen(_PATH_GSS_MECH, "r");
262ae771770SStanislav Sedov if (!fp) {
263ae771770SStanislav Sedov HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
264ae771770SStanislav Sedov return;
265ae771770SStanislav Sedov }
266ae771770SStanislav Sedov rk_cloexec_file(fp);
267ae771770SStanislav Sedov
268ae771770SStanislav Sedov while (fgets(buf, sizeof(buf), fp)) {
269ae771770SStanislav Sedov _gss_mo_init *mi;
270ae771770SStanislav Sedov
271ae771770SStanislav Sedov if (*buf == '#')
272ae771770SStanislav Sedov continue;
273ae771770SStanislav Sedov p = buf;
274ae771770SStanislav Sedov name = strsep(&p, "\t\n ");
275ae771770SStanislav Sedov if (p) while (isspace((unsigned char)*p)) p++;
276ae771770SStanislav Sedov oid = strsep(&p, "\t\n ");
277ae771770SStanislav Sedov if (p) while (isspace((unsigned char)*p)) p++;
278ae771770SStanislav Sedov lib = strsep(&p, "\t\n ");
279ae771770SStanislav Sedov if (p) while (isspace((unsigned char)*p)) p++;
280ae771770SStanislav Sedov kobj = strsep(&p, "\t\n ");
281ae771770SStanislav Sedov if (!name || !oid || !lib || !kobj)
282ae771770SStanislav Sedov continue;
283ae771770SStanislav Sedov
284ae771770SStanislav Sedov if (_gss_string_to_oid(oid, &mech_oid))
285ae771770SStanislav Sedov continue;
286ae771770SStanislav Sedov
287ae771770SStanislav Sedov /*
288ae771770SStanislav Sedov * Check for duplicates, already loaded mechs.
289ae771770SStanislav Sedov */
290ae771770SStanislav Sedov found = 0;
291ae771770SStanislav Sedov HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
292ae771770SStanislav Sedov if (gss_oid_equal(&m->gm_mech.gm_mech_oid, &mech_oid)) {
293ae771770SStanislav Sedov found = 1;
294ae771770SStanislav Sedov free(mech_oid.elements);
295ae771770SStanislav Sedov break;
296ae771770SStanislav Sedov }
297ae771770SStanislav Sedov }
298ae771770SStanislav Sedov if (found)
299ae771770SStanislav Sedov continue;
300ae771770SStanislav Sedov
301ae771770SStanislav Sedov #ifndef RTLD_LOCAL
302ae771770SStanislav Sedov #define RTLD_LOCAL 0
303ae771770SStanislav Sedov #endif
304ae771770SStanislav Sedov
305ae771770SStanislav Sedov #ifndef RTLD_GROUP
306ae771770SStanislav Sedov #define RTLD_GROUP 0
307ae771770SStanislav Sedov #endif
308ae771770SStanislav Sedov
309ae771770SStanislav Sedov so = dlopen(lib, RTLD_LAZY | RTLD_LOCAL | RTLD_GROUP);
310ae771770SStanislav Sedov if (so == NULL) {
311ae771770SStanislav Sedov /* fprintf(stderr, "dlopen: %s\n", dlerror()); */
312ae771770SStanislav Sedov goto bad;
313ae771770SStanislav Sedov }
314ae771770SStanislav Sedov
315ae771770SStanislav Sedov m = calloc(1, sizeof(*m));
316ae771770SStanislav Sedov if (m == NULL)
317ae771770SStanislav Sedov goto bad;
318ae771770SStanislav Sedov
319ae771770SStanislav Sedov m->gm_so = so;
320ae771770SStanislav Sedov m->gm_mech.gm_mech_oid = mech_oid;
321ae771770SStanislav Sedov m->gm_mech.gm_flags = 0;
322ae771770SStanislav Sedov m->gm_mech.gm_compat = calloc(1, sizeof(struct gss_mech_compat_desc_struct));
323ae771770SStanislav Sedov if (m->gm_mech.gm_compat == NULL)
324ae771770SStanislav Sedov goto bad;
325ae771770SStanislav Sedov
326ae771770SStanislav Sedov major_status = gss_add_oid_set_member(&minor_status,
327ae771770SStanislav Sedov &m->gm_mech.gm_mech_oid, &_gss_mech_oids);
328ae771770SStanislav Sedov if (GSS_ERROR(major_status))
329ae771770SStanislav Sedov goto bad;
330ae771770SStanislav Sedov
331ae771770SStanislav Sedov SYM(acquire_cred);
332ae771770SStanislav Sedov SYM(release_cred);
333ae771770SStanislav Sedov SYM(init_sec_context);
334ae771770SStanislav Sedov SYM(accept_sec_context);
335ae771770SStanislav Sedov SYM(process_context_token);
336ae771770SStanislav Sedov SYM(delete_sec_context);
337ae771770SStanislav Sedov SYM(context_time);
338ae771770SStanislav Sedov SYM(get_mic);
339ae771770SStanislav Sedov SYM(verify_mic);
340ae771770SStanislav Sedov SYM(wrap);
341ae771770SStanislav Sedov SYM(unwrap);
342ae771770SStanislav Sedov SYM(display_status);
343ae771770SStanislav Sedov SYM(indicate_mechs);
344ae771770SStanislav Sedov SYM(compare_name);
345ae771770SStanislav Sedov SYM(display_name);
346ae771770SStanislav Sedov SYM(import_name);
347ae771770SStanislav Sedov SYM(export_name);
348ae771770SStanislav Sedov SYM(release_name);
349ae771770SStanislav Sedov SYM(inquire_cred);
350ae771770SStanislav Sedov SYM(inquire_context);
351ae771770SStanislav Sedov SYM(wrap_size_limit);
352ae771770SStanislav Sedov SYM(add_cred);
353ae771770SStanislav Sedov SYM(inquire_cred_by_mech);
354ae771770SStanislav Sedov SYM(export_sec_context);
355ae771770SStanislav Sedov SYM(import_sec_context);
356ae771770SStanislav Sedov SYM(inquire_names_for_mech);
357ae771770SStanislav Sedov SYM(inquire_mechs_for_name);
358ae771770SStanislav Sedov SYM(canonicalize_name);
359ae771770SStanislav Sedov SYM(duplicate_name);
360ae771770SStanislav Sedov OPTSYM(inquire_cred_by_oid);
361ae771770SStanislav Sedov OPTSYM(inquire_sec_context_by_oid);
362ae771770SStanislav Sedov OPTSYM(set_sec_context_option);
363ae771770SStanislav Sedov OPTSPISYM(set_cred_option);
364ae771770SStanislav Sedov OPTSYM(pseudo_random);
365ae771770SStanislav Sedov OPTSYM(wrap_iov);
366ae771770SStanislav Sedov OPTSYM(unwrap_iov);
367ae771770SStanislav Sedov OPTSYM(wrap_iov_length);
368ae771770SStanislav Sedov OPTSYM(store_cred);
369ae771770SStanislav Sedov OPTSYM(export_cred);
370ae771770SStanislav Sedov OPTSYM(import_cred);
371ae771770SStanislav Sedov #if 0
372ae771770SStanislav Sedov OPTSYM(acquire_cred_ext);
373ae771770SStanislav Sedov OPTSYM(iter_creds);
374ae771770SStanislav Sedov OPTSYM(destroy_cred);
375ae771770SStanislav Sedov OPTSYM(cred_hold);
376ae771770SStanislav Sedov OPTSYM(cred_unhold);
377ae771770SStanislav Sedov OPTSYM(cred_label_get);
378ae771770SStanislav Sedov OPTSYM(cred_label_set);
379ae771770SStanislav Sedov #endif
380ae771770SStanislav Sedov OPTSYM(display_name_ext);
381ae771770SStanislav Sedov OPTSYM(inquire_name);
382ae771770SStanislav Sedov OPTSYM(get_name_attribute);
383ae771770SStanislav Sedov OPTSYM(set_name_attribute);
384ae771770SStanislav Sedov OPTSYM(delete_name_attribute);
385ae771770SStanislav Sedov OPTSYM(export_name_composite);
386ae771770SStanislav Sedov OPTSYM(pname_to_uid);
387ae771770SStanislav Sedov OPTSPISYM(authorize_localname);
388ae771770SStanislav Sedov
389ae771770SStanislav Sedov mi = dlsym(so, "gss_mo_init");
390ae771770SStanislav Sedov if (mi != NULL) {
391ae771770SStanislav Sedov major_status = mi(&minor_status, &mech_oid,
392ae771770SStanislav Sedov &m->gm_mech.gm_mo, &m->gm_mech.gm_mo_num);
393ae771770SStanislav Sedov if (GSS_ERROR(major_status))
394ae771770SStanislav Sedov goto bad;
395ae771770SStanislav Sedov } else {
396ae771770SStanislav Sedov /* API-as-SPI compatibility */
397ae771770SStanislav Sedov COMPATSYM(inquire_saslname_for_mech);
398ae771770SStanislav Sedov COMPATSYM(inquire_mech_for_saslname);
399ae771770SStanislav Sedov COMPATSYM(inquire_attrs_for_mech);
400ae771770SStanislav Sedov COMPATSPISYM(acquire_cred_with_password);
401ae771770SStanislav Sedov }
402ae771770SStanislav Sedov
403ae771770SStanislav Sedov /* pick up the oid sets of names */
404ae771770SStanislav Sedov
405ae771770SStanislav Sedov if (m->gm_mech.gm_inquire_names_for_mech)
406ae771770SStanislav Sedov (*m->gm_mech.gm_inquire_names_for_mech)(&minor_status,
407ae771770SStanislav Sedov &m->gm_mech.gm_mech_oid, &m->gm_name_types);
408ae771770SStanislav Sedov
409ae771770SStanislav Sedov if (m->gm_name_types == NULL)
410ae771770SStanislav Sedov gss_create_empty_oid_set(&minor_status, &m->gm_name_types);
411ae771770SStanislav Sedov
412ae771770SStanislav Sedov HEIM_SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
413ae771770SStanislav Sedov continue;
414ae771770SStanislav Sedov
415ae771770SStanislav Sedov bad:
416ae771770SStanislav Sedov if (m != NULL) {
417ae771770SStanislav Sedov free(m->gm_mech.gm_compat);
418ae771770SStanislav Sedov free(m->gm_mech.gm_mech_oid.elements);
419ae771770SStanislav Sedov free(m);
420ae771770SStanislav Sedov }
421ae771770SStanislav Sedov dlclose(so);
422ae771770SStanislav Sedov continue;
423ae771770SStanislav Sedov }
424ae771770SStanislav Sedov fclose(fp);
425ae771770SStanislav Sedov #endif
426ae771770SStanislav Sedov HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
427ae771770SStanislav Sedov }
428ae771770SStanislav Sedov
429ae771770SStanislav Sedov gssapi_mech_interface
__gss_get_mechanism(gss_const_OID mech)430ae771770SStanislav Sedov __gss_get_mechanism(gss_const_OID mech)
431ae771770SStanislav Sedov {
432ae771770SStanislav Sedov struct _gss_mech_switch *m;
433ae771770SStanislav Sedov
434ae771770SStanislav Sedov _gss_load_mech();
435ae771770SStanislav Sedov HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
436ae771770SStanislav Sedov if (gss_oid_equal(&m->gm_mech.gm_mech_oid, mech))
437ae771770SStanislav Sedov return &m->gm_mech;
438ae771770SStanislav Sedov }
439ae771770SStanislav Sedov return NULL;
440ae771770SStanislav Sedov }
441