]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/compare.c
Unify use of BDB lockers
[openldap] / servers / slapd / back-bdb / compare.c
index 9565a3ab62e2e492e747a955a2c4b21413676fc7..4999ec7d46ee53213c72a94bced5c0eed0a9dd1f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2005 The OpenLDAP Foundation.
+ * Copyright 2000-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,8 @@ bdb_compare( Operation *op, SlapReply *rs )
 
 dn2entry_retry:
        /* get entry */
-       rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1, locker, &lock );
+       rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1,
+               locker, &lock );
 
        switch( rs->sr_err ) {
        case DB_NOTFOUND:
@@ -65,17 +66,13 @@ dn2entry_retry:
        e = ei->bei_e;
        if ( rs->sr_err == DB_NOTFOUND ) {
                if ( e != NULL ) {
-#ifdef SLAP_ACL_HONOR_DISCLOSE
-                       /* return referral only if "disclose"
-                        * is granted on the object */
+                       /* return referral only if "disclose" is granted on the object */
                        if ( ! access_allowed( op, e, slap_schema.si_ad_entry,
-                                               NULL, ACL_DISCLOSE, NULL ) )
+                               NULL, ACL_DISCLOSE, NULL ) )
                        {
                                rs->sr_err = LDAP_NO_SUCH_OBJECT;
 
-                       } else
-#endif /* SLAP_ACL_HONOR_DISCLOSE */
-                       {
+                       } else {
                                rs->sr_matched = ch_strdup( e->e_dn );
                                rs->sr_ref = is_entry_referral( e )
                                        ? get_entry_referrals( op, e )
@@ -83,7 +80,7 @@ dn2entry_retry:
                                rs->sr_err = LDAP_REFERRAL;
                        }
 
-                       bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
+                       bdb_cache_return_entry_r( bdb, e, &lock );
                        e = NULL;
 
                } else {
@@ -103,24 +100,19 @@ dn2entry_retry:
        }
 
        if (!manageDSAit && is_entry_referral( e ) ) {
-#ifdef SLAP_ACL_HONOR_DISCLOSE
-               /* return referral only if "disclose"
-                * is granted on the object */
+               /* return referral only if "disclose" is granted on the object */
                if ( !access_allowed( op, e, slap_schema.si_ad_entry,
-                                       NULL, ACL_DISCLOSE, NULL ) )
+                       NULL, ACL_DISCLOSE, NULL ) )
                {
                        rs->sr_err = LDAP_NO_SUCH_OBJECT;
-               } else
-#endif /* SLAP_ACL_HONOR_DISCLOSE */
-               {
+               } else {
                        /* entry is a referral, don't allow compare */
                        rs->sr_ref = get_entry_referrals( op, e );
                        rs->sr_err = LDAP_REFERRAL;
                        rs->sr_matched = e->e_name.bv_val;
                }
 
-               Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
-                       0, 0 );
+               Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 );
 
                send_ldap_result( op, rs );
 
@@ -133,23 +125,26 @@ dn2entry_retry:
        if ( get_assert( op ) &&
                ( test_filter( op, e, get_assertion( op )) != LDAP_COMPARE_TRUE ))
        {
-               rs->sr_err = LDAP_ASSERTION_FAILED;
+               if ( !access_allowed( op, e, slap_schema.si_ad_entry,
+                       NULL, ACL_DISCLOSE, NULL ) )
+               {
+                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
+               } else {
+                       rs->sr_err = LDAP_ASSERTION_FAILED;
+               }
                goto return_results;
        }
 
        if ( !access_allowed( op, e, op->oq_compare.rs_ava->aa_desc,
                &op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL ) )
        {
-#ifdef SLAP_ACL_HONOR_DISCLOSE
                /* return error only if "disclose"
                 * is granted on the object */
                if ( !access_allowed( op, e, slap_schema.si_ad_entry,
                                        NULL, ACL_DISCLOSE, NULL ) )
                {
                        rs->sr_err = LDAP_NO_SUCH_OBJECT;
-               } else
-#endif /* SLAP_ACL_HONOR_DISCLOSE */
-               {
+               } else {
                        rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
                }
                goto return_results;
@@ -166,7 +161,8 @@ dn2entry_retry:
                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 )
+                       a->a_nvals, &op->oq_compare.rs_ava->aa_value,
+                       op->o_tmpmemctx ) == 0 )
                {
                        rs->sr_err = LDAP_COMPARE_TRUE;
                        break;
@@ -186,11 +182,9 @@ return_results:
 done:
        /* free entry */
        if ( e != NULL ) {
-               bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache,
-                               e, &lock );
+               bdb_cache_return_entry_r( bdb, e, &lock );
        }
 
        LOCK_ID_FREE ( bdb->bi_dbenv, locker );
-
        return rs->sr_err;
 }