]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/refint.c
trim listed modules
[openldap] / servers / slapd / overlays / refint.c
index 2b83cef5e14078a000ba09d80bd3ef5b11001061..207b22bde6e4a817908ed6b5db8232859f04c387 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004-2006 The OpenLDAP Foundation.
+ * Copyright 2004-2007 The OpenLDAP Foundation.
  * Portions Copyright 2004 Symas Corporation.
  * All rights reserved.
  *
 
 static slap_overinst refint;
 
+/* The DN to use in the ModifiersName for all refint updates */
+static BerValue refint_dn = BER_BVC("cn=Referential Integrity Overlay");
+static BerValue refint_ndn = BER_BVC("cn=referential integrity overlay");
+
 typedef struct refint_attrs_s {
        struct refint_attrs_s *next;
        AttributeDescription *attr;
@@ -92,6 +96,7 @@ static ConfigTable refintcfg[] = {
          ARG_MAGIC|REFINT_ATTRS, refint_cf_gen,
          "( OLcfgOvAt:11.1 NAME 'olcRefintAttribute' "
          "DESC 'Attributes for referential integrity' "
+         "EQUALITY caseIgnoreMatch "
          "SYNTAX OMsDirectoryString )", NULL, NULL },
        { "refint_nothing", "string", 2, 2, 0,
          ARG_DN|ARG_MAGIC|REFINT_NOTHING, refint_cf_gen,
@@ -204,13 +209,10 @@ refint_cf_gen(ConfigArgs *c)
                                        ip->next = dd->attrs;
                                        dd->attrs = ip;
                                } else {
-                                       Debug ( LDAP_DEBUG_CONFIG,
-                                               "refint add: <%s>: %s\n",
-                                               c->argv[i], text, NULL );
-                                       strncpy ( c->msg,
-                                                 text,
-                                                 SLAP_TEXT_BUFLEN-1 );
-                                       c->msg[SLAP_TEXT_BUFLEN-1] = '\0';
+                                       snprintf( c->msg, sizeof( c->msg ),
+                                               "%s <%s>: %s", c->argv[0], c->argv[i], text );
+                                       Debug ( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+                                               "%s: %s\n", c->log, c->msg, 0 );
                                        rc = ARG_BAD_CONF;
                                }
                        }
@@ -472,6 +474,9 @@ refint_qtask( void *ctx, void *arg )
                op->o_req_ndn = id->dn;
                op->o_req_dn = id->dn;
                op->o_bd = rq->db;
+               op->o_dn = op->o_bd->be_rootdn;
+               op->o_ndn = op->o_bd->be_rootndn;
+               slap_op_time( &op->o_time, &op->o_tincr );
 
                /* search */
                rc = op->o_bd->be_search(op, &rs);
@@ -506,11 +511,11 @@ refint_qtask( void *ctx, void *arg )
                **
                */
 
-               op->orm_modlist = NULL;
-
                for(dp = rq->attrs; dp; dp = dp->next) {
                        Modifications *m, *first = NULL;
 
+                       op->orm_modlist = NULL;
+
                        op->o_req_dn    = dp->dn;
                        op->o_req_ndn   = dp->ndn;
                        op->o_bd = select_backend(&dp->ndn, 0, 1);
@@ -523,6 +528,25 @@ refint_qtask( void *ctx, void *arg )
                        rs.sr_type      = REP_RESULT;
                        for (ra = dp->attrs; ra; ra = dp->attrs) {
                                dp->attrs = ra->next;
+                               /* Set our ModifiersName */
+                               if ( SLAP_LASTMOD( op->o_bd )) {
+                                       m = op->o_tmpalloc( sizeof(Modifications) +
+                                               4*sizeof(BerValue), op->o_tmpmemctx );
+                                       m->sml_next = op->orm_modlist;
+                                       if ( !first )
+                                               first = m;
+                                       op->orm_modlist = m;
+                                       m->sml_op = LDAP_MOD_REPLACE;
+                                       m->sml_flags = SLAP_MOD_INTERNAL;
+                                       m->sml_desc = slap_schema.si_ad_modifiersName;
+                                       m->sml_type = m->sml_desc->ad_cname;
+                                       m->sml_values = (BerVarray)(m+1);
+                                       m->sml_nvalues = m->sml_values+2;
+                                       BER_BVZERO( &m->sml_values[1] );
+                                       BER_BVZERO( &m->sml_nvalues[1] );
+                                       m->sml_values[0] = refint_dn;
+                                       m->sml_nvalues[0] = refint_ndn;
+                               }
                                if ( !BER_BVISEMPTY( &rq->newdn ) || ( ra->next &&
                                        ra->attr == ra->next->attr )) {
                                        m = op->o_tmpalloc( sizeof(Modifications) +
@@ -571,6 +595,7 @@ refint_qtask( void *ctx, void *arg )
 
                        op->o_dn = op->o_bd->be_rootdn;
                        op->o_ndn = op->o_bd->be_rootndn;
+                       slap_op_time( &op->o_time, &op->o_tincr );
                        if((rc = op->o_bd->be_modify(op, &rs)) != LDAP_SUCCESS) {
                                Debug( LDAP_DEBUG_TRACE,
                                        "refint_response: dependent modify failed: %d\n",