1/* dlopen.c--Unix dlopen() dynamic loader interface
2 * Rob Siemborski
3 * Rob Earhart
4 * $Id: staticopen.c,v 1.2 2002/05/22 17:56:56 snsimon Exp $
5 */
6/*
7 * Copyright (c) 2001 Carnegie Mellon University.  All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in
18 *    the documentation and/or other materials provided with the
19 *    distribution.
20 *
21 * 3. The name "Carnegie Mellon University" must not be used to
22 *    endorse or promote products derived from this software without
23 *    prior written permission. For permission or any other legal
24 *    details, please contact
25 *      Office of Technology Transfer
26 *      Carnegie Mellon University
27 *      5000 Forbes Avenue
28 *      Pittsburgh, PA  15213-3890
29 *      (412) 268-4387, fax: (412) 268-7395
30 *      tech-transfer@andrew.cmu.edu
31 *
32 * 4. Redistributions of any form whatsoever must retain the following
33 *    acknowledgment:
34 *    "This product includes software developed by Computing Services
35 *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
36 *
37 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
38 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
39 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
40 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
41 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
42 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
43 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
44 */
45
46#include <config.h>
47#include <stdlib.h>
48#include <limits.h>
49#include <sys/param.h>
50#include <sasl.h>
51#include "saslint.h"
52#include "staticopen.h"
53
54const int _is_sasl_server_static = 1;
55
56/* gets the list of mechanisms */
57int _sasl_load_plugins(const add_plugin_list_t *entrypoints,
58                       const sasl_callback_t *getpath_callback __attribute__((unused)),
59                       const sasl_callback_t *verifyfile_callback __attribute__((unused)))
60{
61    int result = SASL_OK;
62    const add_plugin_list_t *cur_ep;
63    int (*add_plugin)(const char *, void *);
64    enum {
65	UNKNOWN = 0, SERVER = 1, CLIENT = 2, AUXPROP = 3, CANONUSER = 4
66    } type;
67
68    for(cur_ep = entrypoints; cur_ep->entryname; cur_ep++) {
69
70	/* What type of plugin are we looking for? */
71	if(!strcmp(cur_ep->entryname, "sasl_server_plug_init")) {
72	    type = SERVER;
73	    add_plugin = (void *)sasl_server_add_plugin;
74	} else if (!strcmp(cur_ep->entryname, "sasl_client_plug_init")) {
75	    type = CLIENT;
76	    add_plugin = (void *)sasl_client_add_plugin;
77	} else if (!strcmp(cur_ep->entryname, "sasl_auxprop_plug_init")) {
78	    type = AUXPROP;
79	    add_plugin = (void *)sasl_auxprop_add_plugin;
80	} else if (!strcmp(cur_ep->entryname, "sasl_canonuser_init")) {
81	    type = CANONUSER;
82	    add_plugin = (void *)sasl_canonuser_add_plugin;
83	} else {
84	    /* What are we looking for then? */
85	    return SASL_FAIL;
86	}
87
88#ifdef STATIC_ANONYMOUS
89	if(type == SERVER) {
90	    result = (*add_plugin)("ANONYMOUS",
91				   SPECIFIC_SERVER_PLUG_INIT( anonymous ));
92	} else if (type == CLIENT) {
93	    result = (*add_plugin)("ANONYMOUS",
94				   SPECIFIC_CLIENT_PLUG_INIT( anonymous ));
95	}
96#endif
97
98#ifdef STATIC_CRAMMD5
99	if(type == SERVER) {
100	    result = (*add_plugin)("CRAM-MD5",
101				   SPECIFIC_SERVER_PLUG_INIT( crammd5 ));
102	} else if (type == CLIENT) {
103	    result = (*add_plugin)("CRAM-MD5",
104				   SPECIFIC_CLIENT_PLUG_INIT( crammd5 ));
105	}
106#endif
107
108#ifdef STATIC_DIGESTMD5
109	if(type == SERVER) {
110	    result = (*add_plugin)("DIGEST-MD5",
111				   SPECIFIC_SERVER_PLUG_INIT( digestmd5 ));
112	} else if (type == CLIENT) {
113	    result = (*add_plugin)("DIGEST-MD5",
114				   SPECIFIC_CLIENT_PLUG_INIT( digestmd5 ));
115	}
116#endif
117
118#ifdef STATIC_GSSAPIV2
119	if(type == SERVER) {
120	    result = (*add_plugin)("GSSAPI",
121				   SPECIFIC_SERVER_PLUG_INIT( gssapiv2 ));
122	} else if (type == CLIENT) {
123	    result = (*add_plugin)("GSSAPI",
124				   SPECIFIC_CLIENT_PLUG_INIT( gssapiv2 ));
125	}
126#endif
127
128#ifdef STATIC_KERBEROS4
129	if(type == SERVER) {
130	    result = (*add_plugin)("KERBEROS_V4",
131				   SPECIFIC_SERVER_PLUG_INIT( kerberos4 ));
132	} else if (type == CLIENT) {
133	    result = (*add_plugin)("KERBEROS_V4",
134				   SPECIFIC_CLIENT_PLUG_INIT( kerberos4 ));
135	}
136#endif
137
138#ifdef STATIC_LOGIN
139	if(type == SERVER) {
140	    result = (*add_plugin)("LOGIN",
141				   SPECIFIC_SERVER_PLUG_INIT( login ));
142	} else if (type == CLIENT) {
143	    result = (*add_plugin)("LOGIN",
144				   SPECIFIC_CLIENT_PLUG_INIT( login ));
145	}
146#endif
147
148#ifdef STATIC_OTP
149	if(type == SERVER) {
150	    result = (*add_plugin)("OTP",
151				   SPECIFIC_SERVER_PLUG_INIT( otp ));
152	} else if (type == CLIENT) {
153	    result = (*add_plugin)("OTP",
154				   SPECIFIC_CLIENT_PLUG_INIT( otp ));
155	}
156#endif
157
158#ifdef STATIC_PLAIN
159	if(type == SERVER) {
160	    result = (*add_plugin)("PLAIN",
161				   SPECIFIC_SERVER_PLUG_INIT( plain ));
162	} else if (type == CLIENT) {
163	    result = (*add_plugin)("PLAIN",
164				   SPECIFIC_CLIENT_PLUG_INIT( plain ));
165	}
166#endif
167
168#ifdef STATIC_SRP
169	if(type == SERVER) {
170	    result = (*add_plugin)("SRP", SPECIFIC_SERVER_PLUG_INIT( srp ));
171	} else if (type == CLIENT) {
172	    result = (*add_plugin)("SRP", SPECIFIC_CLIENT_PLUG_INIT( srp ));
173	}
174#endif
175
176#ifdef STATIC_SASLDB
177	if(type == AUXPROP) {
178	    result = (*add_plugin)("SASLDB",
179				   SPECIFIC_AUXPROP_PLUG_INIT( sasldb ));
180	}
181#endif
182
183    }
184
185    return SASL_OK;
186}
187
188
189/* loads a single mechanism (or rather, fails to) */
190int _sasl_get_plugin(const char *file __attribute__((unused)),
191		     const sasl_callback_t *verifyfile_cb __attribute__((unused)),
192		     void **libraryptr __attribute__((unused)))
193{
194    return SASL_FAIL;
195}
196
197/* fails to locate an entry point ;) */
198int _sasl_locate_entry(void *library __attribute__((unused)),
199		       const char *entryname __attribute__((unused)),
200                       void **entry_point __attribute__((unused)))
201{
202    return SASL_FAIL;
203}
204
205
206int
207_sasl_done_with_plugins()
208{
209    return SASL_OK;
210}
211