]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_check.c
remove dbenv->lock_put() call from transaction-protected operations
[openldap] / servers / slapd / schema_check.c
index 0b6b1ad09ef7d3713cde108227a7143b2a24f7a2..405a47e54801f9fdccd0930b18bc941ded277171 100644 (file)
@@ -30,7 +30,9 @@ static char * oc_check_required(
 
 int
 entry_schema_check( 
-       Entry *e, Attribute *oldattrs,
+       Backend *be,
+       Entry *e,
+       Attribute *oldattrs,
        const char** text,
        char *textbuf, size_t textlen )
 {
@@ -43,21 +45,40 @@ entry_schema_check(
        AttributeDescription *ad_objectClass
                = slap_schema.si_ad_objectClass;
        int extensible = 0;
+       int subentry = is_entry_subentry( e );
+       int collectiveSubentry = 0;
+
+       if( subentry) collectiveSubentry = is_entry_collectiveAttributeSubentry( e );
 
        *text = textbuf;
 
-       /* check single-valued attrs for multiple values */
+       /* misc attribute checks */
        for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
+               const char *type = a->a_desc->ad_cname.bv_val;
+
                /* there should be at least one value */
                assert( a->a_vals );
                assert( a->a_vals[0].bv_val != NULL ); 
 
+               if( a->a_desc->ad_type->sat_check ) {
+                       int rc = (a->a_desc->ad_type->sat_check)(
+                               be, e, a, text, textbuf, textlen );
+                       if( rc != LDAP_SUCCESS ) {
+                               return rc;
+                       }
+               }
+
+               if( !collectiveSubentry && is_at_collective( a->a_desc->ad_type ) ) {
+                       snprintf( textbuf, textlen,
+                               "'%s' can only appear in collectiveAttributeSubentry",
+                               type );
+                       return LDAP_OBJECT_CLASS_VIOLATION;
+               }
+
                /* if single value type, check for multiple values */
                if( is_at_single_value( a->a_desc->ad_type ) &&
                        a->a_vals[1].bv_val != NULL )
                {
-                       char *type = a->a_desc->ad_cname.bv_val;
-
                        snprintf( textbuf, textlen, 
                                "attribute '%s' cannot have multiple values",
                                type );
@@ -142,7 +163,7 @@ entry_schema_check(
        if ( aoc == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
-                       "entry_schema_check: No objectClass for entry (%s).\n"
+                       "entry_schema_check: No objectClass for entry (%s).\n",
                        e->e_dn ));
 #else
                Debug( LDAP_DEBUG_ANY, "No objectClass for entry (%s)\n",
@@ -196,8 +217,17 @@ entry_schema_check(
 #endif
 
                        return LDAP_OBJECT_CLASS_VIOLATION;
+               }
 
-               } else if ( oc->soc_kind == LDAP_SCHEMA_ABSTRACT ) {
+               if ( oc->soc_check ) {
+                       int rc = (oc->soc_check)( be, e, oc,
+                               text, textbuf, textlen );
+                       if( rc != LDAP_SUCCESS ) {
+                               return rc;
+                       }
+               }
+
+               if ( oc->soc_kind == LDAP_SCHEMA_ABSTRACT ) {
                        /* object class is abstract */
                        if ( oc != slap_schema.si_oc_top &&
                                !is_object_subclass( oc, sc ))
@@ -364,7 +394,7 @@ oc_check_required(
 
 int oc_check_allowed(
        AttributeType *at,
-       BVarray ocl,
+       BerVarray ocl,
        ObjectClass *sc )
 {
        int             i, j;
@@ -445,7 +475,7 @@ int oc_check_allowed(
  * Determine the structural object class from a set of OIDs
  */
 int structural_class(
-       BVarray ocs,
+       BerVarray ocs,
        struct berval *scbv,
        ObjectClass **scp,
        const char **text,
@@ -464,7 +494,7 @@ int structural_class(
 
                if( oc == NULL ) {
                        snprintf( textbuf, textlen,
-                               "unrecongized objectClass '%s'",
+                               "unrecognized objectClass '%s'",
                                ocs[i].bv_val );
                        *text = textbuf;
                        return LDAP_OBJECT_CLASS_VIOLATION;
@@ -485,7 +515,7 @@ int structural_class(
 
                                        if( xc == NULL ) {
                                                snprintf( textbuf, textlen,
-                                                       "unrecongized objectClass '%s'",
+                                                       "unrecognized objectClass '%s'",
                                                        ocs[i].bv_val );
                                                *text = textbuf;
                                                return LDAP_OBJECT_CLASS_VIOLATION;