]> git.sur5r.net Git - openldap/commitdiff
same for objectClass; improve previous commit
authorPierangelo Masarati <ando@openldap.org>
Sun, 10 Apr 2005 15:40:15 +0000 (15:40 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sun, 10 Apr 2005 15:40:15 +0000 (15:40 +0000)
servers/slapd/at.c
servers/slapd/oc.c
servers/slapd/schemaparse.c
servers/slapd/slap.h

index 75f2e11b8336b80ade121e31233f661c8202188b..784f3974ca736e93ed49097e9952efbdfdebd43f 100644 (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);
index 87f4728e0808969872c9fee42549dac15cfa81cc..cd381f1bf3443d3c69845924aa0cbfc8a32b2e17 100644 (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;
 }
 
index b43874d0590fd34e8429ad0425800537713523ba..d0b0d5b77a26c2721048efe64ddafe25bf20ae79 100644 (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",
index 91f7c1a996f6ddd42ae406ff2ed3525477f652c8..3ab274a426218f3b7b0a6e0bf5230f8f06bc0f23 100644 (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,