X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldbm%2Fcompare.c;h=43465aacf3a2a6cb0b3eba1fd6425fa8aa99de38;hb=3917d2b15dad2220e1263af60c742bf93884c986;hp=3316645de5f96d10ca8464271c9361626d0f5c38;hpb=f52cc9bab51e427afa3ed5d28be012d8da27a7a8;p=openldap
diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c
index 3316645de5..43465aacf3 100644
--- a/servers/slapd/back-ldbm/compare.c
+++ b/servers/slapd/back-ldbm/compare.c
@@ -1,8 +1,17 @@
/* compare.c - ldbm backend compare routine */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2004 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
*/
#include "portable.h"
@@ -18,102 +27,104 @@
int
ldbm_back_compare(
- Backend *be,
- Connection *conn,
- Operation *op,
- struct berval *dn,
- struct berval *ndn,
- AttributeAssertion *ava
-)
+ Operation *op,
+ SlapReply *rs )
{
- struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
Entry *matched;
Entry *e;
Attribute *a;
- int rc;
int manageDSAit = get_manageDSAit( op );
- /* get entry with reader lock */
- if ( (e = dn2entry_r( be, ndn, &matched )) == NULL ) {
- char *matched_dn = NULL;
- BVarray refs = NULL;
+ /* grab giant lock for reading */
+ ldap_pvt_thread_rdwr_rlock(&li->li_giant_rwlock);
+ /* get entry with reader lock */
+ if ( (e = dn2entry_r( op->o_bd, &op->o_req_ndn, &matched )) == NULL ) {
if ( matched != NULL ) {
- matched_dn = ch_strdup( matched->e_dn );
- refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
+ rs->sr_matched = ch_strdup( matched->e_dn );
+ rs->sr_ref = is_entry_referral( matched )
+ ? get_entry_referrals( op, matched )
: NULL;
cache_return_entry_r( &li->li_cache, matched );
} else {
- refs = referral_rewrite( default_referral,
- NULL, dn, LDAP_SCOPE_DEFAULT );
+ rs->sr_ref = referral_rewrite( default_referral,
+ NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
}
- send_ldap_result( conn, op, LDAP_REFERRAL,
- matched_dn, NULL, refs, NULL );
+ ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock);
- if ( refs ) bvarray_free( refs );
- free( matched_dn );
+ rs->sr_err = LDAP_REFERRAL;
+ send_ldap_result( op, rs );
+ if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
+ free( (char *)rs->sr_matched );
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
return( 1 );
}
if (!manageDSAit && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
- BVarray refs = get_entry_referrals( be,
- conn, op, e );
+ rs->sr_ref = get_entry_referrals( op, e );
#ifdef NEW_LOGGING
- LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
- "ldbm_back_compare: entry (%s) is a referral.\n", e->e_dn ));
+ LDAP_LOG( BACK_LDBM, INFO,
+ "ldbm_back_compare: entry (%s) is a referral.\n", e->e_dn, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
0, 0 );
#endif
- send_ldap_result( conn, op, LDAP_REFERRAL,
- e->e_dn, NULL, refs, NULL );
-
- if (refs ) bvarray_free( refs );
+ rs->sr_err = LDAP_REFERRAL;
+ rs->sr_matched = e->e_name.bv_val;
+ send_ldap_result( op, rs );
- rc = 1;
+ if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
+ rs->sr_err = 1;
goto return_results;
}
- if ( ! access_allowed( be, conn, op, e,
- ava->aa_desc, &ava->aa_value, ACL_COMPARE ) )
+ if ( ! access_allowed( op, e,
+ op->oq_compare.rs_ava->aa_desc, &op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL ) )
{
- send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
- NULL, NULL, NULL, NULL );
- rc = 1;
+ send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS,
+ NULL );
+ rs->sr_err = 1;
goto return_results;
}
- rc = LDAP_NO_SUCH_ATTRIBUTE;
+ rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE;
- for(a = attrs_find( e->e_attrs, ava->aa_desc );
+ for(a = attrs_find( e->e_attrs, op->oq_compare.rs_ava->aa_desc );
a != NULL;
- a = attrs_find( a->a_next, ava->aa_desc ))
+ a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc ))
{
- rc = LDAP_COMPARE_FALSE;
-
- if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
- rc = LDAP_COMPARE_TRUE;
+ rs->sr_err = LDAP_COMPARE_FALSE;
+
+ if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
+ SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
+ SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
+ a->a_nvals, &op->oq_compare.rs_ava->aa_value,
+ op->o_tmpmemctx ) == 0 )
+ {
+ rs->sr_err = LDAP_COMPARE_TRUE;
break;
}
-
}
- send_ldap_result( conn, op, rc,
- NULL, NULL, NULL, NULL );
+ send_ldap_result( op, rs );
- if( rc != LDAP_NO_SUCH_ATTRIBUTE ) {
- rc = 0;
+ if( rs->sr_err != LDAP_NO_SUCH_ATTRIBUTE ) {
+ rs->sr_err = 0;
}
return_results:;
cache_return_entry_r( &li->li_cache, e );
- return( rc );
+ ldap_pvt_thread_rdwr_runlock(&li->li_giant_rwlock);
+ return( rs->sr_err );
}