same for objectClass; improve previous commit

This commit is contained in:
Pierangelo Masarati 2005-04-10 15:40:15 +00:00
parent fa4b1c69d7
commit 3546934005
4 changed files with 77 additions and 7 deletions

View File

@ -335,6 +335,7 @@ at_insert(
*err = sat->sat_oid;
old_sat = at_bvfind( &air->air_name );
assert( old_sat != NULL );
rc = at_check_dup( old_sat, sat );
ldap_memfree( air );
@ -362,6 +363,7 @@ at_insert(
*err = *names;
old_sat = at_bvfind( &air->air_name );
assert( old_sat != NULL );
rc = at_check_dup( old_sat, sat );
ldap_memfree(air);

View File

@ -396,6 +396,57 @@ oc_destroy( void )
}
}
/*
* check whether the two ObjectClasses actually __are__ identical,
* or rather inconsistent
*/
static int
oc_check_dup(
ObjectClass *soc,
ObjectClass *new_soc )
{
if ( new_soc->soc_oid != NULL ) {
if ( soc->soc_oid == NULL ) {
return SLAP_SCHERR_CLASS_INCONSISTENT;
}
if ( strcmp( soc->soc_oid, new_soc->soc_oid ) != 0 ) {
return SLAP_SCHERR_CLASS_INCONSISTENT;
}
} else {
if ( soc->soc_oid != NULL ) {
return SLAP_SCHERR_CLASS_INCONSISTENT;
}
}
if ( new_soc->soc_names ) {
int i;
if ( soc->soc_names == NULL ) {
return SLAP_SCHERR_CLASS_INCONSISTENT;
}
for ( i = 0; new_soc->soc_names[ i ]; i++ ) {
if ( soc->soc_names[ i ] == NULL ) {
return SLAP_SCHERR_CLASS_INCONSISTENT;
}
if ( strcasecmp( soc->soc_names[ i ],
new_soc->soc_names[ i ] ) != 0 )
{
return SLAP_SCHERR_CLASS_INCONSISTENT;
}
}
} else {
if ( soc->soc_names != NULL ) {
return SLAP_SCHERR_CLASS_INCONSISTENT;
}
}
return SLAP_SCHERR_CLASS_DUP;
}
static int
oc_insert(
ObjectClass *soc,
@ -417,13 +468,21 @@ oc_insert(
if ( avl_insert( &oc_index, (caddr_t) oir,
oc_index_cmp, avl_dup_error ) )
{
ObjectClass *old_soc;
int rc;
*err = soc->soc_oid;
ldap_memfree(oir);
return SLAP_SCHERR_CLASS_DUP;
old_soc = oc_bvfind( &oir->oir_name );
assert( old_soc != NULL );
rc = oc_check_dup( old_soc, soc );
ldap_memfree( oir );
return rc;
}
/* FIX: temporal consistency check */
assert( oc_bvfind(&oir->oir_name) != NULL );
assert( oc_bvfind( &oir->oir_name ) != NULL );
}
if ( (names = soc->soc_names) ) {
@ -440,9 +499,17 @@ oc_insert(
if ( avl_insert( &oc_index, (caddr_t) oir,
oc_index_cmp, avl_dup_error ) )
{
ObjectClass *old_soc;
int rc;
*err = *names;
ldap_memfree(oir);
return SLAP_SCHERR_CLASS_DUP;
old_soc = oc_bvfind( &oir->oir_name );
assert( old_soc != NULL );
rc = oc_check_dup( old_soc, soc );
ldap_memfree( oir );
return rc;
}
/* FIX: temporal consistency check */
@ -453,7 +520,6 @@ oc_insert(
}
LDAP_STAILQ_INSERT_TAIL( &oc_list, soc, soc_next );
return 0;
}

View File

@ -37,13 +37,14 @@ static char *const err2text[] = {
"user-defined ObjectClass includes operational attributes",
"user-defined ObjectClass has inappropriate SUPerior",
"Duplicate objectClass",
"Inconsistent duplicate objectClass",
"AttributeType not found",
"AttributeType inappropriate matching rule",
"AttributeType inappropriate USAGE",
"AttributeType inappropriate SUPerior",
"AttributeType SYNTAX or SUPerior required",
"Duplicate attributeType",
"Inconsistent attributeType",
"Inconsistent duplicate attributeType",
"MatchingRule not found",
"MatchingRule incomplete",
"Duplicate matchingRule",

View File

@ -285,6 +285,7 @@ enum {
SLAP_SCHERR_CLASS_BAD_USAGE,
SLAP_SCHERR_CLASS_BAD_SUP,
SLAP_SCHERR_CLASS_DUP,
SLAP_SCHERR_CLASS_INCONSISTENT,
SLAP_SCHERR_ATTR_NOT_FOUND,
SLAP_SCHERR_ATTR_BAD_MR,
SLAP_SCHERR_ATTR_BAD_USAGE,