X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslapd%2Fpasswd.c;h=2c771519453dbd206cbf8dd1c90229359c9e39c4;hb=1adee08e8912c1f47c7b170fe62bebdd9797921f;hp=a722ef9d7c91753e3070ca1c0ef48cfd729a3fe6;hpb=a7f867c233a463f989038a56efb73061e7a8bac2;p=openldap diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index a722ef9d7c..2c77151945 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2007 The OpenLDAP Foundation. + * Copyright 1998-2010 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,6 +57,7 @@ int passwd_extop( int rc; BackendDB *op_be; int freenewpw = 0; + struct berval dn = BER_BVNULL, ndn = BER_BVNULL; assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, &op->ore_reqoid ) == 0 ); @@ -100,19 +101,22 @@ int passwd_extop( } if ( !BER_BVISEMPTY( &id ) ) { - rs->sr_err = dnPrettyNormal( NULL, &id, &op->o_req_dn, - &op->o_req_ndn, op->o_tmpmemctx ); + rs->sr_err = dnPrettyNormal( NULL, &id, &dn, &ndn, op->o_tmpmemctx ); id.bv_val[id.bv_len] = idNul; if ( rs->sr_err != LDAP_SUCCESS ) { rs->sr_text = "Invalid DN"; rc = rs->sr_err; goto error_return; } + op->o_req_dn = dn; + op->o_req_ndn = ndn; op->o_bd = select_backend( &op->o_req_ndn, 1 ); } else { - ber_dupbv_x( &op->o_req_dn, &op->o_dn, op->o_tmpmemctx ); - ber_dupbv_x( &op->o_req_ndn, &op->o_ndn, op->o_tmpmemctx ); + ber_dupbv_x( &dn, &op->o_dn, op->o_tmpmemctx ); + ber_dupbv_x( &ndn, &op->o_ndn, op->o_tmpmemctx ); + op->o_req_dn = dn; + op->o_req_ndn = ndn; ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); op->o_bd = op->o_conn->c_authz_backend; ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex ); @@ -313,12 +317,12 @@ error_return:; if ( freenewpw ) { free( qpw->rs_new.bv_val ); } - if ( !BER_BVISNULL( &op->o_req_dn ) ) { - op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); + if ( !BER_BVISNULL( &dn ) ) { + op->o_tmpfree( dn.bv_val, op->o_tmpmemctx ); BER_BVZERO( &op->o_req_dn ); } - if ( !BER_BVISNULL( &op->o_req_ndn ) ) { - op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); + if ( !BER_BVISNULL( &ndn ) ) { + op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx ); BER_BVZERO( &op->o_req_ndn ); } @@ -503,14 +507,17 @@ slap_passwd_check( int result = 1; struct berval *bv; AccessControlState acl_state = ACL_STATE_INIT; + char credNul = cred->bv_val[cred->bv_len]; #ifdef SLAPD_SPASSWD void *old_authctx = NULL; - ldap_pvt_thread_pool_setkey_x( op->o_threadctx, slap_sasl_bind, - op->o_conn->c_sasl_authctx, NULL, &old_authctx, NULL ); + ldap_pvt_thread_pool_setkey( op->o_threadctx, (void *)slap_sasl_bind, + op->o_conn->c_sasl_authctx, 0, &old_authctx, NULL ); #endif + if ( credNul ) cred->bv_val[cred->bv_len] = 0; + for ( bv = a->a_vals; bv->bv_val != NULL; bv++ ) { /* if e is provided, check access */ if ( e && access_allowed( op, e, a->a_desc, bv, @@ -525,9 +532,11 @@ slap_passwd_check( } } + if ( credNul ) cred->bv_val[cred->bv_len] = credNul; + #ifdef SLAPD_SPASSWD - ldap_pvt_thread_pool_setkey( op->o_threadctx, slap_sasl_bind, - old_authctx, NULL ); + ldap_pvt_thread_pool_setkey( op->o_threadctx, (void *)slap_sasl_bind, + old_authctx, 0, NULL, NULL ); #endif return result;