char *tstr = NULL;
int quotes = 0;
int j;
+ size_t val;
+ char val_buf[SLAP_TEXT_BUFLEN] = { '\0' };
bv.bv_len = STRLENOF(" ");
for (j = 0; cp->ap[j]; j++) {
if (cp->re) {
tstr = REGEX_STR;
+ quotes = 1;
} else if (cp->lud) {
tstr = URI_STR;
quotes = 1;
quotes = 1;
} else if (cp->size) {
tstr = SIZE_STR;
+ val = cp->size;
} else if (cp->count) {
tstr = COUNT_STR;
+ val = cp->count;
}
bv.bv_len += strlen(tstr);
bv.bv_len += cp->restrict_val.bv_len + STRLENOF(" restrict=\"\"");
}
+ if (cp->count || cp->size) {
+ int len = snprintf(val_buf, sizeof(val_buf), "%d", val);
+ if (len <= 0) {
+ /* error */
+ return -1;
+ }
+ bv.bv_len += len;
+ }
+
s = bv.bv_val = ch_malloc(bv.bv_len + 1);
s = lutil_strncopy( s, cp->ap[0]->ad_cname.bv_val, cp->ap[0]->ad_cname.bv_len );
*s++ = ' ';
s = lutil_strcopy( s, tstr );
*s++ = ' ';
- if ( quotes ) *s++ = '"';
- s = lutil_strncopy( s, cp->val.bv_val, cp->val.bv_len );
- if ( quotes ) *s++ = '"';
+ if (cp->count || cp->size) {
+ s = lutil_strcopy( s, val_buf );
+ } else {
+ if ( quotes ) *s++ = '"';
+ s = lutil_strncopy( s, cp->val.bv_val, cp->val.bv_len );
+ if ( quotes ) *s++ = '"';
+ }
if (cp->restrict_lud != NULL) {
s = lutil_strcopy( s, " restrict=\"" );
s = lutil_strncopy( s, cp->restrict_val.bv_val, cp->restrict_val.bv_len );
}
}
- ber_str2bv(c->argv[argidx], 0, 1, &ap.restrict_val);
+ ber_str2bv(c->argv[argidx] + STRLENOF("restrict="), 0, 1, &ap.restrict_val);
} else {
/* cleanup */
}
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;
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;
rc = LDAP_OTHER;
} else {
+ SlapReply nrs = { REP_RESULT };
+
Debug(LDAP_DEBUG_TRACE,
"==> constraint_violation uri filter = %s\n",
filterstr.bv_val, 0, 0);
if (!found)
return LDAP_CONSTRAINT_VIOLATION; /* constraint violation */
-
}
return LDAP_SUCCESS;
}
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;
}
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;
}
}
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;