xref: /illumos-gate/usr/src/lib/libsasl/lib/saslint.h (revision 694c35fa)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate /* saslint.h - internal SASL library definitions
7*7c478bd9Sstevel@tonic-gate  * Rob Siemborski
8*7c478bd9Sstevel@tonic-gate  * Tim Martin
9*7c478bd9Sstevel@tonic-gate  * $Id: saslint.h,v 1.48 2003/04/16 19:36:01 rjs3 Exp $
10*7c478bd9Sstevel@tonic-gate  */
11*7c478bd9Sstevel@tonic-gate /*
12*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
15*7c478bd9Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
16*7c478bd9Sstevel@tonic-gate  * are met:
17*7c478bd9Sstevel@tonic-gate  *
18*7c478bd9Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
19*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
20*7c478bd9Sstevel@tonic-gate  *
21*7c478bd9Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
22*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in
23*7c478bd9Sstevel@tonic-gate  *    the documentation and/or other materials provided with the
24*7c478bd9Sstevel@tonic-gate  *    distribution.
25*7c478bd9Sstevel@tonic-gate  *
26*7c478bd9Sstevel@tonic-gate  * 3. The name "Carnegie Mellon University" must not be used to
27*7c478bd9Sstevel@tonic-gate  *    endorse or promote products derived from this software without
28*7c478bd9Sstevel@tonic-gate  *    prior written permission. For permission or any other legal
29*7c478bd9Sstevel@tonic-gate  *    details, please contact
30*7c478bd9Sstevel@tonic-gate  *      Office of Technology Transfer
31*7c478bd9Sstevel@tonic-gate  *      Carnegie Mellon University
32*7c478bd9Sstevel@tonic-gate  *      5000 Forbes Avenue
33*7c478bd9Sstevel@tonic-gate  *      Pittsburgh, PA  15213-3890
34*7c478bd9Sstevel@tonic-gate  *      (412) 268-4387, fax: (412) 268-7395
35*7c478bd9Sstevel@tonic-gate  *      tech-transfer@andrew.cmu.edu
36*7c478bd9Sstevel@tonic-gate  *
37*7c478bd9Sstevel@tonic-gate  * 4. Redistributions of any form whatsoever must retain the following
38*7c478bd9Sstevel@tonic-gate  *    acknowledgment:
39*7c478bd9Sstevel@tonic-gate  *    "This product includes software developed by Computing Services
40*7c478bd9Sstevel@tonic-gate  *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
41*7c478bd9Sstevel@tonic-gate  *
42*7c478bd9Sstevel@tonic-gate  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
43*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
44*7c478bd9Sstevel@tonic-gate  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
45*7c478bd9Sstevel@tonic-gate  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
46*7c478bd9Sstevel@tonic-gate  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
47*7c478bd9Sstevel@tonic-gate  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
48*7c478bd9Sstevel@tonic-gate  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49*7c478bd9Sstevel@tonic-gate  */
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate #ifndef SASLINT_H
52*7c478bd9Sstevel@tonic-gate #define SASLINT_H
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #include <config.h>
55*7c478bd9Sstevel@tonic-gate #include "sasl.h"
56*7c478bd9Sstevel@tonic-gate #include "saslplug.h"
57*7c478bd9Sstevel@tonic-gate #include "saslutil.h"
58*7c478bd9Sstevel@tonic-gate #include "prop.h"
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /* #define'd constants */
61*7c478bd9Sstevel@tonic-gate #define CANON_BUF_SIZE 256
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /* Error Handling Foo */
64*7c478bd9Sstevel@tonic-gate /* Helpful Hints:
65*7c478bd9Sstevel@tonic-gate  *  -Error strings are set as soon as possible (first function in stack trace
66*7c478bd9Sstevel@tonic-gate  *   with a pointer to the sasl_conn_t.
67*7c478bd9Sstevel@tonic-gate  *  -Error codes are set as late as possible (only in the sasl api functions),
68*7c478bd9Sstevel@tonic-gate  *   thoug "as often as possible" also comes to mind to ensure correctness
69*7c478bd9Sstevel@tonic-gate  *  -Errors from calls to _buf_alloc, _sasl_strdup, etc are assumed to be
70*7c478bd9Sstevel@tonic-gate  *   memory errors.
71*7c478bd9Sstevel@tonic-gate  *  -Only errors (error codes < SASL_OK) should be remembered
72*7c478bd9Sstevel@tonic-gate  */
73*7c478bd9Sstevel@tonic-gate #define RETURN(conn, val) { if(conn && (val) < SASL_OK) \
74*7c478bd9Sstevel@tonic-gate                                (conn)->error_code = (val); \
75*7c478bd9Sstevel@tonic-gate                             return (val); }
76*7c478bd9Sstevel@tonic-gate #if !defined _SUN_SDK || defined  DEBUG
77*7c478bd9Sstevel@tonic-gate #define MEMERROR(conn) {\
78*7c478bd9Sstevel@tonic-gate     if(conn) sasl_seterror( (conn), 0, \
79*7c478bd9Sstevel@tonic-gate                    "Out of Memory in " __FILE__ " near line %d", __LINE__ ); \
80*7c478bd9Sstevel@tonic-gate     RETURN(conn, SASL_NOMEM) }
81*7c478bd9Sstevel@tonic-gate #define PARAMERROR(conn) {\
82*7c478bd9Sstevel@tonic-gate     if(conn) sasl_seterror( (conn), SASL_NOLOG, \
83*7c478bd9Sstevel@tonic-gate                   "Parameter error in " __FILE__ " near line %d", __LINE__ ); \
84*7c478bd9Sstevel@tonic-gate     RETURN(conn, SASL_BADPARAM) }
85*7c478bd9Sstevel@tonic-gate #define INTERROR(conn, val) {\
86*7c478bd9Sstevel@tonic-gate     if(conn) sasl_seterror( (conn), 0, \
87*7c478bd9Sstevel@tonic-gate                    "Internal Error %d in " __FILE__ " near line %d", (val),\
88*7c478bd9Sstevel@tonic-gate 		   __LINE__ ); \
89*7c478bd9Sstevel@tonic-gate     RETURN(conn, (val)) }
90*7c478bd9Sstevel@tonic-gate #else
91*7c478bd9Sstevel@tonic-gate #define MEMERROR(conn) {\
92*7c478bd9Sstevel@tonic-gate     if(conn) _sasl_log((conn), SASL_LOG_WARN, "Out of Memory"); \
93*7c478bd9Sstevel@tonic-gate     RETURN(conn, SASL_NOMEM) }
94*7c478bd9Sstevel@tonic-gate #define PARAMERROR(conn) {\
95*7c478bd9Sstevel@tonic-gate     if(conn) _sasl_log((conn), SASL_LOG_WARN, "Parameter error"); \
96*7c478bd9Sstevel@tonic-gate     RETURN(conn, SASL_BADPARAM) }
97*7c478bd9Sstevel@tonic-gate #define INTERROR(conn, val) {\
98*7c478bd9Sstevel@tonic-gate     if(conn) _sasl_log((conn), SASL_LOG_ERR, "Internal Error: %d", (val)); \
99*7c478bd9Sstevel@tonic-gate     RETURN(conn, (val)) }
100*7c478bd9Sstevel@tonic-gate #endif
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate #ifndef PATH_MAX
103*7c478bd9Sstevel@tonic-gate # ifdef WIN32
104*7c478bd9Sstevel@tonic-gate #  define PATH_MAX MAX_PATH
105*7c478bd9Sstevel@tonic-gate # else
106*7c478bd9Sstevel@tonic-gate #  ifdef _POSIX_PATH_MAX
107*7c478bd9Sstevel@tonic-gate #   define PATH_MAX _POSIX_PATH_MAX
108*7c478bd9Sstevel@tonic-gate #  else
109*7c478bd9Sstevel@tonic-gate #   define PATH_MAX 1024         /* arbitrary; probably big enough will
110*7c478bd9Sstevel@tonic-gate                                   * probably only be 256+64 on
111*7c478bd9Sstevel@tonic-gate                                   * pre-posix machines */
112*7c478bd9Sstevel@tonic-gate #  endif /* _POSIX_PATH_MAX */
113*7c478bd9Sstevel@tonic-gate # endif /* WIN32 */
114*7c478bd9Sstevel@tonic-gate #endif
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate /* : Define directory delimiter in SASL_PATH variable */
117*7c478bd9Sstevel@tonic-gate #ifdef WIN32
118*7c478bd9Sstevel@tonic-gate #define PATHS_DELIMITER	';'
119*7c478bd9Sstevel@tonic-gate #else
120*7c478bd9Sstevel@tonic-gate #define PATHS_DELIMITER	':'
121*7c478bd9Sstevel@tonic-gate #endif
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate /* Datatype Definitions */
124*7c478bd9Sstevel@tonic-gate typedef struct {
125*7c478bd9Sstevel@tonic-gate   const sasl_callback_t *callbacks;
126*7c478bd9Sstevel@tonic-gate   const char *appname;
127*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
128*7c478bd9Sstevel@tonic-gate   struct _sasl_global_context_s *gctx;
129*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
130*7c478bd9Sstevel@tonic-gate } sasl_global_callbacks_t;
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate typedef struct _sasl_external_properties
133*7c478bd9Sstevel@tonic-gate {
134*7c478bd9Sstevel@tonic-gate     sasl_ssf_t ssf;
135*7c478bd9Sstevel@tonic-gate     char *auth_id;
136*7c478bd9Sstevel@tonic-gate } _sasl_external_properties_t;
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate typedef struct sasl_string_list
139*7c478bd9Sstevel@tonic-gate {
140*7c478bd9Sstevel@tonic-gate     const char *d;
141*7c478bd9Sstevel@tonic-gate     struct sasl_string_list *next;
142*7c478bd9Sstevel@tonic-gate } sasl_string_list_t;
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate typedef struct buffer_info
145*7c478bd9Sstevel@tonic-gate {
146*7c478bd9Sstevel@tonic-gate     char *data;
147*7c478bd9Sstevel@tonic-gate     size_t curlen;
148*7c478bd9Sstevel@tonic-gate     size_t reallen;
149*7c478bd9Sstevel@tonic-gate } buffer_info_t;
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
152*7c478bd9Sstevel@tonic-gate typedef int add_plugin_t(struct _sasl_global_context_s *gctx,
153*7c478bd9Sstevel@tonic-gate 			const char *, void *);
154*7c478bd9Sstevel@tonic-gate #else
155*7c478bd9Sstevel@tonic-gate typedef int add_plugin_t(const char *, void *);
156*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate typedef struct add_plugin_list
159*7c478bd9Sstevel@tonic-gate {
160*7c478bd9Sstevel@tonic-gate     const char *entryname;
161*7c478bd9Sstevel@tonic-gate     add_plugin_t *add_plugin;
162*7c478bd9Sstevel@tonic-gate } add_plugin_list_t;
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate enum Sasl_conn_type { SASL_CONN_UNKNOWN = 0,
165*7c478bd9Sstevel@tonic-gate 		      SASL_CONN_SERVER = 1,
166*7c478bd9Sstevel@tonic-gate                       SASL_CONN_CLIENT = 2 };
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate struct sasl_conn {
169*7c478bd9Sstevel@tonic-gate   enum Sasl_conn_type type;
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate   void (*destroy_conn)(sasl_conn_t *); /* destroy function */
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate   char *service;
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate   unsigned int flags;  /* flags passed to sasl_*_new */
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate   /* IP information.  A buffer of size 52 is adequate for this in its
178*7c478bd9Sstevel@tonic-gate      longest format (see sasl.h) */
179*7c478bd9Sstevel@tonic-gate   int got_ip_local, got_ip_remote;
180*7c478bd9Sstevel@tonic-gate   char iplocalport[NI_MAXHOST + NI_MAXSERV];
181*7c478bd9Sstevel@tonic-gate   char ipremoteport[NI_MAXHOST + NI_MAXSERV];
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate   void *context;
184*7c478bd9Sstevel@tonic-gate   sasl_out_params_t oparams;
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate   sasl_security_properties_t props;
187*7c478bd9Sstevel@tonic-gate   _sasl_external_properties_t external;
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate #ifndef _SUN_SDK_
190*7c478bd9Sstevel@tonic-gate   sasl_secret_t *secret;
191*7c478bd9Sstevel@tonic-gate #endif /* !_SUN_SDK_ */
192*7c478bd9Sstevel@tonic-gate 
193*7c478bd9Sstevel@tonic-gate   int (*idle_hook)(sasl_conn_t *conn);
194*7c478bd9Sstevel@tonic-gate   const sasl_callback_t *callbacks;
195*7c478bd9Sstevel@tonic-gate   const sasl_global_callbacks_t *global_callbacks; /* global callbacks
196*7c478bd9Sstevel@tonic-gate 						    * connection */
197*7c478bd9Sstevel@tonic-gate   char *serverFQDN;
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate   /* Pointers to memory that we are responsible for */
200*7c478bd9Sstevel@tonic-gate   buffer_info_t *encode_buf;
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate   int error_code;
203*7c478bd9Sstevel@tonic-gate   char *error_buf, *errdetail_buf;
204*7c478bd9Sstevel@tonic-gate   size_t error_buf_len, errdetail_buf_len;
205*7c478bd9Sstevel@tonic-gate   char *mechlist_buf;
206*7c478bd9Sstevel@tonic-gate   size_t mechlist_buf_len;
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate   char *decode_buf;
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate   char user_buf[CANON_BUF_SIZE+1], authid_buf[CANON_BUF_SIZE+1];
211*7c478bd9Sstevel@tonic-gate 
212*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
213*7c478bd9Sstevel@tonic-gate   struct _sasl_global_context_s *gctx;
214*7c478bd9Sstevel@tonic-gate #ifdef _INTEGRATED_SOLARIS_
215*7c478bd9Sstevel@tonic-gate   int sun_reg;
216*7c478bd9Sstevel@tonic-gate #endif /* _INTEGRATED_SOLARIS_ */
217*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
218*7c478bd9Sstevel@tonic-gate };
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
221*7c478bd9Sstevel@tonic-gate /* track changes in file system */
222*7c478bd9Sstevel@tonic-gate typedef struct _sasl_path_info {
223*7c478bd9Sstevel@tonic-gate     char *path;
224*7c478bd9Sstevel@tonic-gate     time_t last_changed;
225*7c478bd9Sstevel@tonic-gate     struct _sasl_path_info *next;
226*7c478bd9Sstevel@tonic-gate } _sasl_path_info_t;
227*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
228*7c478bd9Sstevel@tonic-gate 
229*7c478bd9Sstevel@tonic-gate /* Server Conn Type Information */
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate typedef struct mechanism
232*7c478bd9Sstevel@tonic-gate {
233*7c478bd9Sstevel@tonic-gate     int version;
234*7c478bd9Sstevel@tonic-gate     int condition; /* set to SASL_NOUSER if no available users;
235*7c478bd9Sstevel@tonic-gate 		      set to SASL_CONTINUE if delayed plugn loading */
236*7c478bd9Sstevel@tonic-gate     char *plugname; /* for AUTHSOURCE tracking */
237*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
238*7c478bd9Sstevel@tonic-gate #ifdef _INTEGRATED_SOLARIS_
239*7c478bd9Sstevel@tonic-gate     int sun_reg;
240*7c478bd9Sstevel@tonic-gate #endif /* _INTEGRATED_SOLARIS_ */
241*7c478bd9Sstevel@tonic-gate     sasl_server_plug_t *plug;
242*7c478bd9Sstevel@tonic-gate 	/*
243*7c478bd9Sstevel@tonic-gate 	 * The global context needs to be stored with separately from the
244*7c478bd9Sstevel@tonic-gate 	 * the plugin because it will be overwritten when the plugin is
245*7c478bd9Sstevel@tonic-gate 	 * relloaded
246*7c478bd9Sstevel@tonic-gate 	 */
247*7c478bd9Sstevel@tonic-gate     void *glob_context;
248*7c478bd9Sstevel@tonic-gate     struct mechanism *next;
249*7c478bd9Sstevel@tonic-gate #else
250*7c478bd9Sstevel@tonic-gate     const sasl_server_plug_t *plug;
251*7c478bd9Sstevel@tonic-gate     struct mechanism *next;
252*7c478bd9Sstevel@tonic-gate     char *f;       /* where should i load the mechanism from? */
253*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
254*7c478bd9Sstevel@tonic-gate } mechanism_t;
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate typedef struct mech_list {
257*7c478bd9Sstevel@tonic-gate   const sasl_utils_t *utils;  /* gotten from plug_init */
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate   void *mutex;            /* mutex for this data */
260*7c478bd9Sstevel@tonic-gate   mechanism_t *mech_list; /* list of mechanisms */
261*7c478bd9Sstevel@tonic-gate   int mech_length;       /* number of mechanisms */
262*7c478bd9Sstevel@tonic-gate } mech_list_t;
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate typedef struct context_list
265*7c478bd9Sstevel@tonic-gate {
266*7c478bd9Sstevel@tonic-gate     mechanism_t *mech;
267*7c478bd9Sstevel@tonic-gate     void *context;     /* if NULL, this mech is disabled for this connection
268*7c478bd9Sstevel@tonic-gate 			* otherwise, use this context instead of a call
269*7c478bd9Sstevel@tonic-gate 			* to mech_new */
270*7c478bd9Sstevel@tonic-gate     struct context_list *next;
271*7c478bd9Sstevel@tonic-gate } context_list_t;
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate typedef struct sasl_server_conn {
274*7c478bd9Sstevel@tonic-gate     sasl_conn_t base; /* parts common to server + client */
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate     char *user_realm; /* domain the user authenticating is in */
277*7c478bd9Sstevel@tonic-gate     int sent_last; /* Have we already done the last send? */
278*7c478bd9Sstevel@tonic-gate     int authenticated;
279*7c478bd9Sstevel@tonic-gate     mechanism_t *mech; /* mechanism trying to use */
280*7c478bd9Sstevel@tonic-gate     sasl_server_params_t *sparams;
281*7c478bd9Sstevel@tonic-gate     context_list_t *mech_contexts;
282*7c478bd9Sstevel@tonic-gate } sasl_server_conn_t;
283*7c478bd9Sstevel@tonic-gate 
284*7c478bd9Sstevel@tonic-gate /* Client Conn Type Information */
285*7c478bd9Sstevel@tonic-gate 
286*7c478bd9Sstevel@tonic-gate typedef struct cmechanism
287*7c478bd9Sstevel@tonic-gate {
288*7c478bd9Sstevel@tonic-gate     int version;
289*7c478bd9Sstevel@tonic-gate 
290*7c478bd9Sstevel@tonic-gate     char *plugname;
291*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
292*7c478bd9Sstevel@tonic-gate #ifdef _INTEGRATED_SOLARIS_
293*7c478bd9Sstevel@tonic-gate     int sun_reg;
294*7c478bd9Sstevel@tonic-gate #endif /* _INTEGRATED_SOLARIS_ */
295*7c478bd9Sstevel@tonic-gate 	/*
296*7c478bd9Sstevel@tonic-gate 	 * The global context needs to be stored with separately from the
297*7c478bd9Sstevel@tonic-gate 	 * the plugin because it will be overwritten when the plugin is
298*7c478bd9Sstevel@tonic-gate 	 * relloaded
299*7c478bd9Sstevel@tonic-gate 	 */
300*7c478bd9Sstevel@tonic-gate     void *glob_context;
301*7c478bd9Sstevel@tonic-gate     sasl_client_plug_t *plug;
302*7c478bd9Sstevel@tonic-gate #else
303*7c478bd9Sstevel@tonic-gate     const sasl_client_plug_t *plug;
304*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate     struct cmechanism *next;
307*7c478bd9Sstevel@tonic-gate } cmechanism_t;
308*7c478bd9Sstevel@tonic-gate 
309*7c478bd9Sstevel@tonic-gate typedef struct cmech_list {
310*7c478bd9Sstevel@tonic-gate   const sasl_utils_t *utils;
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate   void *mutex;            /* mutex for this data */
313*7c478bd9Sstevel@tonic-gate   cmechanism_t *mech_list; /* list of mechanisms */
314*7c478bd9Sstevel@tonic-gate   int mech_length;       /* number of mechanisms */
315*7c478bd9Sstevel@tonic-gate 
316*7c478bd9Sstevel@tonic-gate } cmech_list_t;
317*7c478bd9Sstevel@tonic-gate 
318*7c478bd9Sstevel@tonic-gate typedef struct sasl_client_conn {
319*7c478bd9Sstevel@tonic-gate   sasl_conn_t base; /* parts common to server + client */
320*7c478bd9Sstevel@tonic-gate 
321*7c478bd9Sstevel@tonic-gate   cmechanism_t *mech;
322*7c478bd9Sstevel@tonic-gate   sasl_client_params_t *cparams;
323*7c478bd9Sstevel@tonic-gate 
324*7c478bd9Sstevel@tonic-gate   char *clientFQDN;
325*7c478bd9Sstevel@tonic-gate 
326*7c478bd9Sstevel@tonic-gate } sasl_client_conn_t;
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate typedef struct sasl_allocation_utils {
329*7c478bd9Sstevel@tonic-gate   sasl_malloc_t *malloc;
330*7c478bd9Sstevel@tonic-gate   sasl_calloc_t *calloc;
331*7c478bd9Sstevel@tonic-gate   sasl_realloc_t *realloc;
332*7c478bd9Sstevel@tonic-gate   sasl_free_t *free;
333*7c478bd9Sstevel@tonic-gate } sasl_allocation_utils_t;
334*7c478bd9Sstevel@tonic-gate 
335*7c478bd9Sstevel@tonic-gate typedef struct sasl_mutex_utils {
336*7c478bd9Sstevel@tonic-gate   sasl_mutex_alloc_t *alloc;
337*7c478bd9Sstevel@tonic-gate   sasl_mutex_lock_t *lock;
338*7c478bd9Sstevel@tonic-gate   sasl_mutex_unlock_t *unlock;
339*7c478bd9Sstevel@tonic-gate   sasl_mutex_free_t *free;
340*7c478bd9Sstevel@tonic-gate } sasl_mutex_utils_t;
341*7c478bd9Sstevel@tonic-gate 
342*7c478bd9Sstevel@tonic-gate typedef struct sasl_log_utils_s {
343*7c478bd9Sstevel@tonic-gate   sasl_log_t *log;
344*7c478bd9Sstevel@tonic-gate } sasl_log_utils_t;
345*7c478bd9Sstevel@tonic-gate 
346*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
347*7c478bd9Sstevel@tonic-gate /*
348*7c478bd9Sstevel@tonic-gate  * The following structure contains the global state for libsasl */
349*7c478bd9Sstevel@tonic-gate typedef struct _sasl_global_context_s {
350*7c478bd9Sstevel@tonic-gate     int				sasl_server_active;
351*7c478bd9Sstevel@tonic-gate 				/* sasl server init'ed */
352*7c478bd9Sstevel@tonic-gate     mech_list_t			*mechlist;
353*7c478bd9Sstevel@tonic-gate 				/* list of server mechs */
354*7c478bd9Sstevel@tonic-gate     _sasl_path_info_t		*splug_path_info;
355*7c478bd9Sstevel@tonic-gate 				/* path info for server plugins */
356*7c478bd9Sstevel@tonic-gate     sasl_global_callbacks_t	server_global_callbacks;
357*7c478bd9Sstevel@tonic-gate 				/* callbacks for sasl_server_init */
358*7c478bd9Sstevel@tonic-gate     int				(*sasl_server_cleanup_hook)
359*7c478bd9Sstevel@tonic-gate 					(struct _sasl_global_context_s *gctx);
360*7c478bd9Sstevel@tonic-gate 				/* entry point to clean up sasl server */
361*7c478bd9Sstevel@tonic-gate     int				(*sasl_server_idle_hook)(sasl_conn_t *conn);
362*7c478bd9Sstevel@tonic-gate 				/* entry point for sasl server idle */
363*7c478bd9Sstevel@tonic-gate 
364*7c478bd9Sstevel@tonic-gate     cmech_list_t		*cmechlist;
365*7c478bd9Sstevel@tonic-gate 				/* list of client mechs */
366*7c478bd9Sstevel@tonic-gate     _sasl_path_info_t		*cplug_path_info;
367*7c478bd9Sstevel@tonic-gate 				/* path info for client plugins */
368*7c478bd9Sstevel@tonic-gate     sasl_global_callbacks_t	client_global_callbacks;
369*7c478bd9Sstevel@tonic-gate 				/* callbacks for sasl_client_init */
370*7c478bd9Sstevel@tonic-gate     int				sasl_client_active;
371*7c478bd9Sstevel@tonic-gate 				/* sasl client init'ed */
372*7c478bd9Sstevel@tonic-gate     int				(*sasl_client_cleanup_hook)
373*7c478bd9Sstevel@tonic-gate 					(struct _sasl_global_context_s *gctx);
374*7c478bd9Sstevel@tonic-gate 				/* entry point to clean up sasl client */
375*7c478bd9Sstevel@tonic-gate     int				(*sasl_client_idle_hook)(sasl_conn_t *conn);
376*7c478bd9Sstevel@tonic-gate 				/* entry point for sasl client idle */
377*7c478bd9Sstevel@tonic-gate 
378*7c478bd9Sstevel@tonic-gate     const sasl_utils_t		*sasl_server_global_utils;
379*7c478bd9Sstevel@tonic-gate 				/* sasl server global utils */
380*7c478bd9Sstevel@tonic-gate     const sasl_utils_t		*sasl_canonusr_global_utils;
381*7c478bd9Sstevel@tonic-gate 				/* sasl global utils for canonusr plugin */
382*7c478bd9Sstevel@tonic-gate 
383*7c478bd9Sstevel@tonic-gate     void			*configlist;
384*7c478bd9Sstevel@tonic-gate 				/* Configuration key value pair data list */
385*7c478bd9Sstevel@tonic-gate     int				nconfiglist;
386*7c478bd9Sstevel@tonic-gate 				/* number of items in configlist */
387*7c478bd9Sstevel@tonic-gate     char			*config_path;
388*7c478bd9Sstevel@tonic-gate 				/* last read config path */
389*7c478bd9Sstevel@tonic-gate     time_t			config_last_read;
390*7c478bd9Sstevel@tonic-gate 				/* last time config read */
391*7c478bd9Sstevel@tonic-gate 
392*7c478bd9Sstevel@tonic-gate     void			*auxprop_head;
393*7c478bd9Sstevel@tonic-gate 				/* Head of auxprop plugin list */
394*7c478bd9Sstevel@tonic-gate     void			*canonuser_head;
395*7c478bd9Sstevel@tonic-gate 				/* Head of canonusr plugin list */
396*7c478bd9Sstevel@tonic-gate     char			**global_mech_list;
397*7c478bd9Sstevel@tonic-gate 				/* Global list of mechanisms */
398*7c478bd9Sstevel@tonic-gate     void			*free_mutex;
399*7c478bd9Sstevel@tonic-gate 				/* sasl_done()/sasl_dispose() mutex */
400*7c478bd9Sstevel@tonic-gate     sasl_allocation_utils_t     sasl_allocation_utils;
401*7c478bd9Sstevel@tonic-gate 				/* malloc et al */
402*7c478bd9Sstevel@tonic-gate     sasl_mutex_utils_t		sasl_mutex_utils;
403*7c478bd9Sstevel@tonic-gate 				/* mutex_alloc et al */
404*7c478bd9Sstevel@tonic-gate     void			*lib_list_head;
405*7c478bd9Sstevel@tonic-gate 				/* list of dynamic libs opened */
406*7c478bd9Sstevel@tonic-gate }_sasl_global_context_t;
407*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
408*7c478bd9Sstevel@tonic-gate 
409*7c478bd9Sstevel@tonic-gate typedef int sasl_plaintext_verifier(sasl_conn_t *conn,
410*7c478bd9Sstevel@tonic-gate 				    const char *userid,
411*7c478bd9Sstevel@tonic-gate 				    const char *passwd,
412*7c478bd9Sstevel@tonic-gate 				    const char *service,
413*7c478bd9Sstevel@tonic-gate 				    const char *user_realm);
414*7c478bd9Sstevel@tonic-gate 
415*7c478bd9Sstevel@tonic-gate struct sasl_verify_password_s {
416*7c478bd9Sstevel@tonic-gate     char *name;
417*7c478bd9Sstevel@tonic-gate     sasl_plaintext_verifier *verify;
418*7c478bd9Sstevel@tonic-gate };
419*7c478bd9Sstevel@tonic-gate 
420*7c478bd9Sstevel@tonic-gate /*
421*7c478bd9Sstevel@tonic-gate  * globals & constants
422*7c478bd9Sstevel@tonic-gate  */
423*7c478bd9Sstevel@tonic-gate /*
424*7c478bd9Sstevel@tonic-gate  * common.c
425*7c478bd9Sstevel@tonic-gate  */
426*7c478bd9Sstevel@tonic-gate #ifndef _SUN_SDK_
427*7c478bd9Sstevel@tonic-gate LIBSASL_API const sasl_utils_t *sasl_global_utils;
428*7c478bd9Sstevel@tonic-gate 
429*7c478bd9Sstevel@tonic-gate extern int (*_sasl_client_idle_hook)(sasl_conn_t *conn);
430*7c478bd9Sstevel@tonic-gate extern int (*_sasl_server_idle_hook)(sasl_conn_t *conn);
431*7c478bd9Sstevel@tonic-gate 
432*7c478bd9Sstevel@tonic-gate /* These return SASL_OK if we've actually finished cleanup,
433*7c478bd9Sstevel@tonic-gate  * SASL_NOTINIT if that part of the library isn't inited, and
434*7c478bd9Sstevel@tonic-gate  * SASL_CONTINUE if we need to call them again */
435*7c478bd9Sstevel@tonic-gate extern int (*_sasl_client_cleanup_hook)(void);
436*7c478bd9Sstevel@tonic-gate extern int (*_sasl_server_cleanup_hook)(void);
437*7c478bd9Sstevel@tonic-gate 
438*7c478bd9Sstevel@tonic-gate extern sasl_allocation_utils_t _sasl_allocation_utils;
439*7c478bd9Sstevel@tonic-gate extern sasl_mutex_utils_t _sasl_mutex_utils;
440*7c478bd9Sstevel@tonic-gate #endif /* !_SUN_SDK_ */
441*7c478bd9Sstevel@tonic-gate 
442*7c478bd9Sstevel@tonic-gate /*
443*7c478bd9Sstevel@tonic-gate  * checkpw.c
444*7c478bd9Sstevel@tonic-gate  */
445*7c478bd9Sstevel@tonic-gate extern struct sasl_verify_password_s _sasl_verify_password[];
446*7c478bd9Sstevel@tonic-gate 
447*7c478bd9Sstevel@tonic-gate /*
448*7c478bd9Sstevel@tonic-gate  * server.c
449*7c478bd9Sstevel@tonic-gate  */
450*7c478bd9Sstevel@tonic-gate /* (this is a function call to ensure this is read-only to the outside) */
451*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
452*7c478bd9Sstevel@tonic-gate extern int _is_sasl_server_active(_sasl_global_context_t *gctx);
453*7c478bd9Sstevel@tonic-gate #else
454*7c478bd9Sstevel@tonic-gate extern int _is_sasl_server_active(void);
455*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
456*7c478bd9Sstevel@tonic-gate 
457*7c478bd9Sstevel@tonic-gate /*
458*7c478bd9Sstevel@tonic-gate  * Allocation and Mutex utility macros
459*7c478bd9Sstevel@tonic-gate  */
460*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
461*7c478bd9Sstevel@tonic-gate #define sasl_ALLOC(__size__) (gctx->sasl_allocation_utils.malloc((__size__)))
462*7c478bd9Sstevel@tonic-gate #define sasl_CALLOC(__nelem__, __size__) \
463*7c478bd9Sstevel@tonic-gate         (gctx->sasl_allocation_utils.calloc((__nelem__), (__size__)))
464*7c478bd9Sstevel@tonic-gate #define sasl_REALLOC(__ptr__, __size__) \
465*7c478bd9Sstevel@tonic-gate         (gctx->sasl_allocation_utils.realloc((__ptr__), (__size__)))
466*7c478bd9Sstevel@tonic-gate #define sasl_FREE(__ptr__) (gctx->sasl_allocation_utils.free((__ptr__)))
467*7c478bd9Sstevel@tonic-gate #define sasl_sun_ALLOC(__size__) (malloc((__size__)))
468*7c478bd9Sstevel@tonic-gate #define sasl_sun_CALLOC(__nelem__, __size__) (calloc((__nelem__), (__size__)))
469*7c478bd9Sstevel@tonic-gate #define sasl_sun_REALLOC(__ptr__, __size__) (realloc((__ptr__), (__size__)))
470*7c478bd9Sstevel@tonic-gate #define sasl_sun_FREE(__ptr__) (free((__ptr__)))
471*7c478bd9Sstevel@tonic-gate 
472*7c478bd9Sstevel@tonic-gate #define sasl_MUTEX_ALLOC() (gctx->sasl_mutex_utils.alloc())
473*7c478bd9Sstevel@tonic-gate #define sasl_MUTEX_LOCK(__mutex__) (gctx->sasl_mutex_utils.lock((__mutex__)))
474*7c478bd9Sstevel@tonic-gate #define sasl_MUTEX_UNLOCK(__mutex__) \
475*7c478bd9Sstevel@tonic-gate 	(gctx->sasl_mutex_utils.unlock((__mutex__)))
476*7c478bd9Sstevel@tonic-gate #define sasl_MUTEX_FREE(__mutex__) (gctx->sasl_mutex_utils.free((__mutex__)))
477*7c478bd9Sstevel@tonic-gate #else
478*7c478bd9Sstevel@tonic-gate #define sasl_ALLOC(__size__) (_sasl_allocation_utils.malloc((__size__)))
479*7c478bd9Sstevel@tonic-gate #define sasl_CALLOC(__nelem__, __size__) \
480*7c478bd9Sstevel@tonic-gate 	(_sasl_allocation_utils.calloc((__nelem__), (__size__)))
481*7c478bd9Sstevel@tonic-gate #define sasl_REALLOC(__ptr__, __size__) \
482*7c478bd9Sstevel@tonic-gate 	(_sasl_allocation_utils.realloc((__ptr__), (__size__)))
483*7c478bd9Sstevel@tonic-gate #define sasl_FREE(__ptr__) (_sasl_allocation_utils.free((__ptr__)))
484*7c478bd9Sstevel@tonic-gate 
485*7c478bd9Sstevel@tonic-gate #define sasl_MUTEX_ALLOC() (_sasl_mutex_utils.alloc())
486*7c478bd9Sstevel@tonic-gate #define sasl_MUTEX_LOCK(__mutex__) (_sasl_mutex_utils.lock((__mutex__)))
487*7c478bd9Sstevel@tonic-gate #define sasl_MUTEX_UNLOCK(__mutex__) (_sasl_mutex_utils.unlock((__mutex__)))
488*7c478bd9Sstevel@tonic-gate #define sasl_MUTEX_FREE(__mutex__) \
489*7c478bd9Sstevel@tonic-gate 	(_sasl_mutex_utils.free((__mutex__)))
490*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
491*7c478bd9Sstevel@tonic-gate 
492*7c478bd9Sstevel@tonic-gate /* function prototypes */
493*7c478bd9Sstevel@tonic-gate /*
494*7c478bd9Sstevel@tonic-gate  * dlopen.c and staticopen.c
495*7c478bd9Sstevel@tonic-gate  */
496*7c478bd9Sstevel@tonic-gate /*
497*7c478bd9Sstevel@tonic-gate  * The differences here are:
498*7c478bd9Sstevel@tonic-gate  * _sasl_load_plugins loads all plugins from all files
499*7c478bd9Sstevel@tonic-gate  * _sasl_get_plugin loads the LIBRARY for an individual file
500*7c478bd9Sstevel@tonic-gate  * _sasl_done_with_plugins frees the LIBRARIES loaded by the above 2
501*7c478bd9Sstevel@tonic-gate  * _sasl_locate_entry locates an entrypoint in a given library
502*7c478bd9Sstevel@tonic-gate  */
503*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
504*7c478bd9Sstevel@tonic-gate extern int _sasl_load_plugins(_sasl_global_context_t *gctx,
505*7c478bd9Sstevel@tonic-gate 			      int server,
506*7c478bd9Sstevel@tonic-gate                               const add_plugin_list_t *entrypoints,
507*7c478bd9Sstevel@tonic-gate                               const sasl_callback_t *getpath_callback,
508*7c478bd9Sstevel@tonic-gate                               const sasl_callback_t *verifyfile_callback);
509*7c478bd9Sstevel@tonic-gate 
510*7c478bd9Sstevel@tonic-gate extern int _sasl_get_plugin(_sasl_global_context_t *gctx,
511*7c478bd9Sstevel@tonic-gate                             const char *file,
512*7c478bd9Sstevel@tonic-gate                             const sasl_callback_t *verifyfile_cb,
513*7c478bd9Sstevel@tonic-gate                             void **libraryptr);
514*7c478bd9Sstevel@tonic-gate extern int _sasl_locate_entry(void *library, const char *entryname,
515*7c478bd9Sstevel@tonic-gate                               void **entry_point);
516*7c478bd9Sstevel@tonic-gate extern int _sasl_done_with_plugins(_sasl_global_context_t *gctx);
517*7c478bd9Sstevel@tonic-gate #else
518*7c478bd9Sstevel@tonic-gate extern int _sasl_load_plugins(const add_plugin_list_t *entrypoints,
519*7c478bd9Sstevel@tonic-gate 			       const sasl_callback_t *getpath_callback,
520*7c478bd9Sstevel@tonic-gate 			       const sasl_callback_t *verifyfile_callback);
521*7c478bd9Sstevel@tonic-gate extern int _sasl_get_plugin(const char *file,
522*7c478bd9Sstevel@tonic-gate 			    const sasl_callback_t *verifyfile_cb,
523*7c478bd9Sstevel@tonic-gate 			    void **libraryptr);
524*7c478bd9Sstevel@tonic-gate extern int _sasl_locate_entry(void *library, const char *entryname,
525*7c478bd9Sstevel@tonic-gate                               void **entry_point);
526*7c478bd9Sstevel@tonic-gate extern int _sasl_done_with_plugins();
527*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
528*7c478bd9Sstevel@tonic-gate 
529*7c478bd9Sstevel@tonic-gate 
530*7c478bd9Sstevel@tonic-gate /*
531*7c478bd9Sstevel@tonic-gate  * common.c
532*7c478bd9Sstevel@tonic-gate  */
533*7c478bd9Sstevel@tonic-gate extern const sasl_callback_t *
534*7c478bd9Sstevel@tonic-gate _sasl_find_getpath_callback(const sasl_callback_t *callbacks);
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate extern const sasl_callback_t *
537*7c478bd9Sstevel@tonic-gate _sasl_find_verifyfile_callback(const sasl_callback_t *callbacks);
538*7c478bd9Sstevel@tonic-gate 
539*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
540*7c478bd9Sstevel@tonic-gate extern const sasl_callback_t *
541*7c478bd9Sstevel@tonic-gate _sasl_find_getconf_callback(const sasl_callback_t *callbacks);
542*7c478bd9Sstevel@tonic-gate 
543*7c478bd9Sstevel@tonic-gate extern int _sasl_common_init(_sasl_global_context_t *gctx,
544*7c478bd9Sstevel@tonic-gate 			     sasl_global_callbacks_t *global_callbacks,
545*7c478bd9Sstevel@tonic-gate 			     int server);
546*7c478bd9Sstevel@tonic-gate #else
547*7c478bd9Sstevel@tonic-gate extern int _sasl_common_init(sasl_global_callbacks_t *global_callbacks);
548*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
549*7c478bd9Sstevel@tonic-gate 
550*7c478bd9Sstevel@tonic-gate extern int _sasl_conn_init(sasl_conn_t *conn,
551*7c478bd9Sstevel@tonic-gate 			   const char *service,
552*7c478bd9Sstevel@tonic-gate 			   unsigned int flags,
553*7c478bd9Sstevel@tonic-gate 			   enum Sasl_conn_type type,
554*7c478bd9Sstevel@tonic-gate 			   int (*idle_hook)(sasl_conn_t *conn),
555*7c478bd9Sstevel@tonic-gate 			   const char *serverFQDN,
556*7c478bd9Sstevel@tonic-gate 			   const char *iplocalport,
557*7c478bd9Sstevel@tonic-gate 			   const char *ipremoteport,
558*7c478bd9Sstevel@tonic-gate 			   const sasl_callback_t *callbacks,
559*7c478bd9Sstevel@tonic-gate 			   const sasl_global_callbacks_t *global_callbacks);
560*7c478bd9Sstevel@tonic-gate extern void _sasl_conn_dispose(sasl_conn_t *conn);
561*7c478bd9Sstevel@tonic-gate 
562*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
563*7c478bd9Sstevel@tonic-gate extern sasl_utils_t *
564*7c478bd9Sstevel@tonic-gate _sasl_alloc_utils(_sasl_global_context_t *gctx, sasl_conn_t *conn,
565*7c478bd9Sstevel@tonic-gate 		  sasl_global_callbacks_t *global_callbacks);
566*7c478bd9Sstevel@tonic-gate #else
567*7c478bd9Sstevel@tonic-gate extern sasl_utils_t *
568*7c478bd9Sstevel@tonic-gate _sasl_alloc_utils(sasl_conn_t *conn,
569*7c478bd9Sstevel@tonic-gate 		  sasl_global_callbacks_t *global_callbacks);
570*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
571*7c478bd9Sstevel@tonic-gate extern int _sasl_free_utils(const sasl_utils_t ** utils);
572*7c478bd9Sstevel@tonic-gate 
573*7c478bd9Sstevel@tonic-gate extern int
574*7c478bd9Sstevel@tonic-gate _sasl_getcallback(sasl_conn_t * conn,
575*7c478bd9Sstevel@tonic-gate 		  unsigned long callbackid,
576*7c478bd9Sstevel@tonic-gate 		  int (**pproc)(),
577*7c478bd9Sstevel@tonic-gate 		  void **pcontext);
578*7c478bd9Sstevel@tonic-gate 
579*7c478bd9Sstevel@tonic-gate extern void
580*7c478bd9Sstevel@tonic-gate _sasl_log(sasl_conn_t *conn,
581*7c478bd9Sstevel@tonic-gate 	  int level,
582*7c478bd9Sstevel@tonic-gate 	  const char *fmt,
583*7c478bd9Sstevel@tonic-gate 	  ...);
584*7c478bd9Sstevel@tonic-gate 
585*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
586*7c478bd9Sstevel@tonic-gate extern void
587*7c478bd9Sstevel@tonic-gate __sasl_log(const _sasl_global_context_t *gctx,
588*7c478bd9Sstevel@tonic-gate 	   const sasl_callback_t *callbacks,
589*7c478bd9Sstevel@tonic-gate 	   int level,
590*7c478bd9Sstevel@tonic-gate 	   const char *fmt,
591*7c478bd9Sstevel@tonic-gate 	   ...);
592*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
593*7c478bd9Sstevel@tonic-gate void _sasl_get_errorbuf(sasl_conn_t *conn, char ***bufhdl, size_t **lenhdl);
594*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
595*7c478bd9Sstevel@tonic-gate int __sasl_add_string(const _sasl_global_context_t *gctx, char **out,
596*7c478bd9Sstevel@tonic-gate                       size_t *alloclen,
597*7c478bd9Sstevel@tonic-gate                       size_t *outlen, const char *add);
598*7c478bd9Sstevel@tonic-gate 
599*7c478bd9Sstevel@tonic-gate #define _sasl_add_string(out, alloclen, outlen, add) \
600*7c478bd9Sstevel@tonic-gate 	__sasl_add_string(gctx, out, alloclen, outlen, add)
601*7c478bd9Sstevel@tonic-gate 
602*7c478bd9Sstevel@tonic-gate /* More Generic Utilities in common.c */
603*7c478bd9Sstevel@tonic-gate #define _sasl_strdup(in, out, outlen) \
604*7c478bd9Sstevel@tonic-gate 	__sasl_strdup(gctx, in, out, outlen)
605*7c478bd9Sstevel@tonic-gate extern int __sasl_strdup(const _sasl_global_context_t *gctx, const char *in,
606*7c478bd9Sstevel@tonic-gate                         char **out, size_t *outlen);
607*7c478bd9Sstevel@tonic-gate 
608*7c478bd9Sstevel@tonic-gate /* Basically a conditional call to realloc(), if we need more */
609*7c478bd9Sstevel@tonic-gate int __buf_alloc(const _sasl_global_context_t *gctx, char **rwbuf,
610*7c478bd9Sstevel@tonic-gate 	size_t *curlen, size_t newlen);
611*7c478bd9Sstevel@tonic-gate #define _buf_alloc(rwbuf, curlen, newlen) \
612*7c478bd9Sstevel@tonic-gate 	__buf_alloc(gctx, rwbuf, curlen, newlen)
613*7c478bd9Sstevel@tonic-gate #else
614*7c478bd9Sstevel@tonic-gate int _sasl_add_string(char **out, size_t *alloclen,
615*7c478bd9Sstevel@tonic-gate 		     size_t *outlen, const char *add);
616*7c478bd9Sstevel@tonic-gate 
617*7c478bd9Sstevel@tonic-gate /* More Generic Utilities in common.c */
618*7c478bd9Sstevel@tonic-gate extern int _sasl_strdup(const char *in, char **out, size_t *outlen);
619*7c478bd9Sstevel@tonic-gate 
620*7c478bd9Sstevel@tonic-gate /* Basically a conditional call to realloc(), if we need more */
621*7c478bd9Sstevel@tonic-gate int _buf_alloc(char **rwbuf, size_t *curlen, size_t newlen);
622*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
623*7c478bd9Sstevel@tonic-gate 
624*7c478bd9Sstevel@tonic-gate /* convert an iovec to a single buffer */
625*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
626*7c478bd9Sstevel@tonic-gate int _iovec_to_buf(const _sasl_global_context_t *gctx, const struct iovec *vec,
627*7c478bd9Sstevel@tonic-gate                   unsigned numiov, buffer_info_t **output);
628*7c478bd9Sstevel@tonic-gate #else
629*7c478bd9Sstevel@tonic-gate int _iovec_to_buf(const struct iovec *vec,
630*7c478bd9Sstevel@tonic-gate 		  unsigned numiov, buffer_info_t **output);
631*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
632*7c478bd9Sstevel@tonic-gate 
633*7c478bd9Sstevel@tonic-gate /* Convert between string formats and sockaddr formats */
634*7c478bd9Sstevel@tonic-gate int _sasl_iptostring(const struct sockaddr *addr, socklen_t addrlen,
635*7c478bd9Sstevel@tonic-gate 		     char *out, unsigned outlen);
636*7c478bd9Sstevel@tonic-gate int _sasl_ipfromstring(const char *addr, struct sockaddr *out,
637*7c478bd9Sstevel@tonic-gate 		       socklen_t outlen);
638*7c478bd9Sstevel@tonic-gate 
639*7c478bd9Sstevel@tonic-gate /*
640*7c478bd9Sstevel@tonic-gate  * external plugin (external.c)
641*7c478bd9Sstevel@tonic-gate  */
642*7c478bd9Sstevel@tonic-gate int external_client_plug_init(const sasl_utils_t *utils,
643*7c478bd9Sstevel@tonic-gate 			      int max_version,
644*7c478bd9Sstevel@tonic-gate 			      int *out_version,
645*7c478bd9Sstevel@tonic-gate 			      sasl_client_plug_t **pluglist,
646*7c478bd9Sstevel@tonic-gate 			      int *plugcount);
647*7c478bd9Sstevel@tonic-gate int external_server_plug_init(const sasl_utils_t *utils,
648*7c478bd9Sstevel@tonic-gate 			      int max_version,
649*7c478bd9Sstevel@tonic-gate 			      int *out_version,
650*7c478bd9Sstevel@tonic-gate 			      sasl_server_plug_t **pluglist,
651*7c478bd9Sstevel@tonic-gate 			      int *plugcount);
652*7c478bd9Sstevel@tonic-gate 
653*7c478bd9Sstevel@tonic-gate /* Mech Listing Functions */
654*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
655*7c478bd9Sstevel@tonic-gate int _sasl_build_mechlist(_sasl_global_context_t *gctx);
656*7c478bd9Sstevel@tonic-gate #else
657*7c478bd9Sstevel@tonic-gate int _sasl_build_mechlist(void);
658*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
659*7c478bd9Sstevel@tonic-gate 
660*7c478bd9Sstevel@tonic-gate int _sasl_server_listmech(sasl_conn_t *conn,
661*7c478bd9Sstevel@tonic-gate 			  const char *user,
662*7c478bd9Sstevel@tonic-gate 			  const char *prefix,
663*7c478bd9Sstevel@tonic-gate 			  const char *sep,
664*7c478bd9Sstevel@tonic-gate 			  const char *suffix,
665*7c478bd9Sstevel@tonic-gate 			  const char **result,
666*7c478bd9Sstevel@tonic-gate 			  unsigned *plen,
667*7c478bd9Sstevel@tonic-gate 			  int *pcount);
668*7c478bd9Sstevel@tonic-gate int _sasl_client_listmech(sasl_conn_t *conn,
669*7c478bd9Sstevel@tonic-gate 			  const char *prefix,
670*7c478bd9Sstevel@tonic-gate 			  const char *sep,
671*7c478bd9Sstevel@tonic-gate 			  const char *suffix,
672*7c478bd9Sstevel@tonic-gate 			  const char **result,
673*7c478bd9Sstevel@tonic-gate 			  unsigned *plen,
674*7c478bd9Sstevel@tonic-gate 			  int *pcount);
675*7c478bd9Sstevel@tonic-gate /* Just create a straight list of them */
676*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
677*7c478bd9Sstevel@tonic-gate sasl_string_list_t *_sasl_client_mechs(_sasl_global_context_t *gctx);
678*7c478bd9Sstevel@tonic-gate sasl_string_list_t *_sasl_server_mechs(_sasl_global_context_t *gctx);
679*7c478bd9Sstevel@tonic-gate #else
680*7c478bd9Sstevel@tonic-gate sasl_string_list_t *_sasl_client_mechs(void);
681*7c478bd9Sstevel@tonic-gate sasl_string_list_t *_sasl_server_mechs(void);
682*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
683*7c478bd9Sstevel@tonic-gate 
684*7c478bd9Sstevel@tonic-gate /*
685*7c478bd9Sstevel@tonic-gate  * config file declarations (config.c)
686*7c478bd9Sstevel@tonic-gate  */
687*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
688*7c478bd9Sstevel@tonic-gate extern int sasl_config_init(_sasl_global_context_t *gctx,
689*7c478bd9Sstevel@tonic-gate         const char *filename);
690*7c478bd9Sstevel@tonic-gate extern void sasl_config_free(_sasl_global_context_t *gctx);
691*7c478bd9Sstevel@tonic-gate extern const char *sasl_config_getstring(_sasl_global_context_t *gctx,
692*7c478bd9Sstevel@tonic-gate         const char *key,const char *def);
693*7c478bd9Sstevel@tonic-gate extern int sasl_config_getint(_sasl_global_context_t *gctx,
694*7c478bd9Sstevel@tonic-gate         const char *key,int def);
695*7c478bd9Sstevel@tonic-gate extern int sasl_config_getswitch(_sasl_global_context_t *gctx,
696*7c478bd9Sstevel@tonic-gate         const char *key,int def);
697*7c478bd9Sstevel@tonic-gate #else
698*7c478bd9Sstevel@tonic-gate extern int sasl_config_init(const char *filename);
699*7c478bd9Sstevel@tonic-gate extern const char *sasl_config_getstring(const char *key,const char *def);
700*7c478bd9Sstevel@tonic-gate extern int sasl_config_getint(const char *key,int def);
701*7c478bd9Sstevel@tonic-gate extern int sasl_config_getswitch(const char *key,int def);
702*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
703*7c478bd9Sstevel@tonic-gate 
704*7c478bd9Sstevel@tonic-gate /* checkpw.c */
705*7c478bd9Sstevel@tonic-gate #ifdef DO_SASL_CHECKAPOP
706*7c478bd9Sstevel@tonic-gate extern int _sasl_auxprop_verify_apop(sasl_conn_t *conn,
707*7c478bd9Sstevel@tonic-gate 				     const char *userstr,
708*7c478bd9Sstevel@tonic-gate 				     const char *challenge,
709*7c478bd9Sstevel@tonic-gate 				     const char *response,
710*7c478bd9Sstevel@tonic-gate 				     const char *user_realm);
711*7c478bd9Sstevel@tonic-gate #endif /* DO_SASL_CHECKAPOP */
712*7c478bd9Sstevel@tonic-gate 
713*7c478bd9Sstevel@tonic-gate /* Auxprop Plugin (checkpw.c) */
714*7c478bd9Sstevel@tonic-gate extern int sasldb_auxprop_plug_init(const sasl_utils_t *utils,
715*7c478bd9Sstevel@tonic-gate 				    int max_version,
716*7c478bd9Sstevel@tonic-gate 				    int *out_version,
717*7c478bd9Sstevel@tonic-gate 				    sasl_auxprop_plug_t **plug,
718*7c478bd9Sstevel@tonic-gate 				    const char *plugname);
719*7c478bd9Sstevel@tonic-gate 
720*7c478bd9Sstevel@tonic-gate /*
721*7c478bd9Sstevel@tonic-gate  * auxprop.c
722*7c478bd9Sstevel@tonic-gate  */
723*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
724*7c478bd9Sstevel@tonic-gate extern void _sasl_auxprop_free(_sasl_global_context_t *gctx);
725*7c478bd9Sstevel@tonic-gate #else
726*7c478bd9Sstevel@tonic-gate extern int _sasl_auxprop_add_plugin(void *p, void *library);
727*7c478bd9Sstevel@tonic-gate extern void _sasl_auxprop_free(void);
728*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
729*7c478bd9Sstevel@tonic-gate extern void _sasl_auxprop_lookup(sasl_server_params_t *sparams,
730*7c478bd9Sstevel@tonic-gate 				 unsigned flags,
731*7c478bd9Sstevel@tonic-gate 				 const char *user, unsigned ulen);
732*7c478bd9Sstevel@tonic-gate 
733*7c478bd9Sstevel@tonic-gate /*
734*7c478bd9Sstevel@tonic-gate  * canonusr.c
735*7c478bd9Sstevel@tonic-gate  */
736*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
737*7c478bd9Sstevel@tonic-gate void _sasl_canonuser_free(_sasl_global_context_t *gctx);
738*7c478bd9Sstevel@tonic-gate #else
739*7c478bd9Sstevel@tonic-gate void _sasl_canonuser_free();
740*7c478bd9Sstevel@tonic-gate #endif /* _SUN_SDK_ */
741*7c478bd9Sstevel@tonic-gate extern int internal_canonuser_init(const sasl_utils_t *utils,
742*7c478bd9Sstevel@tonic-gate 				   int max_version,
743*7c478bd9Sstevel@tonic-gate 				   int *out_version,
744*7c478bd9Sstevel@tonic-gate 				   sasl_canonuser_plug_t **plug,
745*7c478bd9Sstevel@tonic-gate 				   const char *plugname);
746*7c478bd9Sstevel@tonic-gate extern int _sasl_canon_user(sasl_conn_t *conn,
747*7c478bd9Sstevel@tonic-gate 			    const char *user, unsigned ulen,
748*7c478bd9Sstevel@tonic-gate 			    unsigned flags,
749*7c478bd9Sstevel@tonic-gate 			    sasl_out_params_t *oparams);
750*7c478bd9Sstevel@tonic-gate 
751*7c478bd9Sstevel@tonic-gate #ifdef _SUN_SDK_
752*7c478bd9Sstevel@tonic-gate /* Private functions to create, free, and use a private context */
753*7c478bd9Sstevel@tonic-gate void *sasl_create_context(void);
754*7c478bd9Sstevel@tonic-gate 
755*7c478bd9Sstevel@tonic-gate void sasl_free_context(void *context);
756*7c478bd9Sstevel@tonic-gate 
757*7c478bd9Sstevel@tonic-gate extern int _sasl_server_init(void *ctx, const sasl_callback_t *callbacks,
758*7c478bd9Sstevel@tonic-gate 		     const char *appname);
759*7c478bd9Sstevel@tonic-gate 
760*7c478bd9Sstevel@tonic-gate extern int _sasl_server_new(void *ctx, const char *service,
761*7c478bd9Sstevel@tonic-gate 			    const char *serverFQDN, const char *user_realm,
762*7c478bd9Sstevel@tonic-gate 			    const char *iplocalport, const char *ipremoteport,
763*7c478bd9Sstevel@tonic-gate 			    const sasl_callback_t *callbacks, unsigned flags,
764*7c478bd9Sstevel@tonic-gate 			    sasl_conn_t **pconn);
765*7c478bd9Sstevel@tonic-gate 
766*7c478bd9Sstevel@tonic-gate extern int _sasl_client_init(void *ctx,
767*7c478bd9Sstevel@tonic-gate 			     const sasl_callback_t *callbacks);
768*7c478bd9Sstevel@tonic-gate 
769*7c478bd9Sstevel@tonic-gate extern int _sasl_client_new(void *ctx,
770*7c478bd9Sstevel@tonic-gate 			    const char *service,
771*7c478bd9Sstevel@tonic-gate 			    const char *serverFQDN,
772*7c478bd9Sstevel@tonic-gate 			    const char *iplocalport,
773*7c478bd9Sstevel@tonic-gate 			    const char *ipremoteport,
774*7c478bd9Sstevel@tonic-gate 			    const sasl_callback_t *prompt_supp,
775*7c478bd9Sstevel@tonic-gate 			    unsigned flags,
776*7c478bd9Sstevel@tonic-gate 			    sasl_conn_t **pconn);
777*7c478bd9Sstevel@tonic-gate 
778*7c478bd9Sstevel@tonic-gate extern int _sasl_client_add_plugin(void *ctx,
779*7c478bd9Sstevel@tonic-gate                                    const char *plugname,
780*7c478bd9Sstevel@tonic-gate                                    sasl_client_plug_init_t *cplugfunc);
781*7c478bd9Sstevel@tonic-gate extern int _sasl_server_add_plugin(void *ctx,
782*7c478bd9Sstevel@tonic-gate                                    const char *plugname,
783*7c478bd9Sstevel@tonic-gate                                    sasl_server_plug_init_t *splugfunc);
784*7c478bd9Sstevel@tonic-gate extern int _sasl_canonuser_add_plugin(void *ctx,
785*7c478bd9Sstevel@tonic-gate                                       const char *plugname,
786*7c478bd9Sstevel@tonic-gate                                       sasl_canonuser_init_t *canonuserfunc);
787*7c478bd9Sstevel@tonic-gate extern int _sasl_auxprop_add_plugin(void *ctx,
788*7c478bd9Sstevel@tonic-gate                                     const char *plugname,
789*7c478bd9Sstevel@tonic-gate                                     sasl_auxprop_init_t *auxpropfunc);
790*7c478bd9Sstevel@tonic-gate 
791*7c478bd9Sstevel@tonic-gate _sasl_global_context_t *_sasl_gbl_ctx(void);
792*7c478bd9Sstevel@tonic-gate 
793*7c478bd9Sstevel@tonic-gate #ifdef _INTEGRATED_SOLARIS_
794*7c478bd9Sstevel@tonic-gate int _is_sun_reg(void *mech);
795*7c478bd9Sstevel@tonic-gate #endif /* _INTEGRATED_SOLARIS_ */
796*7c478bd9Sstevel@tonic-gate 
797*7c478bd9Sstevel@tonic-gate /* unsupported functions that are used internally */
798*7c478bd9Sstevel@tonic-gate int sasl_randcreate(sasl_rand_t **rpool);
799*7c478bd9Sstevel@tonic-gate 
800*7c478bd9Sstevel@tonic-gate void sasl_randfree(sasl_rand_t **rpool);
801*7c478bd9Sstevel@tonic-gate 
802*7c478bd9Sstevel@tonic-gate void sasl_rand(sasl_rand_t *rpool, char *buf, unsigned len);
803*7c478bd9Sstevel@tonic-gate 
804*7c478bd9Sstevel@tonic-gate void sasl_churn(sasl_rand_t *rpool, const char *data, unsigned len);
805*7c478bd9Sstevel@tonic-gate 
806*7c478bd9Sstevel@tonic-gate int sasl_mkchal(sasl_conn_t *conn, char *buf, unsigned maxlen,
807*7c478bd9Sstevel@tonic-gate 		unsigned hostflag);
808*7c478bd9Sstevel@tonic-gate #endif	/* _SUN_SDK_ */
809*7c478bd9Sstevel@tonic-gate 
810*7c478bd9Sstevel@tonic-gate #endif /* SASLINT_H */
811