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 #ifdef _INTEGRATED_SOLARIS_ 216 int sun_reg; 217 #endif /* _INTEGRATED_SOLARIS_ */ 218 #endif /* _SUN_SDK_ */ 219 }; 220 221 #ifdef _SUN_SDK_ 222 /* track changes in file system */ 223 typedef struct _sasl_path_info { 224 char *path; 225 time_t last_changed; 226 struct _sasl_path_info *next; 227 } _sasl_path_info_t; 228 #endif /* _SUN_SDK_ */ 229 230 /* Server Conn Type Information */ 231 232 typedef struct mechanism 233 { 234 int version; 235 int condition; /* set to SASL_NOUSER if no available users; 236 set to SASL_CONTINUE if delayed plugn loading */ 237 char *plugname; /* for AUTHSOURCE tracking */ 238 #ifdef _SUN_SDK_ 239 #ifdef _INTEGRATED_SOLARIS_ 240 int sun_reg; 241 #endif /* _INTEGRATED_SOLARIS_ */ 242 sasl_server_plug_t *plug; 243 /* 244 * The global context needs to be stored with separately from the 245 * the plugin because it will be overwritten when the plugin is 246 * relloaded 247 */ 248 void *glob_context; 249 struct mechanism *next; 250 #else 251 const sasl_server_plug_t *plug; 252 struct mechanism *next; 253 char *f; /* where should i load the mechanism from? */ 254 #endif /* _SUN_SDK_ */ 255 } mechanism_t; 256 257 typedef struct mech_list { 258 const sasl_utils_t *utils; /* gotten from plug_init */ 259 260 void *mutex; /* mutex for this data */ 261 mechanism_t *mech_list; /* list of mechanisms */ 262 int mech_length; /* number of mechanisms */ 263 } mech_list_t; 264 265 typedef struct context_list 266 { 267 mechanism_t *mech; 268 void *context; /* if NULL, this mech is disabled for this connection 269 * otherwise, use this context instead of a call 270 * to mech_new */ 271 struct context_list *next; 272 } context_list_t; 273 274 typedef struct sasl_server_conn { 275 sasl_conn_t base; /* parts common to server + client */ 276 277 char *user_realm; /* domain the user authenticating is in */ 278 int sent_last; /* Have we already done the last send? */ 279 int authenticated; 280 mechanism_t *mech; /* mechanism trying to use */ 281 sasl_server_params_t *sparams; 282 context_list_t *mech_contexts; 283 } sasl_server_conn_t; 284 285 /* Client Conn Type Information */ 286 287 typedef struct cmechanism 288 { 289 int version; 290 291 char *plugname; 292 #ifdef _SUN_SDK_ 293 #ifdef _INTEGRATED_SOLARIS_ 294 int sun_reg; 295 #endif /* _INTEGRATED_SOLARIS_ */ 296 /* 297 * The global context needs to be stored with separately from the 298 * the plugin because it will be overwritten when the plugin is 299 * relloaded 300 */ 301 void *glob_context; 302 sasl_client_plug_t *plug; 303 #else 304 const sasl_client_plug_t *plug; 305 #endif /* _SUN_SDK_ */ 306 307 struct cmechanism *next; 308 } cmechanism_t; 309 310 typedef struct cmech_list { 311 const sasl_utils_t *utils; 312 313 void *mutex; /* mutex for this data */ 314 cmechanism_t *mech_list; /* list of mechanisms */ 315 int mech_length; /* number of mechanisms */ 316 317 } cmech_list_t; 318 319 typedef struct sasl_client_conn { 320 sasl_conn_t base; /* parts common to server + client */ 321 322 cmechanism_t *mech; 323 sasl_client_params_t *cparams; 324 325 char *clientFQDN; 326 327 } sasl_client_conn_t; 328 329 typedef struct sasl_allocation_utils { 330 sasl_malloc_t *malloc; 331 sasl_calloc_t *calloc; 332 sasl_realloc_t *realloc; 333 sasl_free_t *free; 334 } sasl_allocation_utils_t; 335 336 typedef struct sasl_mutex_utils { 337 sasl_mutex_alloc_t *alloc; 338 sasl_mutex_lock_t *lock; 339 sasl_mutex_unlock_t *unlock; 340 sasl_mutex_free_t *free; 341 } sasl_mutex_utils_t; 342 343 typedef struct sasl_log_utils_s { 344 sasl_log_t *log; 345 } sasl_log_utils_t; 346 347 #ifdef _SUN_SDK_ 348 /* 349 * The following structure contains the global state for libsasl */ 350 typedef struct _sasl_global_context_s { 351 int sasl_server_active; 352 /* sasl server init'ed */ 353 mech_list_t *mechlist; 354 /* list of server mechs */ 355 _sasl_path_info_t *splug_path_info; 356 /* path info for server plugins */ 357 sasl_global_callbacks_t server_global_callbacks; 358 /* callbacks for sasl_server_init */ 359 int (*sasl_server_cleanup_hook) 360 (struct _sasl_global_context_s *gctx); 361 /* entry point to clean up sasl server */ 362 int (*sasl_server_idle_hook)(sasl_conn_t *conn); 363 /* entry point for sasl server idle */ 364 365 cmech_list_t *cmechlist; 366 /* list of client mechs */ 367 _sasl_path_info_t *cplug_path_info; 368 /* path info for client plugins */ 369 sasl_global_callbacks_t client_global_callbacks; 370 /* callbacks for sasl_client_init */ 371 int sasl_client_active; 372 /* sasl client init'ed */ 373 int (*sasl_client_cleanup_hook) 374 (struct _sasl_global_context_s *gctx); 375 /* entry point to clean up sasl client */ 376 int (*sasl_client_idle_hook)(sasl_conn_t *conn); 377 /* entry point for sasl client idle */ 378 379 const sasl_utils_t *sasl_server_global_utils; 380 /* sasl server global utils */ 381 const sasl_utils_t *sasl_canonusr_global_utils; 382 /* sasl global utils for canonusr plugin */ 383 384 void *configlist; 385 /* Configuration key value pair data list */ 386 int nconfiglist; 387 /* number of items in configlist */ 388 char *config_path; 389 /* last read config path */ 390 time_t config_last_read; 391 /* last time config read */ 392 393 void *auxprop_head; 394 /* Head of auxprop plugin list */ 395 void *canonuser_head; 396 /* Head of canonusr plugin list */ 397 char **global_mech_list; 398 /* Global list of mechanisms */ 399 void *free_mutex; 400 /* sasl_done()/sasl_dispose() mutex */ 401 sasl_allocation_utils_t sasl_allocation_utils; 402 /* malloc et al */ 403 sasl_mutex_utils_t sasl_mutex_utils; 404 /* mutex_alloc et al */ 405 void *lib_list_head; 406 /* list of dynamic libs opened */ 407 }_sasl_global_context_t; 408 #endif /* _SUN_SDK_ */ 409 410 typedef int sasl_plaintext_verifier(sasl_conn_t *conn, 411 const char *userid, 412 const char *passwd, 413 const char *service, 414 const char *user_realm); 415 416 struct sasl_verify_password_s { 417 char *name; 418 sasl_plaintext_verifier *verify; 419 }; 420 421 /* 422 * globals & constants 423 */ 424 /* 425 * common.c 426 */ 427 #ifndef _SUN_SDK_ 428 LIBSASL_API const sasl_utils_t *sasl_global_utils; 429 430 extern int (*_sasl_client_idle_hook)(sasl_conn_t *conn); 431 extern int (*_sasl_server_idle_hook)(sasl_conn_t *conn); 432 433 /* These return SASL_OK if we've actually finished cleanup, 434 * SASL_NOTINIT if that part of the library isn't inited, and 435 * SASL_CONTINUE if we need to call them again */ 436 extern int (*_sasl_client_cleanup_hook)(void); 437 extern int (*_sasl_server_cleanup_hook)(void); 438 439 extern sasl_allocation_utils_t _sasl_allocation_utils; 440 extern sasl_mutex_utils_t _sasl_mutex_utils; 441 #endif /* !_SUN_SDK_ */ 442 443 /* 444 * checkpw.c 445 */ 446 extern struct sasl_verify_password_s _sasl_verify_password[]; 447 448 /* 449 * server.c 450 */ 451 /* (this is a function call to ensure this is read-only to the outside) */ 452 #ifdef _SUN_SDK_ 453 extern int _is_sasl_server_active(_sasl_global_context_t *gctx); 454 #else 455 extern int _is_sasl_server_active(void); 456 #endif /* _SUN_SDK_ */ 457 458 /* 459 * Allocation and Mutex utility macros 460 */ 461 #ifdef _SUN_SDK_ 462 #define sasl_ALLOC(__size__) (gctx->sasl_allocation_utils.malloc((__size__))) 463 #define sasl_CALLOC(__nelem__, __size__) \ 464 (gctx->sasl_allocation_utils.calloc((__nelem__), (__size__))) 465 #define sasl_REALLOC(__ptr__, __size__) \ 466 (gctx->sasl_allocation_utils.realloc((__ptr__), (__size__))) 467 #define sasl_FREE(__ptr__) (gctx->sasl_allocation_utils.free((__ptr__))) 468 #define sasl_sun_ALLOC(__size__) (malloc((__size__))) 469 #define sasl_sun_CALLOC(__nelem__, __size__) (calloc((__nelem__), (__size__))) 470 #define sasl_sun_REALLOC(__ptr__, __size__) (realloc((__ptr__), (__size__))) 471 #define sasl_sun_FREE(__ptr__) (free((__ptr__))) 472 473 #define sasl_MUTEX_ALLOC() (gctx->sasl_mutex_utils.alloc()) 474 #define sasl_MUTEX_LOCK(__mutex__) (gctx->sasl_mutex_utils.lock((__mutex__))) 475 #define sasl_MUTEX_UNLOCK(__mutex__) \ 476 (gctx->sasl_mutex_utils.unlock((__mutex__))) 477 #define sasl_MUTEX_FREE(__mutex__) (gctx->sasl_mutex_utils.free((__mutex__))) 478 #else 479 #define sasl_ALLOC(__size__) (_sasl_allocation_utils.malloc((__size__))) 480 #define sasl_CALLOC(__nelem__, __size__) \ 481 (_sasl_allocation_utils.calloc((__nelem__), (__size__))) 482 #define sasl_REALLOC(__ptr__, __size__) \ 483 (_sasl_allocation_utils.realloc((__ptr__), (__size__))) 484 #define sasl_FREE(__ptr__) (_sasl_allocation_utils.free((__ptr__))) 485 486 #define sasl_MUTEX_ALLOC() (_sasl_mutex_utils.alloc()) 487 #define sasl_MUTEX_LOCK(__mutex__) (_sasl_mutex_utils.lock((__mutex__))) 488 #define sasl_MUTEX_UNLOCK(__mutex__) (_sasl_mutex_utils.unlock((__mutex__))) 489 #define sasl_MUTEX_FREE(__mutex__) \ 490 (_sasl_mutex_utils.free((__mutex__))) 491 #endif /* _SUN_SDK_ */ 492 493 /* function prototypes */ 494 /* 495 * dlopen.c and staticopen.c 496 */ 497 /* 498 * The differences here are: 499 * _sasl_load_plugins loads all plugins from all files 500 * _sasl_get_plugin loads the LIBRARY for an individual file 501 * _sasl_done_with_plugins frees the LIBRARIES loaded by the above 2 502 * _sasl_locate_entry locates an entrypoint in a given library 503 */ 504 #ifdef _SUN_SDK_ 505 extern int _sasl_load_plugins(_sasl_global_context_t *gctx, 506 int server, 507 const add_plugin_list_t *entrypoints, 508 const sasl_callback_t *getpath_callback, 509 const sasl_callback_t *verifyfile_callback); 510 511 extern int _sasl_get_plugin(_sasl_global_context_t *gctx, 512 const char *file, 513 const sasl_callback_t *verifyfile_cb, 514 void **libraryptr); 515 extern int _sasl_locate_entry(void *library, const char *entryname, 516 void **entry_point); 517 extern int _sasl_done_with_plugins(_sasl_global_context_t *gctx); 518 #else 519 extern int _sasl_load_plugins(const add_plugin_list_t *entrypoints, 520 const sasl_callback_t *getpath_callback, 521 const sasl_callback_t *verifyfile_callback); 522 extern int _sasl_get_plugin(const char *file, 523 const sasl_callback_t *verifyfile_cb, 524 void **libraryptr); 525 extern int _sasl_locate_entry(void *library, const char *entryname, 526 void **entry_point); 527 extern int _sasl_done_with_plugins(); 528 #endif /* _SUN_SDK_ */ 529 530 531 /* 532 * common.c 533 */ 534 extern const sasl_callback_t * 535 _sasl_find_getpath_callback(const sasl_callback_t *callbacks); 536 537 extern const sasl_callback_t * 538 _sasl_find_verifyfile_callback(const sasl_callback_t *callbacks); 539 540 #ifdef _SUN_SDK_ 541 extern const sasl_callback_t * 542 _sasl_find_getconf_callback(const sasl_callback_t *callbacks); 543 544 extern int _sasl_common_init(_sasl_global_context_t *gctx, 545 sasl_global_callbacks_t *global_callbacks, 546 int server); 547 #else 548 extern int _sasl_common_init(sasl_global_callbacks_t *global_callbacks); 549 #endif /* _SUN_SDK_ */ 550 551 extern int _sasl_conn_init(sasl_conn_t *conn, 552 const char *service, 553 unsigned int flags, 554 enum Sasl_conn_type type, 555 int (*idle_hook)(sasl_conn_t *conn), 556 const char *serverFQDN, 557 const char *iplocalport, 558 const char *ipremoteport, 559 const sasl_callback_t *callbacks, 560 const sasl_global_callbacks_t *global_callbacks); 561 extern void _sasl_conn_dispose(sasl_conn_t *conn); 562 563 #ifdef _SUN_SDK_ 564 extern sasl_utils_t * 565 _sasl_alloc_utils(_sasl_global_context_t *gctx, sasl_conn_t *conn, 566 sasl_global_callbacks_t *global_callbacks); 567 #else 568 extern sasl_utils_t * 569 _sasl_alloc_utils(sasl_conn_t *conn, 570 sasl_global_callbacks_t *global_callbacks); 571 #endif /* _SUN_SDK_ */ 572 extern int _sasl_free_utils(const sasl_utils_t ** utils); 573 574 extern int 575 _sasl_getcallback(sasl_conn_t * conn, 576 unsigned long callbackid, 577 int (**pproc)(), 578 void **pcontext); 579 580 extern void 581 _sasl_log(sasl_conn_t *conn, 582 int level, 583 const char *fmt, 584 ...); 585 586 #ifdef _SUN_SDK_ 587 extern void 588 __sasl_log(const _sasl_global_context_t *gctx, 589 const sasl_callback_t *callbacks, 590 int level, 591 const char *fmt, 592 ...); 593 #endif /* _SUN_SDK_ */ 594 void _sasl_get_errorbuf(sasl_conn_t *conn, char ***bufhdl, size_t **lenhdl); 595 #ifdef _SUN_SDK_ 596 int __sasl_add_string(const _sasl_global_context_t *gctx, char **out, 597 size_t *alloclen, 598 size_t *outlen, const char *add); 599 600 #define _sasl_add_string(out, alloclen, outlen, add) \ 601 __sasl_add_string(gctx, out, alloclen, outlen, add) 602 603 /* More Generic Utilities in common.c */ 604 #define _sasl_strdup(in, out, outlen) \ 605 __sasl_strdup(gctx, in, out, outlen) 606 extern int __sasl_strdup(const _sasl_global_context_t *gctx, const char *in, 607 char **out, size_t *outlen); 608 609 /* Basically a conditional call to realloc(), if we need more */ 610 int __buf_alloc(const _sasl_global_context_t *gctx, char **rwbuf, 611 size_t *curlen, size_t newlen); 612 #define _buf_alloc(rwbuf, curlen, newlen) \ 613 __buf_alloc(gctx, rwbuf, curlen, newlen) 614 #else 615 int _sasl_add_string(char **out, size_t *alloclen, 616 size_t *outlen, const char *add); 617 618 /* More Generic Utilities in common.c */ 619 extern int _sasl_strdup(const char *in, char **out, size_t *outlen); 620 621 /* Basically a conditional call to realloc(), if we need more */ 622 int _buf_alloc(char **rwbuf, size_t *curlen, size_t newlen); 623 #endif /* _SUN_SDK_ */ 624 625 /* convert an iovec to a single buffer */ 626 #ifdef _SUN_SDK_ 627 int _iovec_to_buf(const _sasl_global_context_t *gctx, const struct iovec *vec, 628 unsigned numiov, buffer_info_t **output); 629 #else 630 int _iovec_to_buf(const struct iovec *vec, 631 unsigned numiov, buffer_info_t **output); 632 #endif /* _SUN_SDK_ */ 633 634 /* Convert between string formats and sockaddr formats */ 635 int _sasl_iptostring(const struct sockaddr *addr, socklen_t addrlen, 636 char *out, unsigned outlen); 637 int _sasl_ipfromstring(const char *addr, struct sockaddr *out, 638 socklen_t outlen); 639 640 /* 641 * external plugin (external.c) 642 */ 643 int external_client_plug_init(const sasl_utils_t *utils, 644 int max_version, 645 int *out_version, 646 sasl_client_plug_t **pluglist, 647 int *plugcount); 648 int external_server_plug_init(const sasl_utils_t *utils, 649 int max_version, 650 int *out_version, 651 sasl_server_plug_t **pluglist, 652 int *plugcount); 653 654 /* Mech Listing Functions */ 655 #ifdef _SUN_SDK_ 656 int _sasl_build_mechlist(_sasl_global_context_t *gctx); 657 #else 658 int _sasl_build_mechlist(void); 659 #endif /* _SUN_SDK_ */ 660 661 int _sasl_server_listmech(sasl_conn_t *conn, 662 const char *user, 663 const char *prefix, 664 const char *sep, 665 const char *suffix, 666 const char **result, 667 unsigned *plen, 668 int *pcount); 669 int _sasl_client_listmech(sasl_conn_t *conn, 670 const char *prefix, 671 const char *sep, 672 const char *suffix, 673 const char **result, 674 unsigned *plen, 675 int *pcount); 676 /* Just create a straight list of them */ 677 #ifdef _SUN_SDK_ 678 sasl_string_list_t *_sasl_client_mechs(_sasl_global_context_t *gctx); 679 sasl_string_list_t *_sasl_server_mechs(_sasl_global_context_t *gctx); 680 #else 681 sasl_string_list_t *_sasl_client_mechs(void); 682 sasl_string_list_t *_sasl_server_mechs(void); 683 #endif /* _SUN_SDK_ */ 684 685 /* 686 * config file declarations (config.c) 687 */ 688 #ifdef _SUN_SDK_ 689 extern int sasl_config_init(_sasl_global_context_t *gctx, 690 const char *filename); 691 extern void sasl_config_free(_sasl_global_context_t *gctx); 692 extern const char *sasl_config_getstring(_sasl_global_context_t *gctx, 693 const char *key,const char *def); 694 extern int sasl_config_getint(_sasl_global_context_t *gctx, 695 const char *key,int def); 696 extern int sasl_config_getswitch(_sasl_global_context_t *gctx, 697 const char *key,int def); 698 #else 699 extern int sasl_config_init(const char *filename); 700 extern const char *sasl_config_getstring(const char *key,const char *def); 701 extern int sasl_config_getint(const char *key,int def); 702 extern int sasl_config_getswitch(const char *key,int def); 703 #endif /* _SUN_SDK_ */ 704 705 /* checkpw.c */ 706 #ifdef DO_SASL_CHECKAPOP 707 extern int _sasl_auxprop_verify_apop(sasl_conn_t *conn, 708 const char *userstr, 709 const char *challenge, 710 const char *response, 711 const char *user_realm); 712 #endif /* DO_SASL_CHECKAPOP */ 713 714 /* Auxprop Plugin (checkpw.c) */ 715 extern int sasldb_auxprop_plug_init(const sasl_utils_t *utils, 716 int max_version, 717 int *out_version, 718 sasl_auxprop_plug_t **plug, 719 const char *plugname); 720 721 /* 722 * auxprop.c 723 */ 724 #ifdef _SUN_SDK_ 725 extern void _sasl_auxprop_free(_sasl_global_context_t *gctx); 726 #else 727 extern int _sasl_auxprop_add_plugin(void *p, void *library); 728 extern void _sasl_auxprop_free(void); 729 #endif /* _SUN_SDK_ */ 730 extern void _sasl_auxprop_lookup(sasl_server_params_t *sparams, 731 unsigned flags, 732 const char *user, unsigned ulen); 733 734 /* 735 * canonusr.c 736 */ 737 #ifdef _SUN_SDK_ 738 void _sasl_canonuser_free(_sasl_global_context_t *gctx); 739 #else 740 void _sasl_canonuser_free(); 741 #endif /* _SUN_SDK_ */ 742 extern int internal_canonuser_init(const sasl_utils_t *utils, 743 int max_version, 744 int *out_version, 745 sasl_canonuser_plug_t **plug, 746 const char *plugname); 747 extern int _sasl_canon_user(sasl_conn_t *conn, 748 const char *user, unsigned ulen, 749 unsigned flags, 750 sasl_out_params_t *oparams); 751 752 #ifdef _SUN_SDK_ 753 /* Private functions to create, free, and use a private context */ 754 void *sasl_create_context(void); 755 756 void sasl_free_context(void *context); 757 758 extern int _sasl_server_init(void *ctx, const sasl_callback_t *callbacks, 759 const char *appname); 760 761 extern int _sasl_server_new(void *ctx, const char *service, 762 const char *serverFQDN, const char *user_realm, 763 const char *iplocalport, const char *ipremoteport, 764 const sasl_callback_t *callbacks, unsigned flags, 765 sasl_conn_t **pconn); 766 767 extern int _sasl_client_init(void *ctx, 768 const sasl_callback_t *callbacks); 769 770 extern int _sasl_client_new(void *ctx, 771 const char *service, 772 const char *serverFQDN, 773 const char *iplocalport, 774 const char *ipremoteport, 775 const sasl_callback_t *prompt_supp, 776 unsigned flags, 777 sasl_conn_t **pconn); 778 779 extern int _sasl_client_add_plugin(void *ctx, 780 const char *plugname, 781 sasl_client_plug_init_t *cplugfunc); 782 extern int _sasl_server_add_plugin(void *ctx, 783 const char *plugname, 784 sasl_server_plug_init_t *splugfunc); 785 extern int _sasl_canonuser_add_plugin(void *ctx, 786 const char *plugname, 787 sasl_canonuser_init_t *canonuserfunc); 788 extern int _sasl_auxprop_add_plugin(void *ctx, 789 const char *plugname, 790 sasl_auxprop_init_t *auxpropfunc); 791 792 _sasl_global_context_t *_sasl_gbl_ctx(void); 793 794 #ifdef _INTEGRATED_SOLARIS_ 795 int _is_sun_reg(void *mech); 796 #endif /* _INTEGRATED_SOLARIS_ */ 797 798 /* unsupported functions that are used internally */ 799 int sasl_randcreate(sasl_rand_t **rpool); 800 801 void sasl_randfree(sasl_rand_t **rpool); 802 803 void sasl_rand(sasl_rand_t *rpool, char *buf, unsigned len); 804 805 void sasl_churn(sasl_rand_t *rpool, const char *data, unsigned len); 806 807 int sasl_mkchal(sasl_conn_t *conn, char *buf, unsigned maxlen, 808 unsigned hostflag); 809 #endif /* _SUN_SDK_ */ 810 811 #endif /* SASLINT_H */