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