From: Howard Chu Date: Sun, 26 Jul 2009 00:14:15 +0000 (+0000) Subject: Change AttributeName.an_oc_exclude to an_oc_flags, avoid multiple X-Git-Tag: ACLCHECK_0~395 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=82e95f80918dabfc814e464c8254123975d25d69;p=openldap Change AttributeName.an_oc_exclude to an_oc_flags, avoid multiple futile searches for OC matches. --- diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 3f0e381722..9a405660d7 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -2774,7 +2774,7 @@ acl_unparse( AccessControl *a, struct berval *bv ) for ( an = a->acl_attrs; an && !BER_BVISNULL( &an->an_name ); an++ ) { if ( ! first ) *ptr++ = ','; if (an->an_oc) { - *ptr++ = an->an_oc_exclude ? '!' : '@'; + *ptr++ = ( an->an_flags & SLAP_AN_OCEXCLUDE ) ? '!' : '@'; ptr = lutil_strcopy( ptr, an->an_oc->soc_cname.bv_val ); } else { diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index c881612799..4c118c4313 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -594,29 +594,33 @@ int ad_inlist( * else if requested description is !objectClass, return * attributes which the class does not require/allow */ - oc = attrs->an_oc; - if( oc == NULL && attrs->an_name.bv_val ) { - switch( attrs->an_name.bv_val[0] ) { - case '@': /* @objectClass */ - case '+': /* +objectClass (deprecated) */ - case '!': { /* exclude */ - struct berval ocname; - ocname.bv_len = attrs->an_name.bv_len - 1; - ocname.bv_val = &attrs->an_name.bv_val[1]; - oc = oc_bvfind( &ocname ); - attrs->an_oc_exclude = 0; - if ( oc && attrs->an_name.bv_val[0] == '!' ) { - attrs->an_oc_exclude = 1; - } - } break; + if ( !( attrs->an_flags & SLAP_AN_OCINITED )) { + if( attrs->an_name.bv_val ) { + switch( attrs->an_name.bv_val[0] ) { + case '@': /* @objectClass */ + case '+': /* +objectClass (deprecated) */ + case '!': { /* exclude */ + struct berval ocname; + ocname.bv_len = attrs->an_name.bv_len - 1; + ocname.bv_val = &attrs->an_name.bv_val[1]; + oc = oc_bvfind( &ocname ); + if ( oc && attrs->an_name.bv_val[0] == '!' ) { + attrs->an_flags |= SLAP_AN_OCEXCLUDE; + } else { + attrs->an_flags &= ~SLAP_AN_OCEXCLUDE; + } + } break; - default: /* old (deprecated) way */ - oc = oc_bvfind( &attrs->an_name ); + default: /* old (deprecated) way */ + oc = oc_bvfind( &attrs->an_name ); + } + attrs->an_oc = oc; } - attrs->an_oc = oc; + attrs->an_flags |= SLAP_AN_OCINITED; } + oc = attrs->an_oc; if( oc != NULL ) { - if ( attrs->an_oc_exclude ) { + if ( attrs->an_flags & SLAP_AN_OCEXCLUDE ) { if ( oc == slap_schema.si_oc_extensibleObject ) { /* extensibleObject allows the return of anything */ return 0; @@ -932,7 +936,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) anew->an_desc = NULL; anew->an_oc = NULL; - anew->an_oc_exclude = 0; + anew->an_flags = 0; ber_str2bv(s, 0, 1, &anew->an_name); slap_bv2ad(&anew->an_name, &anew->an_desc, &text); if ( !anew->an_desc ) { @@ -959,7 +963,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) } if ( anew->an_name.bv_val[0] == '!' ) { - anew->an_oc_exclude = 1; + anew->an_flags |= SLAP_AN_OCEXCLUDE; } } break; @@ -971,6 +975,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) } } } + anew->an_flags |= SLAP_AN_OCINITED; anew++; } diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index 93476070d1..d20dbd30ae 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -1414,7 +1414,7 @@ parseReadAttrs( an[i].an_desc = NULL; an[i].an_oc = NULL; - an[i].an_oc_exclude = 0; + an[i].an_flags = 0; rc = slap_bv2ad( &an[i].an_name, &an[i].an_desc, &dummy ); if ( rc == LDAP_SUCCESS ) { an[i].an_name = an[i].an_desc->ad_cname; diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 80a5d74028..3a1a5fa60b 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -1605,7 +1605,7 @@ filter2template( (*filter_attrs)[*filter_cnt].an_desc = ad; (*filter_attrs)[*filter_cnt].an_name = ad->ad_cname; (*filter_attrs)[*filter_cnt].an_oc = NULL; - (*filter_attrs)[*filter_cnt].an_oc_exclude = 0; + (*filter_attrs)[*filter_cnt].an_flags = 0; BER_BVZERO( &(*filter_attrs)[*filter_cnt+1].an_name ); (*filter_cnt)++; if ( ad == slap_schema.si_ad_objectClass ) @@ -2202,14 +2202,14 @@ add_filter_attrs( (*new_attrs)[j].an_name = filter_attrs[i].an_name; (*new_attrs)[j].an_desc = filter_attrs[i].an_desc; (*new_attrs)[j].an_oc = NULL; - (*new_attrs)[j].an_oc_exclude = 0; + (*new_attrs)[j].an_flags = 0; j++; } if ( addoc ) { (*new_attrs)[j].an_name = slap_schema.si_ad_objectClass->ad_cname; (*new_attrs)[j].an_desc = slap_schema.si_ad_objectClass; (*new_attrs)[j].an_oc = NULL; - (*new_attrs)[j].an_oc_exclude = 0; + (*new_attrs)[j].an_flags = 0; j++; } BER_BVZERO( &(*new_attrs)[j].an_name ); @@ -3039,7 +3039,7 @@ pc_cf_gen( ConfigArgs *c ) attr_name->an_name = attr_name->an_desc->ad_cname; } attr_name->an_oc = NULL; - attr_name->an_oc_exclude = 0; + attr_name->an_flags = 0; if ( attr_name->an_desc == slap_schema.si_ad_objectClass ) qm->attr_sets[num].flags |= PC_GOT_OC; attr_name++; diff --git a/servers/slapd/search.c b/servers/slapd/search.c index be0b283f82..ecdae3ce61 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -152,7 +152,7 @@ do_search( const char *dummy; /* ignore msgs from bv2ad */ op->ors_attrs[i].an_desc = NULL; op->ors_attrs[i].an_oc = NULL; - op->ors_attrs[i].an_oc_exclude = 0; + op->ors_attrs[i].an_flags = 0; if ( slap_bv2ad( &op->ors_attrs[i].an_name, &op->ors_attrs[i].an_desc, &dummy ) != LDAP_SUCCESS ) { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 1e9235f93b..65716aabcb 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -842,10 +842,13 @@ struct AttributeDescription { #define SLAP_AD_PROXIED 0x01U #define SLAP_AD_NOINSERT 0x02U +#define SLAP_AN_OCEXCLUDE 0x01 +#define SLAP_AN_OCINITED 0x02 + struct AttributeName { struct berval an_name; AttributeDescription *an_desc; - int an_oc_exclude; + int an_flags; ObjectClass *an_oc; }; diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index bdff8eba3f..28615bbd36 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -1152,7 +1152,7 @@ pblock_set( Slapi_PBlock *pb, int param, void *value ) for ( i = 0; attrs[i] != NULL; i++ ) { an[j].an_desc = NULL; an[j].an_oc = NULL; - an[j].an_oc_exclude = 0; + an[j].an_flags = 0; an[j].an_name.bv_val = attrs[i]; an[j].an_name.bv_len = strlen( attrs[i] ); if ( slap_bv2ad( &an[j].an_name, &an[j].an_desc, &pb->pb_rs->sr_text ) == LDAP_SUCCESS ) {