]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/constraint.c
ITS#6953 do not use the cache db when refreshing
[openldap] / servers / slapd / overlays / constraint.c
index c514da31a7c583b84dcdb4ed65df621514e52bce..fcb2830ee88cbf2e45d344ba3537fdfac10ee36e 100644 (file)
@@ -541,7 +541,7 @@ constraint_uri_cb( Operation *op, SlapReply *rs )
 }
 
 static int
-constraint_violation( constraint *c, struct berval *bv, Operation *op, SlapReply *rs)
+constraint_violation( constraint *c, struct berval *bv, Operation *op )
 {
        if ((!c) || (!bv)) return LDAP_SUCCESS;
        
@@ -556,19 +556,13 @@ constraint_violation( constraint *c, struct berval *bv, Operation *op, SlapReply
                Operation nop = *op;
                slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
                slap_callback cb;
-               SlapReply nrs = { REP_RESULT };
                int i;
-               int found;
+               int found = 0;
                int rc;
                size_t len;
                struct berval filterstr;
                char *ptr;
 
-               found = 0;
-
-               nrs.sr_entry = NULL;
-               nrs.sr_nentries = 0;
-
                cb.sc_next = NULL;
                cb.sc_response = constraint_uri_cb;
                cb.sc_cleanup = NULL;
@@ -642,8 +636,11 @@ constraint_violation( constraint *c, struct berval *bv, Operation *op, SlapReply
                        Debug( LDAP_DEBUG_ANY,
                                "%s constraint_violation uri filter=\"%s\" invalid\n",
                                op->o_log_prefix, filterstr.bv_val, 0 );
+                       rc = LDAP_OTHER;
 
                } else {
+                       SlapReply nrs = { REP_RESULT };
+
                        Debug(LDAP_DEBUG_TRACE, 
                                "==> constraint_violation uri filter = %s\n",
                                filterstr.bv_val, 0, 0);
@@ -656,13 +653,12 @@ constraint_violation( constraint *c, struct berval *bv, Operation *op, SlapReply
                }
                op->o_tmpfree(filterstr.bv_val, op->o_tmpmemctx);
 
-               if((rc != LDAP_SUCCESS) && (rc != LDAP_NO_SUCH_OBJECT)) {
+               if ((rc != LDAP_SUCCESS) && (rc != LDAP_NO_SUCH_OBJECT)) {
                        return rc; /* unexpected error */
                }
 
                if (!found)
                        return LDAP_CONSTRAINT_VIOLATION; /* constraint violation */
-                       
        }
 
        return LDAP_SUCCESS;
@@ -786,8 +782,8 @@ constraint_add( Operation *op, SlapReply *rs )
 
                        Debug(LDAP_DEBUG_TRACE, 
                                "==> constraint_add, "
-                               "a->a_numvals = %d, cp->count = %d\n",
-                               a->a_numvals, cp->count, 0);
+                               "a->a_numvals = %u, cp->count = %lu\n",
+                               a->a_numvals, (unsigned long) cp->count, 0);
 
                        if ((cp->count != 0) && (a->a_numvals > cp->count)) {
                                rc = LDAP_CONSTRAINT_VIOLATION;
@@ -795,7 +791,7 @@ constraint_add( Operation *op, SlapReply *rs )
                        }
 
                        for ( i = 0; b[i].bv_val; i++ ) {
-                               rc = constraint_violation( cp, &b[i], op, rs );
+                               rc = constraint_violation( cp, &b[i], op );
                                if ( rc ) {
                                        goto add_violation;
                                }
@@ -885,7 +881,7 @@ constraint_update( Operation *op, SlapReply *rs )
 
        rc = LDAP_CONSTRAINT_VIOLATION;
        for(;m; m = m->sml_next) {
-               int ce = 0;
+               unsigned ce = 0;
 
                if (is_at_operational( m->sml_desc->ad_type )) continue;
 
@@ -916,7 +912,7 @@ constraint_update( Operation *op, SlapReply *rs )
                        }
 
                        if (cp->count != 0) {
-                               int ca;
+                               unsigned ca;
 
                                if (m->sml_op == LDAP_MOD_DELETE)
                                        ce = 0;
@@ -924,9 +920,9 @@ constraint_update( Operation *op, SlapReply *rs )
                                for (ca = 0; b[ca].bv_val; ++ca);
 
                                Debug(LDAP_DEBUG_TRACE, 
-                                       "==> constraint_update ce = %d, "
-                                       "ca = %d, cp->count = %d\n",
-                                       ce, ca, cp->count);
+                                       "==> constraint_update ce = %u, "
+                                       "ca = %u, cp->count = %lu\n",
+                                       ce, ca, (unsigned long) cp->count);
 
                                if (m->sml_op == LDAP_MOD_ADD) {
                                        if (ca + ce > cp->count) {
@@ -948,7 +944,7 @@ constraint_update( Operation *op, SlapReply *rs )
                                continue;
 
                        for ( i = 0; b[i].bv_val; i++ ) {
-                               rc = constraint_violation( cp, &b[i], op, rs );
+                               rc = constraint_violation( cp, &b[i], op );
                                if ( rc ) {
                                        goto mod_violation;
                                }
@@ -1026,6 +1022,29 @@ constraint_update( Operation *op, SlapReply *rs )
                                                        }
                                                        break;
 
+                                               case SLAP_MOD_SOFTDEL:
+                                                       mod->sm_op = LDAP_MOD_ADD;
+                                                       err = modify_delete_values( target_entry_copy,
+                                                               mod, get_permissiveModify(op),
+                                                               &text, textbuf, textlen );
+                                                       mod->sm_op = SLAP_MOD_SOFTDEL;
+                                                       if ( err == LDAP_NO_SUCH_ATTRIBUTE ) {
+                                                               err = LDAP_SUCCESS;
+                                                       }
+                                                       break;
+
+                                               case SLAP_MOD_ADD_IF_NOT_PRESENT:
+                                                       if ( attr_find( target_entry_copy->e_attrs, mod->sm_desc ) ) {
+                                                               err = LDAP_SUCCESS;
+                                                               break;
+                                                       }
+                                                       mod->sm_op = LDAP_MOD_ADD;
+                                                       err = modify_add_values( target_entry_copy,
+                                                               mod, get_permissiveModify(op),
+                                                               &text, textbuf, textlen );
+                                                       mod->sm_op = SLAP_MOD_ADD_IF_NOT_PRESENT;
+                                                       break;
+
                                                default:
                                                        err = LDAP_OTHER;
                                                        break;