List supportedSASLmechanisms based upon what sasl_listmech() returns.

This commit is contained in:
Kurt Zeilenga 1999-08-03 23:23:05 +00:00
parent ecb9c3b3fb
commit 354d49fb9a
6 changed files with 57 additions and 40 deletions

View file

@ -648,6 +648,10 @@ if test $ol_enable_dns != no ; then
AC_CHECK_LIB(bind, res_search)
ac_cv_func_res_search=$ac_cv_lib_bind_res_search
fi
if test $ac_cv_func_res_search = no ; then
AC_CHECK_LIB(bind, __res_search)
ac_cv_func_res_search=$ac_cv_lib_bind___res_search
fi
if test $ac_cv_func_res_search = no ; then
AC_CHECK_LIB(resolv, res_search)
ac_cv_func_res_search=$ac_cv_lib_resolv_res_search

View file

@ -21,8 +21,6 @@
#include "slap.h"
char **supportedSASLMechanisms = NULL;
int
do_bind(
Connection *conn,

View file

@ -129,6 +129,10 @@ int slap_startup(int dbnum)
rc = backend_startup(dbnum);
if( rc == 0 ) {
rc = sasl_init();
}
return rc;
}
@ -140,6 +144,8 @@ int slap_shutdown(int dbnum)
"%s shutdown: initiated\n",
slap_name, 0, 0 );
sasl_destroy();
/* let backends do whatever cleanup they need to do */
rc = backend_shutdown(dbnum);

View file

@ -243,7 +243,6 @@ int load_module LDAP_P(( const char* file_name, int argc, char *argv[] ));
*/
extern char *supportedExtensions[];
extern char *supportedControls[];
extern char **supportedSASLMechanisms;
void monitor_info LDAP_P((
Connection *conn,
@ -318,6 +317,14 @@ int send_search_entry LDAP_P((
int str2result LDAP_P(( char *s,
int *code, char **matched, char **info ));
/*
* sasl.c
*/
extern char **supportedSASLMechanisms;
int sasl_init(void);
int sasl_destroy(void);
/*
* schema.c
*/

View file

@ -1,7 +1,5 @@
#include "portable.h"
#ifdef HAVE_CYRUS_SASL
#include <ac/stdlib.h>
#include <stdio.h>
@ -11,29 +9,24 @@
#include <lber.h>
#include <ldap_log.h>
#ifdef MAIN
#undef Debug
#define Debug(x,s,a,b,c) fprintf(stderr, s, a, b, c)
#endif
char **supportedSASLMechanisms = NULL;
#ifdef HAVE_CYRUS_SASL
#include <sasl.h>
/* sasl server context */
static sasl_conn_t *server = NULL;
int sasl_init( void )
{
int rc;
char *data;
unsigned len, count;
sasl_security_properties_t secprops;
sasl_conn_t *server = NULL;
rc = sasl_server_init( NULL, "slapd" );
if( rc != SASL_OK ) {
Debug( LDAP_DEBUG_ANY, "sasl_server_init failed\n",
0, 0, 0 );
return EXIT_FAILURE;
return -1;
}
rc = sasl_server_new( "ldap", NULL, NULL, NULL,
@ -43,21 +36,26 @@ int sasl_init( void )
if( rc != SASL_OK ) {
Debug( LDAP_DEBUG_ANY, "sasl_server_new failed\n",
0, 0, 0 );
return EXIT_FAILURE;
return -1;
}
memset(&secprops, 0, sizeof(secprops));
secprops.security_flags = SASL_SEC_NOPLAINTEXT | SASL_SEC_NOANONYMOUS;
secprops.property_names = NULL;
secprops.property_values = NULL;
#ifdef RESTRICT_SASL
{
sasl_security_properties_t secprops;
memset(&secprops, 0, sizeof(secprops));
secprops.security_flags = SASL_SEC_NOPLAINTEXT | SASL_SEC_NOANONYMOUS;
secprops.property_names = NULL;
secprops.property_values = NULL;
rc = sasl_setprop( server, SASL_SEC_PROPS, &secprops );
rc = sasl_setprop( server, SASL_SEC_PROPS, &secprops );
if( rc != SASL_OK ) {
Debug( LDAP_DEBUG_ANY, "sasl_setprop failed\n",
0, 0, 0 );
return EXIT_FAILURE;
if( rc != SASL_OK ) {
Debug( LDAP_DEBUG_ANY, "sasl_setprop failed\n",
0, 0, 0 );
return -1;
}
}
#endif
rc = sasl_listmech( server, NULL, NULL, ",", NULL,
&data, &len, &count);
@ -65,30 +63,26 @@ int sasl_init( void )
if( rc != SASL_OK ) {
Debug( LDAP_DEBUG_ANY, "sasl_listmech failed: %d\n",
rc, 0, 0 );
return EXIT_FAILURE;
return -1;
}
Debug( LDAP_DEBUG_TRACE, "SASL mechanisms: %s\n",
data, 0, 0 );
return EXIT_SUCCESS;
supportedSASLMechanisms = str2charray( data, "," );
sasl_dispose( &server );
return 0;
}
int sasl_destory( void )
int sasl_destroy( void )
{
if( server != NULL ) {
sasl_dispose( &server );
}
charray_free( supportedSASLMechanisms );
return 0;
}
#ifdef MAIN
int main( int argc, char* argv[] )
{
int rc = sasl_init();
sasl_destory();
exit(rc);
}
#endif
#else
/* no SASL support */
int sasl_init( void ) { return 0; }
int sasl_destroy( void ) { return 0; }
#endif

View file

@ -99,3 +99,11 @@ struct berval **get_entry_referrals(
assert(0);
return NULL;
}
int sasl_init(void) {
return 0;
}
int sasl_destroy(void) {
return 0;
}