Print this page
pass 2
first pass


 290     
 291     result = sasl_encodev(conn, &tmp, 1, output, outputlen);
 292 
 293     RETURN(conn, result);
 294 }
 295 
 296 /* security-encode an iovec */
 297 /* output is only valid until next call to sasl_encode or sasl_encodev */
 298 int sasl_encodev(sasl_conn_t *conn,
 299                  const struct iovec *invec, unsigned numiov,
 300                  const char **output, unsigned *outputlen)
 301 {
 302 #ifdef _SUN_SDK_
 303     int result = SASL_FAIL;
 304 #else
 305     int result;
 306 #endif /* _SUN_SDK_ */
 307     unsigned i;
 308     size_t total_size = 0;
 309 
 310     /* EXPORT DELETE START */
 311     if (!conn) return SASL_BADPARAM;
 312     if (! invec || ! output || ! outputlen || numiov < 1)
 313         PARAMERROR(conn);
 314 
 315     if(!conn->props.maxbufsize) {
 316 #ifdef _SUN_SDK_
 317         _sasl_log(conn, SASL_LOG_ERR,
 318                   "called sasl_encode[v] with application that does not support security layers");
 319 #else
 320         sasl_seterror(conn, 0,
 321                       "called sasl_encode[v] with application that does not support security layers");
 322 #endif /* _SUN_SDK_ */
 323         return SASL_TOOWEAK;
 324     }
 325 
 326     /* This might be better to check on a per-plugin basis, but I think
 327      * it's cleaner and more effective here.  It also encourages plugins
 328      * to be honest about what they accept */
 329 
 330     for(i=0; i<numiov;i++) {
 331 #ifdef _SUN_SDK_
 332         if (invec[i].iov_base == NULL)
 333             PARAMERROR(conn);
 334 #endif /* _SUN_SDK_ */
 335         total_size += invec[i].iov_len;
 336     }    
 337     if(total_size > conn->oparams.maxoutbuf)
 338         PARAMERROR(conn);
 339 
 340     if(conn->oparams.encode == NULL)  {
 341 #ifdef _SUN_SDK_
 342         result = _iovec_to_buf(conn->gctx, invec, numiov, &conn->encode_buf);
 343 #else
 344         result = _iovec_to_buf(invec, numiov, &conn->encode_buf);
 345 #endif /* _SUN_SDK_ */
 346         if(result != SASL_OK) INTERROR(conn, result);
 347        
 348         *output = conn->encode_buf->data;
 349         *outputlen = conn->encode_buf->curlen;
 350 
 351     /* CRYPT DELETE START */
 352 #ifdef _INTEGRATED_SOLARIS_
 353     } else if (!conn->sun_reg) {
 354             INTERROR(conn, SASL_FAIL);
 355 #endif /* _INTEGRATED_SOLARIS_ */
 356     /* CRYPT DELETE END */
 357     } else {
 358         result = conn->oparams.encode(conn->context, invec, numiov,
 359                                       output, outputlen);
 360     }
 361     /* EXPORT DELETE END */
 362 
 363     RETURN(conn, result);
 364 }
 365  
 366 /* output is only valid until next call to sasl_decode */
 367 int sasl_decode(sasl_conn_t *conn,
 368                 const char *input, unsigned inputlen,
 369                 const char **output, unsigned *outputlen)
 370 {
 371     int result;
 372     /* EXPORT DELETE START */
 373 #ifdef _SUN_SDK_
 374     const _sasl_global_context_t *gctx;
 375 #endif /* _SUN_SDK_ */
 376 
 377     if(!conn) return SASL_BADPARAM;
 378     if(!input || !output || !outputlen)
 379         PARAMERROR(conn);
 380 
 381 #ifdef _SUN_SDK_
 382     gctx = conn->gctx;
 383 #endif /* _SUN_SDK_ */
 384 
 385     if(!conn->props.maxbufsize) {
 386 #ifdef _SUN_SDK_
 387         _sasl_log(conn, SASL_LOG_ERR,
 388                   "called sasl_decode with application that does not support security layers");
 389 #else
 390         sasl_seterror(conn, 0,
 391                       "called sasl_decode with application that does not support security layers");
 392 #endif /* _SUN_SDK_ */


 406             _sasl_log(conn, SASL_LOG_ERR,
 407                       "input too large for default sasl_decode");
 408 #else
 409             sasl_seterror(conn, 0,
 410                           "input too large for default sasl_decode");
 411 #endif /* _SUN_SDK_ */
 412             RETURN(conn,SASL_BUFOVER);
 413         }
 414 
 415         if(!conn->decode_buf)
 416             conn->decode_buf = sasl_ALLOC(conn->props.maxbufsize + 1);
 417         if(!conn->decode_buf)        
 418             MEMERROR(conn);
 419         
 420         memcpy(conn->decode_buf, input, inputlen);
 421         conn->decode_buf[inputlen] = '\0';
 422         *output = conn->decode_buf;
 423         *outputlen = inputlen;
 424         
 425         return SASL_OK;
 426     /* CRYPT DELETE START */
 427 #ifdef _INTEGRATED_SOLARIS_
 428     } else if (!conn->sun_reg) {
 429             INTERROR(conn, SASL_FAIL);
 430 #endif /* _INTEGRATED_SOLARIS_ */
 431     /* CRYPT DELETE END */
 432     } else {
 433         result = conn->oparams.decode(conn->context, input, inputlen,
 434                                       output, outputlen);
 435 
 436         /* NULL an empty buffer (for misbehaved applications) */
 437         if (*outputlen == 0) *output = NULL;
 438 
 439         RETURN(conn, result);
 440     }
 441 
 442     /* EXPORT DELETE END */
 443 #ifdef _SUN_SDK_
 444     return SASL_FAIL;
 445 #else
 446     INTERROR(conn, SASL_FAIL);
 447 #endif  /* _SUN_SDK_ */
 448 }
 449 
 450 
 451 void
 452 sasl_set_alloc(sasl_malloc_t *m,
 453                sasl_calloc_t *c,
 454                sasl_realloc_t *r,
 455                sasl_free_t *f)
 456 {
 457 #ifdef _SUN_SDK_
 458   _sasl_global_context_t *gctx =  _sasl_gbl_ctx();
 459 
 460   LOCK_MUTEX(&malloc_global_mutex);
 461   gctx->sasl_allocation_utils.malloc=m;
 462   gctx->sasl_allocation_utils.calloc=c;


 730 /* get property from SASL connection state
 731  *  propnum       -- property number
 732  *  pvalue        -- pointer to value
 733  * returns:
 734  *  SASL_OK       -- no error
 735  *  SASL_NOTDONE  -- property not available yet
 736  *  SASL_BADPARAM -- bad property number
 737  */
 738 int sasl_getprop(sasl_conn_t *conn, int propnum, const void **pvalue)
 739 {
 740   int result = SASL_OK;
 741   sasl_getopt_t *getopt;
 742   void *context;
 743   
 744   if (! conn) return SASL_BADPARAM;
 745   if (! pvalue) PARAMERROR(conn);
 746 
 747   switch(propnum)
 748   {
 749   case SASL_SSF:
 750     /* EXPORT DELETE START */
 751     /* CRYPT DELETE START */
 752 #ifdef _INTEGRATED_SOLARIS_
 753       if (!conn->sun_reg)
 754         conn->oparams.mech_ssf = 0;
 755 #endif /* _INTEGRATED_SOLARIS_ */
 756     /* CRYPT DELETE END */
 757     /* EXPORT DELETE END */
 758       *(sasl_ssf_t **)pvalue= &conn->oparams.mech_ssf;
 759       break;      
 760   case SASL_MAXOUTBUF:
 761       *(unsigned **)pvalue = &conn->oparams.maxoutbuf;
 762       break;
 763   case SASL_GETOPTCTX:
 764       result = _sasl_getcallback(conn, SASL_CB_GETOPT, &getopt, &context);
 765       if(result != SASL_OK) break;
 766       
 767       *(void **)pvalue = context;
 768       break;
 769   case SASL_CALLBACK:
 770       *(const sasl_callback_t **)pvalue = conn->callbacks;
 771       break;
 772   case SASL_IPLOCALPORT:
 773       if(conn->got_ip_local)
 774           *(const char **)pvalue = conn->iplocalport;
 775       else {
 776           *(const char **)pvalue = NULL;
 777           result = SASL_NOTDONE;


1287 #endif /* _SUN_SDK_ */
1288     
1289     errstr = sasl_errstring(conn->error_code, NULL, NULL);
1290     snprintf(leader,128,"SASL(%d): %s: ",
1291              sasl_usererr(conn->error_code), errstr);
1292     
1293     need_len = strlen(leader) + strlen(conn->error_buf) + 12;
1294 #ifdef _SUN_SDK_
1295     ret = _buf_alloc(&conn->errdetail_buf, &conn->errdetail_buf_len, need_len);
1296     if (ret != SASL_OK)
1297         return "no memory available";
1298 #else
1299     _buf_alloc(&conn->errdetail_buf, &conn->errdetail_buf_len, need_len);
1300 #endif /* _SUN_SDK_ */
1301 
1302     snprintf(conn->errdetail_buf, need_len, "%s%s", leader, conn->error_buf);
1303    
1304     return conn->errdetail_buf;
1305 }
1306 
1307 /* EXPORT DELETE START */
1308 /* CRYPT DELETE START */
1309 #ifdef _INTEGRATED_SOLARIS_
1310 DEFINE_STATIC_MUTEX(reg_mutex);
1311 typedef struct reg_list {
1312         struct reg_list *next;
1313         void *mech;
1314 } reg_list_t;
1315 
1316 static reg_list_t *reg_list_base = NULL;
1317 
1318 int _is_sun_reg(void *mech)
1319 {
1320         reg_list_t *r, *prev;
1321         int is_reg = 0;
1322 
1323         LOCK_MUTEX(&reg_mutex);
1324         for (r = reg_list_base; r != NULL; r = r->next) {
1325                 if (r->mech != mech) {
1326                         prev = r;
1327                         continue;
1328                 }


1336                 break;
1337         }
1338         UNLOCK_MUTEX(&reg_mutex);
1339         return (is_reg);
1340 }
1341 
1342 static void
1343 _register_plugin(void *arg)
1344 {
1345         reg_list_t *r = (reg_list_t *)calloc(1, sizeof (reg_list_t));
1346 
1347         if (r != NULL) {
1348                 r->mech = arg;
1349                 LOCK_MUTEX(&reg_mutex);
1350                 r->next = reg_list_base;
1351                 reg_list_base = r;
1352                 UNLOCK_MUTEX(&reg_mutex);
1353         }
1354 }
1355 #endif /* _INTEGRATED_SOLARIS_ */
1356 /* CRYPT DELETE END */
1357 /* EXPORT DELETE END */
1358 
1359 /* Note that this needs the global callbacks, so if you don't give getcallbacks
1360  * a sasl_conn_t, you're going to need to pass it yourself (or else we couldn't
1361  * have client and server at the same time */
1362 static int _sasl_global_getopt(void *context,
1363                                const char *plugin_name,
1364                                const char *option,
1365                                const char ** result,
1366                                unsigned *len)
1367 {
1368   const sasl_global_callbacks_t * global_callbacks;
1369   const sasl_callback_t *callback;
1370 #ifdef _SUN_SDK_
1371   _sasl_global_context_t *gctx;
1372 #endif /* _SUN_SDK_ */
1373 
1374   global_callbacks = (const sasl_global_callbacks_t *) context;
1375 
1376 #ifdef _SUN_SDK_
1377   /* EXPORT DELETE START */
1378   /* CRYPT DELETE START */
1379 #ifdef _INTEGRATED_SOLARIS_
1380   if (strcmp("reg_sun_plug", option) == 0) {
1381         *result = (const char *)_register_plugin;
1382         *len = 0;
1383         return (SASL_OK);
1384   }
1385 #endif /* _INTEGRATED_SOLARIS_ */
1386   /* CRYPT DELETE END */
1387   /* EXPORT DELETE END */
1388 
1389   if (global_callbacks)
1390     gctx = global_callbacks->gctx;
1391   else
1392     gctx = _sasl_gbl_ctx();
1393 #endif /* _SUN_SDK_ */
1394 
1395   if (global_callbacks && global_callbacks->callbacks) {
1396       for (callback = global_callbacks->callbacks;
1397            callback->id != SASL_CB_LIST_END;
1398            callback++) {
1399         if (callback->id == SASL_CB_GETOPT) {
1400           if (!callback->proc) return SASL_FAIL;
1401           if (((sasl_getopt_t *)(callback->proc))(callback->context,
1402                                                   plugin_name,
1403                                                   option,
1404                                                   result,
1405                                                   len)
1406               == SASL_OK)
1407             return SASL_OK;


2679                                 /* sasl_allocation_utils */
2680         {&sasl_mutex_alloc, &sasl_mutex_lock, &sasl_mutex_unlock,
2681             &sasl_mutex_free},  /* sasl_mutex_utils */
2682         NULL                    /* lib_list_head */
2683   };
2684 
2685   return (&gbl_ctx);
2686 }
2687 
2688 static int
2689 _sasl_getconf(void *context __attribute__((unused)), const char **conf)
2690 {
2691     if (! conf)
2692         return SASL_BADPARAM;
2693 
2694     *conf = SASL_CONFDIR;
2695 
2696     return SASL_OK;
2697 }
2698 
2699 /* EXPORT DELETE START */
2700 /* CRYPT DELETE START */
2701 #ifdef _INTEGRATED_SOLARIS_
2702 #pragma fini(sasl_fini)
2703 int 
2704 sasl_fini(void) 
2705 { 
2706     reg_list_t *next;
2707 
2708     while (reg_list_base != NULL) {
2709         next = reg_list_base->next;
2710         free(reg_list_base);
2711         reg_list_base = next;
2712     }
2713     return (0);
2714 } 
2715 #endif /* _INTEGRATED_SOLARIS_ */
2716 /* CRYPT DELETE END */
2717 /* EXPORT DELETE END */
2718 
2719 #endif /* _SUN_SDK_ */
2720 
2721 #ifndef WIN32
2722 static int
2723 _sasl_getpath(void *context __attribute__((unused)),
2724               const char **path)
2725 {
2726   if (! path)
2727     return SASL_BADPARAM;
2728 
2729 #ifdef _SUN_SDK_
2730 /* SASL_PATH is not allowed for SUN SDK */
2731 #else
2732   *path = getenv(SASL_PATH_ENV_VAR);
2733   if (! *path)
2734 #endif /* _SUN_SDK_ */
2735     *path = PLUGINDIR;
2736 
2737   return SASL_OK;




 290     
 291     result = sasl_encodev(conn, &tmp, 1, output, outputlen);
 292 
 293     RETURN(conn, result);
 294 }
 295 
 296 /* security-encode an iovec */
 297 /* output is only valid until next call to sasl_encode or sasl_encodev */
 298 int sasl_encodev(sasl_conn_t *conn,
 299                  const struct iovec *invec, unsigned numiov,
 300                  const char **output, unsigned *outputlen)
 301 {
 302 #ifdef _SUN_SDK_
 303     int result = SASL_FAIL;
 304 #else
 305     int result;
 306 #endif /* _SUN_SDK_ */
 307     unsigned i;
 308     size_t total_size = 0;
 309 

 310     if (!conn) return SASL_BADPARAM;
 311     if (! invec || ! output || ! outputlen || numiov < 1)
 312         PARAMERROR(conn);
 313 
 314     if(!conn->props.maxbufsize) {
 315 #ifdef _SUN_SDK_
 316         _sasl_log(conn, SASL_LOG_ERR,
 317                   "called sasl_encode[v] with application that does not support security layers");
 318 #else
 319         sasl_seterror(conn, 0,
 320                       "called sasl_encode[v] with application that does not support security layers");
 321 #endif /* _SUN_SDK_ */
 322         return SASL_TOOWEAK;
 323     }
 324 
 325     /* This might be better to check on a per-plugin basis, but I think
 326      * it's cleaner and more effective here.  It also encourages plugins
 327      * to be honest about what they accept */
 328 
 329     for(i=0; i<numiov;i++) {
 330 #ifdef _SUN_SDK_
 331         if (invec[i].iov_base == NULL)
 332             PARAMERROR(conn);
 333 #endif /* _SUN_SDK_ */
 334         total_size += invec[i].iov_len;
 335     }    
 336     if(total_size > conn->oparams.maxoutbuf)
 337         PARAMERROR(conn);
 338 
 339     if(conn->oparams.encode == NULL)  {
 340 #ifdef _SUN_SDK_
 341         result = _iovec_to_buf(conn->gctx, invec, numiov, &conn->encode_buf);
 342 #else
 343         result = _iovec_to_buf(invec, numiov, &conn->encode_buf);
 344 #endif /* _SUN_SDK_ */
 345         if(result != SASL_OK) INTERROR(conn, result);
 346        
 347         *output = conn->encode_buf->data;
 348         *outputlen = conn->encode_buf->curlen;
 349 

 350 #ifdef _INTEGRATED_SOLARIS_
 351     } else if (!conn->sun_reg) {
 352             INTERROR(conn, SASL_FAIL);
 353 #endif /* _INTEGRATED_SOLARIS_ */

 354     } else {
 355         result = conn->oparams.encode(conn->context, invec, numiov,
 356                                       output, outputlen);
 357     }

 358 
 359     RETURN(conn, result);
 360 }
 361  
 362 /* output is only valid until next call to sasl_decode */
 363 int sasl_decode(sasl_conn_t *conn,
 364                 const char *input, unsigned inputlen,
 365                 const char **output, unsigned *outputlen)
 366 {
 367     int result;

 368 #ifdef _SUN_SDK_
 369     const _sasl_global_context_t *gctx;
 370 #endif /* _SUN_SDK_ */
 371 
 372     if(!conn) return SASL_BADPARAM;
 373     if(!input || !output || !outputlen)
 374         PARAMERROR(conn);
 375 
 376 #ifdef _SUN_SDK_
 377     gctx = conn->gctx;
 378 #endif /* _SUN_SDK_ */
 379 
 380     if(!conn->props.maxbufsize) {
 381 #ifdef _SUN_SDK_
 382         _sasl_log(conn, SASL_LOG_ERR,
 383                   "called sasl_decode with application that does not support security layers");
 384 #else
 385         sasl_seterror(conn, 0,
 386                       "called sasl_decode with application that does not support security layers");
 387 #endif /* _SUN_SDK_ */


 401             _sasl_log(conn, SASL_LOG_ERR,
 402                       "input too large for default sasl_decode");
 403 #else
 404             sasl_seterror(conn, 0,
 405                           "input too large for default sasl_decode");
 406 #endif /* _SUN_SDK_ */
 407             RETURN(conn,SASL_BUFOVER);
 408         }
 409 
 410         if(!conn->decode_buf)
 411             conn->decode_buf = sasl_ALLOC(conn->props.maxbufsize + 1);
 412         if(!conn->decode_buf)        
 413             MEMERROR(conn);
 414         
 415         memcpy(conn->decode_buf, input, inputlen);
 416         conn->decode_buf[inputlen] = '\0';
 417         *output = conn->decode_buf;
 418         *outputlen = inputlen;
 419         
 420         return SASL_OK;

 421 #ifdef _INTEGRATED_SOLARIS_
 422     } else if (!conn->sun_reg) {
 423             INTERROR(conn, SASL_FAIL);
 424 #endif /* _INTEGRATED_SOLARIS_ */

 425     } else {
 426         result = conn->oparams.decode(conn->context, input, inputlen,
 427                                       output, outputlen);
 428 
 429         /* NULL an empty buffer (for misbehaved applications) */
 430         if (*outputlen == 0) *output = NULL;
 431 
 432         RETURN(conn, result);
 433     }
 434 

 435 #ifdef _SUN_SDK_
 436     return SASL_FAIL;
 437 #else
 438     INTERROR(conn, SASL_FAIL);
 439 #endif  /* _SUN_SDK_ */
 440 }
 441 
 442 
 443 void
 444 sasl_set_alloc(sasl_malloc_t *m,
 445                sasl_calloc_t *c,
 446                sasl_realloc_t *r,
 447                sasl_free_t *f)
 448 {
 449 #ifdef _SUN_SDK_
 450   _sasl_global_context_t *gctx =  _sasl_gbl_ctx();
 451 
 452   LOCK_MUTEX(&malloc_global_mutex);
 453   gctx->sasl_allocation_utils.malloc=m;
 454   gctx->sasl_allocation_utils.calloc=c;


 722 /* get property from SASL connection state
 723  *  propnum       -- property number
 724  *  pvalue        -- pointer to value
 725  * returns:
 726  *  SASL_OK       -- no error
 727  *  SASL_NOTDONE  -- property not available yet
 728  *  SASL_BADPARAM -- bad property number
 729  */
 730 int sasl_getprop(sasl_conn_t *conn, int propnum, const void **pvalue)
 731 {
 732   int result = SASL_OK;
 733   sasl_getopt_t *getopt;
 734   void *context;
 735   
 736   if (! conn) return SASL_BADPARAM;
 737   if (! pvalue) PARAMERROR(conn);
 738 
 739   switch(propnum)
 740   {
 741   case SASL_SSF:


 742 #ifdef _INTEGRATED_SOLARIS_
 743       if (!conn->sun_reg)
 744         conn->oparams.mech_ssf = 0;
 745 #endif /* _INTEGRATED_SOLARIS_ */


 746       *(sasl_ssf_t **)pvalue= &conn->oparams.mech_ssf;
 747       break;      
 748   case SASL_MAXOUTBUF:
 749       *(unsigned **)pvalue = &conn->oparams.maxoutbuf;
 750       break;
 751   case SASL_GETOPTCTX:
 752       result = _sasl_getcallback(conn, SASL_CB_GETOPT, &getopt, &context);
 753       if(result != SASL_OK) break;
 754       
 755       *(void **)pvalue = context;
 756       break;
 757   case SASL_CALLBACK:
 758       *(const sasl_callback_t **)pvalue = conn->callbacks;
 759       break;
 760   case SASL_IPLOCALPORT:
 761       if(conn->got_ip_local)
 762           *(const char **)pvalue = conn->iplocalport;
 763       else {
 764           *(const char **)pvalue = NULL;
 765           result = SASL_NOTDONE;


1275 #endif /* _SUN_SDK_ */
1276     
1277     errstr = sasl_errstring(conn->error_code, NULL, NULL);
1278     snprintf(leader,128,"SASL(%d): %s: ",
1279              sasl_usererr(conn->error_code), errstr);
1280     
1281     need_len = strlen(leader) + strlen(conn->error_buf) + 12;
1282 #ifdef _SUN_SDK_
1283     ret = _buf_alloc(&conn->errdetail_buf, &conn->errdetail_buf_len, need_len);
1284     if (ret != SASL_OK)
1285         return "no memory available";
1286 #else
1287     _buf_alloc(&conn->errdetail_buf, &conn->errdetail_buf_len, need_len);
1288 #endif /* _SUN_SDK_ */
1289 
1290     snprintf(conn->errdetail_buf, need_len, "%s%s", leader, conn->error_buf);
1291    
1292     return conn->errdetail_buf;
1293 }
1294 


1295 #ifdef _INTEGRATED_SOLARIS_
1296 DEFINE_STATIC_MUTEX(reg_mutex);
1297 typedef struct reg_list {
1298         struct reg_list *next;
1299         void *mech;
1300 } reg_list_t;
1301 
1302 static reg_list_t *reg_list_base = NULL;
1303 
1304 int _is_sun_reg(void *mech)
1305 {
1306         reg_list_t *r, *prev;
1307         int is_reg = 0;
1308 
1309         LOCK_MUTEX(&reg_mutex);
1310         for (r = reg_list_base; r != NULL; r = r->next) {
1311                 if (r->mech != mech) {
1312                         prev = r;
1313                         continue;
1314                 }


1322                 break;
1323         }
1324         UNLOCK_MUTEX(&reg_mutex);
1325         return (is_reg);
1326 }
1327 
1328 static void
1329 _register_plugin(void *arg)
1330 {
1331         reg_list_t *r = (reg_list_t *)calloc(1, sizeof (reg_list_t));
1332 
1333         if (r != NULL) {
1334                 r->mech = arg;
1335                 LOCK_MUTEX(&reg_mutex);
1336                 r->next = reg_list_base;
1337                 reg_list_base = r;
1338                 UNLOCK_MUTEX(&reg_mutex);
1339         }
1340 }
1341 #endif /* _INTEGRATED_SOLARIS_ */


1342 
1343 /* Note that this needs the global callbacks, so if you don't give getcallbacks
1344  * a sasl_conn_t, you're going to need to pass it yourself (or else we couldn't
1345  * have client and server at the same time */
1346 static int _sasl_global_getopt(void *context,
1347                                const char *plugin_name,
1348                                const char *option,
1349                                const char ** result,
1350                                unsigned *len)
1351 {
1352   const sasl_global_callbacks_t * global_callbacks;
1353   const sasl_callback_t *callback;
1354 #ifdef _SUN_SDK_
1355   _sasl_global_context_t *gctx;
1356 #endif /* _SUN_SDK_ */
1357 
1358   global_callbacks = (const sasl_global_callbacks_t *) context;
1359 
1360 #ifdef _SUN_SDK_


1361 #ifdef _INTEGRATED_SOLARIS_
1362   if (strcmp("reg_sun_plug", option) == 0) {
1363         *result = (const char *)_register_plugin;
1364         *len = 0;
1365         return (SASL_OK);
1366   }
1367 #endif /* _INTEGRATED_SOLARIS_ */


1368 
1369   if (global_callbacks)
1370     gctx = global_callbacks->gctx;
1371   else
1372     gctx = _sasl_gbl_ctx();
1373 #endif /* _SUN_SDK_ */
1374 
1375   if (global_callbacks && global_callbacks->callbacks) {
1376       for (callback = global_callbacks->callbacks;
1377            callback->id != SASL_CB_LIST_END;
1378            callback++) {
1379         if (callback->id == SASL_CB_GETOPT) {
1380           if (!callback->proc) return SASL_FAIL;
1381           if (((sasl_getopt_t *)(callback->proc))(callback->context,
1382                                                   plugin_name,
1383                                                   option,
1384                                                   result,
1385                                                   len)
1386               == SASL_OK)
1387             return SASL_OK;


2659                                 /* sasl_allocation_utils */
2660         {&sasl_mutex_alloc, &sasl_mutex_lock, &sasl_mutex_unlock,
2661             &sasl_mutex_free},  /* sasl_mutex_utils */
2662         NULL                    /* lib_list_head */
2663   };
2664 
2665   return (&gbl_ctx);
2666 }
2667 
2668 static int
2669 _sasl_getconf(void *context __attribute__((unused)), const char **conf)
2670 {
2671     if (! conf)
2672         return SASL_BADPARAM;
2673 
2674     *conf = SASL_CONFDIR;
2675 
2676     return SASL_OK;
2677 }
2678 


2679 #ifdef _INTEGRATED_SOLARIS_
2680 #pragma fini(sasl_fini)
2681 int 
2682 sasl_fini(void) 
2683 { 
2684     reg_list_t *next;
2685 
2686     while (reg_list_base != NULL) {
2687         next = reg_list_base->next;
2688         free(reg_list_base);
2689         reg_list_base = next;
2690     }
2691     return (0);
2692 } 
2693 #endif /* _INTEGRATED_SOLARIS_ */


2694 
2695 #endif /* _SUN_SDK_ */
2696 
2697 #ifndef WIN32
2698 static int
2699 _sasl_getpath(void *context __attribute__((unused)),
2700               const char **path)
2701 {
2702   if (! path)
2703     return SASL_BADPARAM;
2704 
2705 #ifdef _SUN_SDK_
2706 /* SASL_PATH is not allowed for SUN SDK */
2707 #else
2708   *path = getenv(SASL_PATH_ENV_VAR);
2709   if (! *path)
2710 #endif /* _SUN_SDK_ */
2711     *path = PLUGINDIR;
2712 
2713   return SASL_OK;