X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslapd%2Foc.c;h=2d7c6ce097274af7dd4b5327a207e25eab7ddd23;hb=925714ceeff035c596ad3d3c899ff631986c6757;hp=c2ba69013df2c18d05162c54a4d27a1fecd2466a;hpb=58a72b915a265e25f3542eac4871e417c4612c60;p=openldap diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index c2ba69013d..2d7c6ce097 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -17,28 +17,34 @@ #include "ldap_pvt.h" int is_object_subclass( - ObjectClass *sub, - ObjectClass *sup ) + ObjectClass *sup, + ObjectClass *sub ) { int i; if( sub == NULL || sup == NULL ) return 0; -#if 0 +#if 1 +#ifdef NEW_LOGGING + LDAP_LOG ( OPERATION, ARGS, + "is_object_subclass(%s,%s) %d\n", + sup->soc_oid, sub->soc_oid, sup == sub ); +#else Debug( LDAP_DEBUG_TRACE, "is_object_subclass(%s,%s) %d\n", - sub->soc_oid, sup->soc_oid, sup == sub ); + sup->soc_oid, sub->soc_oid, sup == sub ); +#endif #endif if( sup == sub ) { return 1; } - if( sup->soc_sups == NULL ) { + if( sub->soc_sups == NULL ) { return 0; } - for( i=0; sup->soc_sups[i] != NULL; i++ ) { - if( is_object_subclass( sub, sup->soc_sups[i] ) ) { + for( i=0; sub->soc_sups[i] != NULL; i++ ) { + if( is_object_subclass( sup, sub->soc_sups[i] ) ) { return 1; } } @@ -48,7 +54,8 @@ int is_object_subclass( int is_entry_objectclass( Entry* e, - ObjectClass *oc ) + ObjectClass *oc, + int set_flags ) { Attribute *attr; struct berval *bv; @@ -59,6 +66,10 @@ int is_entry_objectclass( return 0; } + if( set_flags && ( e->e_ocflags & SLAP_OC__END )) { + return (e->e_ocflags & oc->soc_flags) ? 1 : 0; + } + /* * find objectClass attribute */ @@ -67,10 +78,10 @@ int is_entry_objectclass( if( attr == NULL ) { /* no objectClass attribute */ #ifdef NEW_LOGGING - LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "is_entry_objectclass: " - "dn(%s), oid (%s), no objectClass attribute.\n", - e->e_dn == NULL ? "" : e->e_dn, - oc->soc_oclass.oc_oid )); + LDAP_LOG( OPERATION, ERR, + "is_entry_objectclass: dn(%s), oid (%s), no objectClass " + "attribute.\n", e->e_dn == NULL ? "" : e->e_dn, + oc->soc_oclass.oc_oid, 0 ); #else Debug( LDAP_DEBUG_ANY, "is_entry_objectclass(\"%s\", \"%s\") " "no objectClass attribute\n", @@ -84,13 +95,17 @@ int is_entry_objectclass( for( bv=attr->a_vals; bv->bv_val; bv++ ) { ObjectClass *objectClass = oc_bvfind( bv ); - if( objectClass == oc ) { + if ( objectClass == oc && !set_flags ) { return 1; } + + if ( objectClass != NULL ) { + e->e_ocflags |= objectClass->soc_flags; + } } + e->e_ocflags |= SLAP_OC__END; /* We've finished this */ - return 0; - + return (e->e_ocflags & oc->soc_flags); } @@ -154,6 +169,7 @@ static int oc_create_required( ObjectClass *soc, char **attrs, + int *op, const char **err ) { char **attrs1; @@ -169,6 +185,9 @@ oc_create_required( *err = *attrs1; return SLAP_SCHERR_ATTR_NOT_FOUND; } + + if( is_at_operational( sat )) (*op)++; + if ( at_find_in_list(sat, soc->soc_required) < 0) { if ( at_append_to_list(sat, &soc->soc_required) ) { *err = *attrs1; @@ -192,6 +211,7 @@ static int oc_create_allowed( ObjectClass *soc, char **attrs, + int *op, const char **err ) { char **attrs1; @@ -205,6 +225,9 @@ oc_create_allowed( *err = *attrs1; return SLAP_SCHERR_ATTR_NOT_FOUND; } + + if( is_at_operational( sat )) (*op)++; + if ( at_find_in_list(sat, soc->soc_required) < 0 && at_find_in_list(sat, soc->soc_allowed) < 0 ) { if ( at_append_to_list(sat, &soc->soc_allowed) ) { @@ -222,6 +245,7 @@ static int oc_add_sups( ObjectClass *soc, char **sups, + int *op, const char **err ) { int code; @@ -265,16 +289,19 @@ oc_add_sups( return SLAP_SCHERR_CLASS_BAD_USAGE; } - if ( add_sups ) + if( soc->soc_flags & SLAP_OC_OPERATIONAL ) (*op)++; + + if ( add_sups ) { soc->soc_sups[nsups] = soc1; + } - code = oc_add_sups( soc, soc1->soc_sup_oids, err ); + code = oc_add_sups( soc, soc1->soc_sup_oids, op, err ); if ( code ) return code; - code = oc_create_required( soc, soc1->soc_at_oids_must, err ); + code = oc_create_required( soc, soc1->soc_at_oids_must, op, err ); if ( code ) return code; - code = oc_create_allowed( soc, soc1->soc_at_oids_may, err ); + code = oc_create_allowed( soc, soc1->soc_at_oids_may, op, err ); if ( code ) return code; nsups++; @@ -333,7 +360,7 @@ oc_insert( { *err = soc->soc_oid; ldap_memfree(oir); - return SLAP_SCHERR_DUP_CLASS; + return SLAP_SCHERR_CLASS_DUP; } /* FIX: temporal consistency check */ @@ -357,7 +384,7 @@ oc_insert( { *err = *names; ldap_memfree(oir); - return SLAP_SCHERR_DUP_CLASS; + return SLAP_SCHERR_CLASS_DUP; } /* FIX: temporal consistency check */ @@ -373,11 +400,13 @@ oc_insert( int oc_add( LDAPObjectClass *oc, + int user, const char **err ) { ObjectClass *soc; int code; + int op = 0; if ( oc->oc_names != NULL ) { int i; @@ -410,19 +439,21 @@ oc_add( { /* structural object classes implicitly inherit from 'top' */ static char *top_oids[] = { SLAPD_TOP_OID, NULL }; - code = oc_add_sups( soc, top_oids, err ); + code = oc_add_sups( soc, top_oids, &op, err ); } else { - code = oc_add_sups( soc, soc->soc_sup_oids, err ); + code = oc_add_sups( soc, soc->soc_sup_oids, &op, err ); } if ( code != 0 ) return code; - code = oc_create_required( soc, soc->soc_at_oids_must, err ); + code = oc_create_required( soc, soc->soc_at_oids_must, &op, err ); if ( code != 0 ) return code; - code = oc_create_allowed( soc, soc->soc_at_oids_may, err ); + code = oc_create_allowed( soc, soc->soc_at_oids_may, &op, err ); if ( code != 0 ) return code; + if( user && op ) return SLAP_SCHERR_CLASS_BAD_SUP; + code = oc_insert(soc,err); return code; } @@ -471,6 +502,9 @@ oc_schema_info( Entry *e ) if ( ldap_objectclass2bv( &oc->soc_oclass, vals ) == NULL ) { return -1; } + + if( oc->soc_flags & SLAP_OC_HIDE ) continue; + #if 0 Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n", (long) vals[0].bv_len, vals[0].bv_val, 0 );