]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/refint.c
More accesslog updates
[openldap] / servers / slapd / overlays / refint.c
index 490520b1e164a236ff379a0a7f7d7bf3a18149b4..a233fec070d1f7f77449f47df535ea16861bd014 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004 The OpenLDAP Foundation.
+ * Copyright 2004-2005 The OpenLDAP Foundation.
  * Portions Copyright 2004 Symas Corporation.
  * All rights reserved.
  *
@@ -80,7 +80,7 @@ refint_db_init(
 {
        slap_overinst *on = (slap_overinst *)be->bd_info;
        refint_data *id = ch_malloc(sizeof(refint_data));
-       refint_attrs *ip;
+
        id->message = "_init";
        id->attrs = NULL;
        id->newdn.bv_val = NULL;
@@ -242,9 +242,9 @@ refint_delete_cb(
 {
        Attribute *a;
        BerVarray b = NULL;
-       refint_data *id, *dd = op->o_callback->sc_private;
+       refint_data *dd = op->o_callback->sc_private;
        refint_attrs *ia, *da = dd->attrs;
-       dependent_data *ip, *dp = NULL;
+       dependent_data *ip;
        Modifications *mp, *ma;
        int i;
 
@@ -291,6 +291,7 @@ refint_delete_cb(
                                mp->sml_values[1].bv_val = mp->sml_nvalues[1].bv_val = NULL;
 
                                mp->sml_op = LDAP_MOD_ADD;
+                               mp->sml_flags = 0;
                                ber_dupbv(&mp->sml_values[0],  &dd->nothing);
                                ber_dupbv(&mp->sml_nvalues[0], &dd->nnothing);
                                mp->sml_next = ma;
@@ -305,6 +306,7 @@ refint_delete_cb(
                        mp->sml_values[1].bv_len = mp->sml_nvalues[1].bv_len = 0;
                        mp->sml_values[1].bv_val = mp->sml_nvalues[1].bv_val = NULL;
                        mp->sml_op = LDAP_MOD_DELETE;
+                       mp->sml_flags = 0;
                        ber_dupbv(&mp->sml_values[0], &dd->dn);
                        ber_dupbv(&mp->sml_nvalues[0], &mp->sml_values[0]);
                        mp->sml_next = ma;
@@ -349,11 +351,11 @@ refint_modrdn_cb(
 {
        Attribute *a;
        BerVarray b = NULL;
-       refint_data *id, *dd = op->o_callback->sc_private;
+       refint_data *dd = op->o_callback->sc_private;
        refint_attrs *ia, *da = dd->attrs;
-       dependent_data *ip = NULL, *dp = NULL;
+       dependent_data *ip = NULL;
        Modifications *mp;
-       int i, j, fix;
+       int i, fix;
 
        Debug(LDAP_DEBUG_TRACE, "refint_modrdn_cb <%s>\n",
                rs->sr_entry ? rs->sr_entry->e_name.bv_val : "NOTHING", 0, 0);
@@ -389,6 +391,7 @@ refint_modrdn_cb(
                        }
                        mp = ch_malloc(sizeof(Modifications));
                        mp->sml_op = LDAP_MOD_ADD;
+                       mp->sml_flags = 0;
                        mp->sml_desc = ia->attr;                /* XXX */
                        mp->sml_type = ia->attr->ad_cname;
                        mp->sml_values  = ch_malloc(2 * sizeof(BerValue));
@@ -401,6 +404,7 @@ refint_modrdn_cb(
                        ip->mm = mp;
                        mp = ch_malloc(sizeof(Modifications));
                        mp->sml_op = LDAP_MOD_DELETE;
+                       mp->sml_flags = 0;
                        mp->sml_desc = ia->attr;                /* XXX */
                        mp->sml_type = ia->attr->ad_cname;
                        mp->sml_values  = ch_malloc(2 * sizeof(BerValue));
@@ -446,11 +450,9 @@ refint_response(
        refint_data dd = *id;
        refint_attrs *ip;
        dependent_data *dp;
-       char *fstr, *key, *kp, **dnpp, **ndnpp, *cp;
-       BerValue ndn, moddn, pdn;
-       BerVarray b = NULL;
-       int rc, ac, i, j, ksize;
-       AttributeName   an[2];
+       BerValue pdn;
+       int rc, ac;
+       Filter ftop, *fptr;
 
        id->message = "_refint_response";
 
@@ -520,7 +522,6 @@ refint_response(
        }
 
        /*
-       ** calculate the search key size and allocate it;
        ** build a search filter for all configured attributes;
        ** populate our Operation;
        ** pass our data (attr list, dn) to backend via sc_private;
@@ -530,18 +531,20 @@ refint_response(
        **
        */
 
-       for(ksize = 16, ip = id->attrs; ip; ip = ip->next)
-               ksize += ip->attr->ad_cname.bv_len + op->o_req_dn.bv_len + 3;
-       kp = key = ch_malloc(ksize);
-       if(--ac) kp += sprintf(key, "(|");
-       for(ip = id->attrs; ip; ip = ip->next)
-               kp += sprintf(kp, "(%s=%s)",
-                       ip->attr->ad_cname.bv_val, op->o_req_dn.bv_val);
-       if(ac) *kp++ = ')';
-       *kp = 0;
-
-       nop.ors_filter = str2filter_x(&nop, key);
-       ber_str2bv(key, 0, 0, &nop.ors_filterstr);
+       ftop.f_choice = LDAP_FILTER_OR;
+       ftop.f_next = NULL;
+       ftop.f_or = NULL;
+       nop.ors_filter = &ftop;
+       for(ip = id->attrs; ip; ip = ip->next) {
+               fptr = ch_malloc( sizeof(Filter) + sizeof(AttributeAssertion) );
+               fptr->f_choice = LDAP_FILTER_EQUALITY;
+               fptr->f_ava = (AttributeAssertion *)(fptr+1);
+               fptr->f_ava->aa_desc = ip->attr;
+               fptr->f_ava->aa_value = op->o_req_ndn;
+               fptr->f_next = ftop.f_or;
+               ftop.f_or = fptr;
+       }
+       filter2bv( nop.ors_filter, &nop.ors_filterstr );
 
        /* callback gets the searched dn instead */
        dd.dn = op->o_req_ndn;
@@ -552,14 +555,13 @@ refint_response(
        nop.o_tag       = LDAP_REQ_SEARCH;
        nop.ors_scope   = LDAP_SCOPE_SUBTREE;
        nop.ors_deref   = LDAP_DEREF_NEVER;
+       nop.ors_limit   = NULL;
        nop.ors_slimit  = SLAP_NO_LIMIT;
        nop.ors_tlimit  = SLAP_NO_LIMIT;
 
        /* no attrs! */
-       memset( &an[0], 0, sizeof( AttributeName ) );
-       BER_BVSTR( &an[0].an_name, LDAP_NO_ATTRS );
-       BER_BVZERO( &an[1].an_name );
-       nop.ors_attrs = an;
+       nop.ors_attrs = slap_anlist_no_attrs;
+       nop.ors_attrsonly = 1;
 
        nop.o_req_ndn = id->dn;
        nop.o_req_dn = id->dn;
@@ -567,8 +569,11 @@ refint_response(
        /* search */
        rc = nop.o_bd->be_search(&nop, &nrs);
 
-       filter_free_x(&nop, nop.ors_filter);
-       ch_free(key);
+       ch_free( nop.ors_filterstr.bv_val );
+       while ( fptr = ftop.f_or ) {
+               ftop.f_or = fptr->f_next;
+               ch_free( fptr );
+       }
        ch_free(dd.nnewdn.bv_val);
        ch_free(dd.newdn.bv_val);
        dd.newdn.bv_val = NULL;
@@ -633,7 +638,7 @@ refint_response(
                nop.o_dn = refint_dn;
                nop.o_ndn = refint_dn;
                rs->sr_err = slap_mods_opattrs( &nop, nop.orm_modlist,
-                       tail, &rs->sr_text, NULL, 0 );
+                       tail, &rs->sr_text, NULL, 0, 1 );
                nop.o_dn = nop.o_bd->be_rootdn;
                nop.o_ndn = nop.o_bd->be_rootndn;
                if(rs->sr_err != LDAP_SUCCESS) goto done;