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