]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/sasl.c
Updated for schemas.
[openldap] / servers / slapd / sasl.c
index fe640ff877020c0c60eb8e1120dc775e21950a06..b2e40a05b822ad8ca92e2b684040bdce4dd57931 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -114,7 +114,7 @@ int sasl_init( void )
        }
 
        if( sasl_host == NULL ) {
-               char hostname[MAXHOSTNAMELEN+1];
+               static char hostname[MAXHOSTNAMELEN+1];
 
                if( gethostname( hostname, MAXHOSTNAMELEN ) == 0 ) {
                        hostname[MAXHOSTNAMELEN] = '\0';
@@ -186,9 +186,9 @@ int sasl_destroy( void )
 int sasl_bind(
     Connection          *conn,
     Operation           *op,  
-    char                *dn,  
-    char                *ndn,
-    char                *mech,
+    const char          *dn,  
+    const char          *ndn,
+    const char          *mech,
     struct berval       *cred,
        char                            **edn )
 {
@@ -197,7 +197,8 @@ int sasl_bind(
        int sc;
        int rc = 1;
 
-       Debug(LDAP_DEBUG_ARGS, "==> sasl_bind: dn=%s, mech=%s, cred->bv_len=%d\n",
+       Debug(LDAP_DEBUG_ARGS,
+               "==> sasl_bind: dn=\"%s\" mech=%s cred->bv_len=%d\n",
                dn, mech, cred ? cred->bv_len : 0 );
 
        if ( conn->c_sasl_bind_context == NULL ) {
@@ -239,18 +240,27 @@ int sasl_bind(
                        send_ldap_result( conn, op, rc = LDAP_AUTH_METHOD_NOT_SUPPORTED,
                                NULL, NULL, NULL, NULL );
                } else {
+                       unsigned reslen;
                        conn->c_authmech = ch_strdup( mech );
+
                        sc = sasl_server_start( conn->c_sasl_bind_context, conn->c_authmech,
-                               cred->bv_val, cred->bv_len, (char **)&response.bv_val,
-                               (unsigned *)&response.bv_len, &errstr );
+                               cred->bv_val, cred->bv_len,
+                               (char **)&response.bv_val, &reslen, &errstr );
+
+                       response.bv_len = reslen;
+                       
                        if ( (sc != SASL_OK) && (sc != SASL_CONTINUE) ) {
                                send_ldap_result( conn, op, rc = slap_sasl_err2ldap( sc ),
                                        NULL, errstr, NULL, NULL );
                        }
                }
        } else {
+               unsigned reslen;
                sc = sasl_server_step( conn->c_sasl_bind_context, cred->bv_val, cred->bv_len,
-                       (char **)&response.bv_val, (unsigned *)&response.bv_len, &errstr );
+                       (char **)&response.bv_val, &reslen, &errstr );
+
+               response.bv_len = reslen;
+       
                if ( (sc != SASL_OK) && (sc != SASL_CONTINUE) ) {
                        send_ldap_result( conn, op, rc = slap_sasl_err2ldap( sc ),
                                NULL, errstr, NULL, NULL );
@@ -303,9 +313,9 @@ int sasl_bind(
 int sasl_bind(
     Connection          *conn,
     Operation           *op,  
-    char                *dn,  
-    char                *ndn,
-    char                *mech,
+    const char          *dn,  
+    const char          *ndn,
+    const char          *mech,
     struct berval       *cred,
        char                            **edn )
 {