From 44f0efb44f995fac8325e9be5631a9fa4df95cf0 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 19 Jan 2002 02:58:00 +0000 Subject: [PATCH] Defined some ObjectClass->soc_flags values, changed is_entry_*objectclass macros to use flags --- servers/slapd/back-bdb/group.c | 2 +- servers/slapd/back-ldap/group.c | 2 +- servers/slapd/back-ldbm/group.c | 2 +- servers/slapd/back-meta/group.c | 2 +- servers/slapd/oc.c | 15 +++++++++++---- servers/slapd/proto-slap.h | 17 +++++++++++------ servers/slapd/schema_check.c | 4 ++-- servers/slapd/schema_prep.c | 14 +++++++------- servers/slapd/slap.h | 14 ++++++++++++-- 9 files changed, 47 insertions(+), 25 deletions(-) diff --git a/servers/slapd/back-bdb/group.c b/servers/slapd/back-bdb/group.c index 2e55471eaf..c108c8c546 100644 --- a/servers/slapd/back-bdb/group.c +++ b/servers/slapd/back-bdb/group.c @@ -145,7 +145,7 @@ bdb_group( goto return_results; } - if( !is_entry_objectclass( e, group_oc ) ) { + if( !is_entry_objectclass( e, group_oc, 0 ) ) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ERR, "bdb_group: failed to find %s in objectClass.\n", diff --git a/servers/slapd/back-ldap/group.c b/servers/slapd/back-ldap/group.c index c1410d3879..5d8dd3a173 100644 --- a/servers/slapd/back-ldap/group.c +++ b/servers/slapd/back-ldap/group.c @@ -68,7 +68,7 @@ ldap_back_group( /* * Now we can check for the group objectClass value */ - if( !is_entry_objectclass( target, group_oc ) ) { + if( !is_entry_objectclass( target, group_oc, 0 ) ) { return(1); } diff --git a/servers/slapd/back-ldbm/group.c b/servers/slapd/back-ldbm/group.c index ac7f45ce33..11f857b381 100644 --- a/servers/slapd/back-ldbm/group.c +++ b/servers/slapd/back-ldbm/group.c @@ -143,7 +143,7 @@ ldbm_back_group( goto return_results; } - if( !is_entry_objectclass( e, group_oc ) ) { + if( !is_entry_objectclass( e, group_oc, 0 ) ) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ERR, "ldbm_back_group: failed to find %s in objectClass.\n", diff --git a/servers/slapd/back-meta/group.c b/servers/slapd/back-meta/group.c index 65481f71eb..972b87031b 100644 --- a/servers/slapd/back-meta/group.c +++ b/servers/slapd/back-meta/group.c @@ -129,7 +129,7 @@ meta_back_group( /* * Now we can check for the group objectClass value */ - if ( !is_entry_objectclass( target, group_oc ) ) { + if ( !is_entry_objectclass( target, group_oc, 0 ) ) { return 1; } diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index c2ba69013d..3a4c48d2c5 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -48,7 +48,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 +60,10 @@ int is_entry_objectclass( return 0; } + if( set_flags && ( e->e_ocflags & SLAP_OC__END )) { + return (e->e_ocflags & oc->soc_flags); + } + /* * find objectClass attribute */ @@ -84,13 +89,15 @@ 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; } - } - return 0; + e->e_ocflags |= objectClass->soc_flags; + } + e->e_ocflags |= SLAP_OC__END; /* We've finished this */ + return (e->e_ocflags & oc->soc_flags); } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 592e697caf..d41c9c2bb3 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -622,17 +622,22 @@ LDAP_SLAPD_F (int) is_object_subclass LDAP_P(( ObjectClass *sup )); LDAP_SLAPD_F (int) is_entry_objectclass LDAP_P(( - Entry *, ObjectClass *oc )); + Entry *, ObjectClass *oc, int set_flags )); #define is_entry_alias(e) \ - is_entry_objectclass((e), slap_schema.si_oc_alias) + ((e)->e_ocflags & SLAP_OC__END) ? ((e)->e_ocflags & SLAP_OC_ALIAS) : \ + is_entry_objectclass((e), slap_schema.si_oc_alias, 1) #define is_entry_referral(e) \ - is_entry_objectclass((e), slap_schema.si_oc_referral) + ((e)->e_ocflags & SLAP_OC__END) ? ((e)->e_ocflags & SLAP_OC_REFERRAL) : \ + is_entry_objectclass((e), slap_schema.si_oc_referral, 1) #define is_entry_subentry(e) \ - is_entry_objectclass((e), slap_schema.si_oc_subentry) + ((e)->e_ocflags & SLAP_OC__END) ? ((e)->e_ocflags & SLAP_OC_SUBENTRY) : \ + is_entry_objectclass((e), slap_schema.si_oc_subentry, 1) #define is_entry_collectiveAttributes(e) \ - is_entry_objectclass((e), slap_schema.si_oc_collectiveAttributes) + ((e)->e_ocflags & SLAP_OC__END) ? ((e)->e_ocflags & SLAP_OC_COLLECTIVEATTRIBUTES) : \ + is_entry_objectclass((e), slap_schema.si_oc_collectiveAttributes, 1) #define is_entry_dynamicObject(e) \ - is_entry_objectclass((e), slap_schema.si_oc_dynamicObject) + ((e)->e_ocflags & SLAP_OC__END) ? ((e)->e_ocflags & SLAP_OC_DYNAMICOBJECT) : \ + is_entry_objectclass((e), slap_schema.si_oc_dynamicObject, 1) LDAP_SLAPD_F (int) oc_schema_info( Entry *e ); diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 2be55f9fd5..8e81ea0e35 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -219,8 +219,8 @@ entry_schema_check( return LDAP_OBJECT_CLASS_VIOLATION; } - if ( oc->sco_check ) { - int rc = (oc->sco_check)( be, e, oc, + if ( oc->soc_check ) { + int rc = (oc->soc_check)( be, e, oc, text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { return rc; diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index b9c1b5b9e1..b23d4c364b 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -141,12 +141,12 @@ static struct slap_schema_oc_map { "DESC 'RFC2256: an alias' " "SUP top STRUCTURAL " "MUST aliasedObjectName )", - aliasObjectClass, 0, + aliasObjectClass, SLAP_OC_ALIAS, offsetof(struct slap_internal_schema, si_oc_alias) }, { "referral", "( 2.16.840.1.113730.3.2.6 NAME 'referral' " "DESC 'namedref: named subordinate referral' " "SUP top STRUCTURAL MUST ref )", - referralObjectClass, 0, + referralObjectClass, SLAP_OC_REFERRAL, offsetof(struct slap_internal_schema, si_oc_referral) }, { "LDAProotDSE", "( 1.3.6.1.4.1.4203.1.4.1 " "NAME ( 'OpenLDAProotDSE' 'LDAProotDSE' ) " @@ -165,7 +165,7 @@ static struct slap_schema_oc_map { "MAY ( dITStructureRules $ nameForms $ ditContentRules $ " "objectClasses $ attributeTypes $ matchingRules $ " "matchingRuleUse ) )", - subentryObjectClass, 0, + subentryObjectClass, SLAP_OC_SUBENTRY, offsetof(struct slap_internal_schema, si_oc_subschema) }, { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 NAME 'monitor' " "DESC 'OpenLDAP system monitoring' " @@ -175,13 +175,13 @@ static struct slap_schema_oc_map { { "collectiveAttributes", "( 2.5.20.2 " "NAME 'collectiveAttributes' " "AUXILIARY )", - subentryObjectClass, 0, + subentryObjectClass, SLAP_OC_COLLECTIVEATTRIBUTES, offsetof(struct slap_internal_schema, si_oc_collectiveAttributes) }, { "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 " "NAME 'dynamicObject' " "DESC 'RFC2589: Dynamic Object' " "SUP top AUXILIARY )", - dynamicObjectClass, 0, + dynamicObjectClass, SLAP_OC_DYNAMICOBJECT, offsetof(struct slap_internal_schema, si_oc_dynamicObject) }, { NULL, NULL, NULL, 0, 0 } }; @@ -732,10 +732,10 @@ slap_schema_check( void ) if( oc_map[i].ssom_check ) { /* install check routine */ - (*ocp)->sco_check = oc_map[i].ssom_check; + (*ocp)->soc_check = oc_map[i].ssom_check; } /* install flags */ - (*ocp)->sco_flags |= oc_map[i].ssom_flags; + (*ocp)->soc_flags |= oc_map[i].ssom_flags; } ++schema_init_done; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index f493fcd665..de2b8fedab 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -471,8 +471,8 @@ typedef struct slap_object_class { struct slap_object_class **soc_sups; AttributeType **soc_required; AttributeType **soc_allowed; - ObjectClassSchemaCheckFN *sco_check; - slap_mask_t sco_flags; + ObjectClassSchemaCheckFN *soc_check; + slap_mask_t soc_flags; #define soc_oid soc_oclass.oc_oid #define soc_names soc_oclass.oc_names #define soc_desc soc_oclass.oc_desc @@ -486,6 +486,14 @@ typedef struct slap_object_class { struct slap_object_class *soc_next; } ObjectClass; +#define SLAP_OC_ALIAS 0x01 +#define SLAP_OC_REFERRAL 0x02 +#define SLAP_OC_SUBENTRY 0x04 +#define SLAP_OC_DYNAMICOBJECT 0x08 +#define SLAP_OC_COLLECTIVEATTRIBUTES 0x10 +#define SLAP_OC__MASK 0x1F +#define SLAP_OC__END 0x20 + #ifdef LDAP_EXTENDED_SCHEMA /* * DIT content rule @@ -746,6 +754,8 @@ typedef struct slap_entry { Attribute *e_attrs; /* list of attributes + values */ + slap_mask_t e_ocflags; + /* for use by the backend for any purpose */ void* e_private; } Entry; -- 2.39.5