From: Kurt Zeilenga Date: Tue, 3 Aug 1999 23:23:05 +0000 (+0000) Subject: List supportedSASLmechanisms based upon what sasl_listmech() returns. X-Git-Tag: TWEB_OL_BASE~301 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=354d49fb9a2e7112b422844a4e1059f55634705d;p=openldap List supportedSASLmechanisms based upon what sasl_listmech() returns. --- diff --git a/configure.in b/configure.in index e8aad57cec..3c41b6a526 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 7094b6a71f..34d617e627 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -21,8 +21,6 @@ #include "slap.h" -char **supportedSASLMechanisms = NULL; - int do_bind( Connection *conn, diff --git a/servers/slapd/init.c b/servers/slapd/init.c index dc50910663..36face1b28 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -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); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index ea41602032..3aaf6f02f4 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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 */ diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index d1b195f459..2552767e35 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -1,7 +1,5 @@ #include "portable.h" -#ifdef HAVE_CYRUS_SASL - #include #include @@ -11,29 +9,24 @@ #include #include -#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 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 ); -int sasl_destory( void ) -{ - if( server != NULL ) { - sasl_dispose( &server ); - } + return 0; } -#ifdef MAIN -int main( int argc, char* argv[] ) +int sasl_destroy( void ) { - int rc = sasl_init(); - - sasl_destory(); - - exit(rc); + charray_free( supportedSASLMechanisms ); + return 0; } -#endif + +#else +/* no SASL support */ +int sasl_init( void ) { return 0; } +int sasl_destroy( void ) { return 0; } #endif diff --git a/servers/slapd/tools/mimic.c b/servers/slapd/tools/mimic.c index fba6ef6767..c5e4d28492 100644 --- a/servers/slapd/tools/mimic.c +++ b/servers/slapd/tools/mimic.c @@ -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; +}