]> git.sur5r.net Git - openldap/commitdiff
Add a little SASL framework and remove old X-DIGEST-MD5 hardcode.
authorKurt Zeilenga <kurt@openldap.org>
Tue, 3 Aug 1999 02:37:42 +0000 (02:37 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 3 Aug 1999 02:37:42 +0000 (02:37 +0000)
This code is not called (yet).

configure
configure.in
include/portable.h.in
servers/slapd/Makefile.in
servers/slapd/bind.c
servers/slapd/proto-slap.h
servers/slapd/root_dse.c
servers/slapd/sasl.c [new file with mode: 0644]

index fd79ea943742653b697c8086108390725652a726..40a2a636d9bbfc058ef7a15d4c60dc2322bdca5d 100755 (executable)
--- a/configure
+++ b/configure
@@ -10492,7 +10492,7 @@ fi
                if test $have_cyrus_sasl != no ; then
                        LUTIL_LIBS="$LUTIL_LIBS -lsasl"
                        cat >> confdefs.h <<\EOF
-#define HAVE_CRYUS_SASL 1
+#define HAVE_CYRUS_SASL 1
 EOF
 
                        ol_link_sasl=yes
index 54ea8bdf316a3687ed465cc952f766200eb28b35..6cce7a6648c6fd8db7c4a7298c5002a9add95b77 100644 (file)
@@ -1653,7 +1653,7 @@ if test $ol_with_cyrus_sasl != no ; then
 
                if test $have_cyrus_sasl != no ; then
                        LUTIL_LIBS="$LUTIL_LIBS -lsasl"
-                       AC_DEFINE(HAVE_CRYUS_SASL,1,[define if you have Cyrus SASL])
+                       AC_DEFINE(HAVE_CYRUS_SASL,1,[define if you have Cyrus SASL])
                        ol_link_sasl=yes
                fi
        fi
index c18e14bc6f6aabc393bfd887ace5a5749b51ad9f..f8a74c960c6a4893cccc832a8d5ccbc3371e8ef9 100644 (file)
 #undef NO_TERMCAP
 
 /* define if you have Cyrus SASL */
-#undef HAVE_CRYUS_SASL
+#undef HAVE_CYRUS_SASL
 
 /* define if you actually have FreeBSD fetch(3) */
 #undef HAVE_FETCH
index 8285e58ea67483d33e99a2c4dcdd0b13a95aab42..8106d61dcddb0541edfec75eac941b90bd452570 100644 (file)
@@ -11,7 +11,7 @@ SRCS  = main.c daemon.c connection.c search.c filter.c add.c charray.c \
                phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
                repl.c lock.c controls.c extended.c \
                schema.c schemaparse.c monitor.c configinfo.c \
-               root_dse.c module.c suffixalias.c
+               root_dse.c sasl.c module.c suffixalias.c
 OBJS   = main.o daemon.o connection.o search.o filter.o add.o charray.o \
                attr.o entry.o config.o backend.o result.o operation.o \
                dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
@@ -19,7 +19,7 @@ OBJS  = main.o daemon.o connection.o search.o filter.o add.o charray.o \
                phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
                repl.o lock.o controls.o extended.o \
                schema.o schemaparse.o monitor.o configinfo.o \
-               root_dse.o module.o suffixalias.o
+               root_dse.o sasl.o module.o suffixalias.o
 
 LDAP_INCDIR= ../../include
 LDAP_LIBDIR= ../../libraries
index bbd2f9d5fd73f1b44ccb2df5b75828a115e829e0..7094b6a71f74abefb45df225c9a701f26241d791 100644 (file)
 
 #include "slap.h"
 
-char *supportedSASLMechanisms[] = {
-       "X-DIGEST-MD5",
-       NULL
-};
+char **supportedSASLMechanisms = NULL;
 
 int
 do_bind(
index 473927dcaf2cb6cd212c3c37eaebbdfcbcfcb6b3..ea41602032272a856d3688c9c5173565a36f16b7 100644 (file)
@@ -243,7 +243,7 @@ int load_module LDAP_P(( const char* file_name, int argc, char *argv[] ));
  */
 extern char *supportedExtensions[];
 extern char *supportedControls[];
-extern char *supportedSASLMechanisms[];
+extern char **supportedSASLMechanisms;
 
 void monitor_info LDAP_P((
        Connection *conn,
index 361f7bc4e34fd9d0ab0e961afb8560df256ddb78..13e7a9258a1c018abca4519a37cad61954767eb0 100644 (file)
@@ -88,10 +88,12 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
        }
 
        /* supportedSASLMechanism */
-       for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
-               val.bv_val = supportedSASLMechanisms[i];
-               val.bv_len = strlen( val.bv_val );
-               attr_merge( e, "supportedSASLMechanisms", vals );
+       if( supportedSASLMechanisms != NULL ) {
+               for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
+                       val.bv_val = supportedSASLMechanisms[i];
+                       val.bv_len = strlen( val.bv_val );
+                       attr_merge( e, "supportedSASLMechanisms", vals );
+               }
        }
 
        if ( default_referral != NULL ) {
diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c
new file mode 100644 (file)
index 0000000..b2cf4fc
--- /dev/null
@@ -0,0 +1,93 @@
+#include "portable.h"
+
+#ifdef HAVE_CYRUS_SASL
+
+#include <stdio.h>
+
+#include "slap.h"
+#include "proto-slap.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
+
+#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;
+
+       rc = sasl_server_init( NULL, "slapd" );
+
+       if( rc != SASL_OK ) {
+               Debug( LDAP_DEBUG_ANY, "sasl_server_init failed\n",
+                       0, 0, 0 );
+               exit(-1);
+       }
+
+       rc = sasl_server_new( "ldap", NULL, NULL, NULL,
+               SASL_SECURITY_LAYER, 
+               &server );
+
+       if( rc != SASL_OK ) {
+               Debug( LDAP_DEBUG_ANY, "sasl_server_new failed\n",
+                       0, 0, 0 );
+               exit(-1);
+       }
+
+       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 );
+
+       if( rc != SASL_OK ) {
+               Debug( LDAP_DEBUG_ANY, "sasl_setprop failed\n",
+                       0, 0, 0 );
+               exit(-1);
+       }
+
+       rc = sasl_listmech( server, NULL, NULL, ",", NULL,
+               &data, &len, &count);
+
+       if( rc != SASL_OK ) {
+               Debug( LDAP_DEBUG_ANY, "sasl_listmech failed: %d\n",
+                       rc, 0, 0 );
+               exit(-1);
+       }
+
+       Debug( LDAP_DEBUG_TRACE, "SASL mechanisms: %s\n",
+               data, 0, 0 );
+
+       return 0;
+}
+
+int sasl_destory( void )
+{
+       if( server != NULL ) {
+               sasl_dispose( &server );
+       }
+}
+
+#ifdef MAIN
+int main( int argc, char* argv[] )
+{
+       int rc = sasl_init();
+
+       sasl_destory();
+
+       exit(rc);
+}
+#endif
+#endif