X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fsasl.c;h=b2e40a05b822ad8ca92e2b684040bdce4dd57931;hb=a5ee438c9394a19a241716d3d922299c20b0365d;hp=fe640ff877020c0c60eb8e1120dc775e21950a06;hpb=f224e695583793b1af770d7b7342bee29917bf7e;p=openldap diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index fe640ff877..b2e40a05b8 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -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 ) {