SLAPD_SCHEMA_NOT_COMPAT: working modify? need additional match

routines, such as distinguishedNameMatch, to be sure.
This commit is contained in:
Kurt Zeilenga 2000-05-28 23:51:39 +00:00
parent 3e3acf87c8
commit 30c43c307c
4 changed files with 59 additions and 20 deletions

View File

@ -290,10 +290,10 @@ attr_delete(
*a = (*a)->a_next;
attr_free( save );
return 0;
return LDAP_SUCCESS;
}
}
return 1;
return LDAP_NO_SUCH_ATTRIBUTE;
}

View File

@ -60,6 +60,8 @@ int ldbm_modify_internal(
err = add_values( e, mod, op->o_ndn );
if( err != LDAP_SUCCESS ) {
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
err, text, 0);
*text = "modify: add values failed";
}
break;
@ -69,6 +71,8 @@ int ldbm_modify_internal(
err = delete_values( e, mod, op->o_ndn );
assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
if( err != LDAP_SUCCESS ) {
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
err, text, 0);
*text = "modify: delete values failed";
}
break;
@ -78,6 +82,8 @@ int ldbm_modify_internal(
err = replace_values( e, mod, op->o_ndn );
assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
if( err != LDAP_SUCCESS ) {
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
err, text, 0);
*text = "modify: replace values failed";
}
break;
@ -95,6 +101,8 @@ int ldbm_modify_internal(
}
if( err != LDAP_SUCCESS ) {
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
err, text, 0);
*text = "modify: (soft)add values failed";
}
break;
@ -104,6 +112,8 @@ int ldbm_modify_internal(
mod->sm_op, 0, 0);
*text = "Invalid modify operation";
err = LDAP_OTHER;
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
err, text, 0);
}
if ( err != LDAP_SUCCESS ) {
@ -331,34 +341,50 @@ add_values(
Attribute *a;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc = mod->sm_desc;
/* char *desc = mod->sm_desc->ad_cname->bv_val; */
MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
if( mr == NULL ) {
return LDAP_INAPPROPRIATE_MATCHING;
}
#else
char *desc = mod->mod_type;
/* char *desc = mod->mod_type; */
#endif
a = attr_find( e->e_attrs, desc );
a = attr_find( e->e_attrs, mod->sm_desc );
/* check if the values we're adding already exist */
if ( a != NULL ) {
for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( value_find( desc, a->a_vals, mod->sm_bvalues[i] ) == 0 )
int j;
for ( j = 0; a->a_vals[j] != NULL; j++ ) {
int match;
const char *text = NULL;
int rc = value_match( &match, mod->sm_desc, mr,
mod->sm_bvalues[i], a->a_vals[j], &text );
if( rc == LDAP_SUCCESS && match == 0 ) {
return LDAP_TYPE_OR_VALUE_EXISTS;
}
}
#else
if ( value_find( a->a_vals, mod->sm_bvalues[i],
a->a_syntax, 3 ) == 0 )
#endif
{
a->a_syntax, 3 ) == 0 ) {
return( LDAP_TYPE_OR_VALUE_EXISTS );
}
#endif
}
}
/* no - add them */
if( attr_merge( e, desc, mod->sm_bvalues ) != 0 ) {
return( LDAP_CONSTRAINT_VIOLATION );
if( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) {
/* this should return result return of attr_merge */
return LDAP_OTHER;
}
return( LDAP_SUCCESS );
return LDAP_SUCCESS;
}
static int
@ -372,6 +398,11 @@ delete_values(
Attribute *a;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
char *desc = mod->sm_desc->ad_cname->bv_val;
MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
if( mr == NULL || !mr->smr_match ) {
return LDAP_INAPPROPRIATE_MATCHING;
}
#else
char *desc = mod->mod_type;
#endif
@ -399,7 +430,7 @@ delete_values(
int match;
const char *text = NULL;
int rc = value_match( &match, mod->sm_desc,
mod->sm_desc->ad_type->sat_equality,
mr,
mod->sm_bvalues[i], a->a_vals[j], &text );
if( rc == LDAP_SUCCESS && match != 0 )
@ -441,7 +472,7 @@ delete_values(
}
}
return( LDAP_SUCCESS );
return LDAP_SUCCESS;
}
static int
@ -451,13 +482,17 @@ replace_values(
char *dn
)
{
(void) attr_delete( &e->e_attrs, mod->sm_desc );
int rc = attr_delete( &e->e_attrs, mod->sm_desc );
if( rc != LDAP_SUCCESS && rc != LDAP_NO_SUCH_ATTRIBUTE ) {
return rc;
}
if ( mod->sm_bvalues != NULL &&
attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 )
{
return( LDAP_CONSTRAINT_VIOLATION );
return LDAP_OTHER;
}
return( LDAP_SUCCESS );
return LDAP_SUCCESS;
}

View File

@ -176,12 +176,16 @@ register_matching_rule(
return( -1 );
}
code = mr_add( mr, usage, convert, normalize, match, indexer, filter, &err );
code = mr_add( mr, usage,
convert, normalize, match, indexer, filter,
&err );
if ( code ) {
Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s for %s in %s\n",
scherr2str(code), err, desc );
return( -1 );
}
return( 0 );
}

View File

@ -48,7 +48,7 @@ value_add(
}
(*vals)[n + j] = NULL;
return( 0 );
return LDAP_SUCCESS;
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
@ -289,7 +289,7 @@ value_find(
#ifdef SLAPD_SCHEMA_NOT_COMPAT
MatchingRule *mr = ad->ad_type->sat_equality;
if( mr == NULL ) {
if( mr == NULL || !mr->smr_match ) {
return LDAP_INAPPROPRIATE_MATCHING;
}
#endif