From: Pierangelo Masarati Date: Sat, 20 Aug 2005 19:01:53 +0000 (+0000) Subject: allow objectClass checking including sups X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~637 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=00b5d8c1bca8c8163826a6a42989d6e638381e23;p=openldap allow objectClass checking including sups --- diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index a721a35d6f..6af4cbcbcc 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -57,7 +57,7 @@ int is_object_subclass( int is_entry_objectclass( Entry* e, ObjectClass *oc, - int set_flags ) + unsigned flags ) { /* * set_flags should only be true if oc is one of operational @@ -67,15 +67,16 @@ int is_entry_objectclass( Attribute *attr; struct berval *bv; - AttributeDescription *objectClass = slap_schema.si_ad_objectClass; - assert(!( e == NULL || oc == NULL )); + assert( !( e == NULL || oc == NULL ) ); + assert( ( flags & SLAP_OCF_MASK ) != SLAP_OCF_MASK ); if( e == NULL || oc == NULL ) { return 0; } - if( set_flags && ( e->e_ocflags & SLAP_OC__END )) { + if( flags == SLAP_OCF_SET_FLAGS && ( e->e_ocflags & SLAP_OC__END ) ) + { /* flags are set, use them */ return (e->e_ocflags & oc->soc_flags & SLAP_OC__MASK) != 0; } @@ -83,7 +84,7 @@ int is_entry_objectclass( /* * find objectClass attribute */ - attr = attr_find(e->e_attrs, objectClass); + attr = attr_find( e->e_attrs, slap_schema.si_ad_objectClass ); if( attr == NULL ) { /* no objectClass attribute */ Debug( LDAP_DEBUG_ANY, "is_entry_objectclass(\"%s\", \"%s\") " @@ -97,19 +98,30 @@ int is_entry_objectclass( for( bv=attr->a_vals; bv->bv_val; bv++ ) { ObjectClass *objectClass = oc_bvfind( bv ); - if ( !set_flags && objectClass == oc ) { - return 1; + if ( objectClass == NULL ) { + /* FIXME: is this acceptable? */ + continue; } - - if ( objectClass != NULL ) { - e->e_ocflags |= objectClass->soc_flags; + + if ( !( flags & SLAP_OCF_SET_FLAGS ) ) { + if ( objectClass == oc ) { + return 1; + } + + if ( ( flags & SLAP_OCF_CHECK_SUP ) + && is_object_subclass( oc, objectClass ) ) + { + return 1; + } } + + e->e_ocflags |= objectClass->soc_flags; } /* mark flags as set */ e->e_ocflags |= SLAP_OC__END; - return (e->e_ocflags & oc->soc_flags & SLAP_OC__MASK) != 0; + return ( e->e_ocflags & oc->soc_flags & SLAP_OC__MASK ) != 0; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 996cc7fdc9..f98de6a895 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1131,39 +1131,41 @@ LDAP_SLAPD_F (int) is_object_subclass LDAP_P(( ObjectClass *sub )); LDAP_SLAPD_F (int) is_entry_objectclass LDAP_P(( - Entry *, ObjectClass *oc, int set_flags )); + Entry *, ObjectClass *oc, unsigned flags )); +#define is_entry_objectclass_or_sub(e,oc) \ + (is_entry_objectclass((e),(oc),SLAP_OCF_CHECK_SUP)) #define is_entry_alias(e) \ (((e)->e_ocflags & SLAP_OC__END) \ ? (((e)->e_ocflags & SLAP_OC_ALIAS) != 0) \ - : is_entry_objectclass((e), slap_schema.si_oc_alias, 1)) + : is_entry_objectclass((e), slap_schema.si_oc_alias, SLAP_OCF_SET_FLAGS)) #define is_entry_referral(e) \ (((e)->e_ocflags & SLAP_OC__END) \ ? (((e)->e_ocflags & SLAP_OC_REFERRAL) != 0) \ - : is_entry_objectclass((e), slap_schema.si_oc_referral, 1)) + : is_entry_objectclass((e), slap_schema.si_oc_referral, SLAP_OCF_SET_FLAGS)) #define is_entry_subentry(e) \ (((e)->e_ocflags & SLAP_OC__END) \ ? (((e)->e_ocflags & SLAP_OC_SUBENTRY) != 0) \ - : is_entry_objectclass((e), slap_schema.si_oc_subentry, 1)) + : is_entry_objectclass((e), slap_schema.si_oc_subentry, SLAP_OCF_SET_FLAGS)) #define is_entry_collectiveAttributeSubentry(e) \ (((e)->e_ocflags & SLAP_OC__END) \ ? (((e)->e_ocflags & SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY) != 0) \ - : is_entry_objectclass((e), slap_schema.si_oc_collectiveAttributeSubentry, 1)) + : is_entry_objectclass((e), slap_schema.si_oc_collectiveAttributeSubentry, SLAP_OCF_SET_FLAGS)) #define is_entry_dynamicObject(e) \ (((e)->e_ocflags & SLAP_OC__END) \ ? (((e)->e_ocflags & SLAP_OC_DYNAMICOBJECT) != 0) \ - : is_entry_objectclass((e), slap_schema.si_oc_dynamicObject, 1)) + : is_entry_objectclass((e), slap_schema.si_oc_dynamicObject, SLAP_OCF_SET_FLAGS)) #define is_entry_glue(e) \ (((e)->e_ocflags & SLAP_OC__END) \ ? (((e)->e_ocflags & SLAP_OC_GLUE) != 0) \ - : is_entry_objectclass((e), slap_schema.si_oc_glue, 1)) + : is_entry_objectclass((e), slap_schema.si_oc_glue, SLAP_OCF_SET_FLAGS)) #define is_entry_syncProviderSubentry(e) \ (((e)->e_ocflags & SLAP_OC__END) \ ? (((e)->e_ocflags & SLAP_OC_SYNCPROVIDERSUBENTRY) != 0) \ - : is_entry_objectclass((e), slap_schema.si_oc_syncProviderSubentry, 1)) + : is_entry_objectclass((e), slap_schema.si_oc_syncProviderSubentry, SLAP_OCF_SET_FLAGS)) #define is_entry_syncConsumerSubentry(e) \ (((e)->e_ocflags & SLAP_OC__END) \ ? (((e)->e_ocflags & SLAP_OC_SYNCCONSUMERSUBENTRY) != 0) \ - : is_entry_objectclass((e), slap_schema.si_oc_syncConsumerSubentry, 1)) + : is_entry_objectclass((e), slap_schema.si_oc_syncConsumerSubentry, SLAP_OCF_SET_FLAGS)) LDAP_SLAPD_F (int) oc_schema_info( Entry *e ); LDAP_SLAPD_F (void) oc_unparse LDAP_P(( diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index a212f44bd1..1b4a303a42 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -743,6 +743,10 @@ typedef struct slap_object_class { LDAP_STAILQ_ENTRY(slap_object_class) soc_next; } ObjectClass; +#define SLAP_OCF_SET_FLAGS 0x1 +#define SLAP_OCF_CHECK_SUP 0x2 +#define SLAP_OCF_MASK (SLAP_OCF_SET_FLAGS|SLAP_OCF_CHECK_SUP) + #define SLAP_OC_ALIAS 0x0001 #define SLAP_OC_REFERRAL 0x0002 #define SLAP_OC_SUBENTRY 0x0004