]> git.sur5r.net Git - openldap/commitdiff
List supportedSASLmechanisms based upon what sasl_listmech() returns.
authorKurt Zeilenga <kurt@openldap.org>
Tue, 3 Aug 1999 23:23:05 +0000 (23:23 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 3 Aug 1999 23:23:05 +0000 (23:23 +0000)
configure.in
servers/slapd/bind.c
servers/slapd/init.c
servers/slapd/proto-slap.h
servers/slapd/sasl.c
servers/slapd/tools/mimic.c

index e8aad57cec19e04f03d466048ceea2a369aed18e..3c41b6a5268813e9ca313602f6375f864ef8a3ce 100644 (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
index 7094b6a71f74abefb45df225c9a701f26241d791..34d617e6273b876232b1622cdc8a74b4b85bc653 100644 (file)
@@ -21,8 +21,6 @@
 
 #include "slap.h"
 
-char **supportedSASLMechanisms = NULL;
-
 int
 do_bind(
     Connection *conn,
index dc5091066331c30df0bd8eec0bbc602b66d470ff..36face1b28644ed01b155ca09e500cac3f8eb8f9 100644 (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); 
 
index ea41602032272a856d3688c9c5173565a36f16b7..3aaf6f02f4181a4ae2da4831f32da0782ec6a53f 100644 (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
  */
index d1b195f4590b27e4802794fd860778346473dd82..2552767e35a53df6081bf527b09346ba441f8a9a 100644 (file)
@@ -1,7 +1,5 @@
 #include "portable.h"
 
-#ifdef HAVE_CYRUS_SASL
-
 #include <ac/stdlib.h>
 #include <stdio.h>
 
 #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 );
 
-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
index fba6ef6767add6ce2346c1654b8e9ff08d60586e..c5e4d28492da73504b1f09abbbe3f39657b7da17 100644 (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;
+}