From 0e16f6acf9efe4a3dd2b413418213431ec86c33d Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 22 Oct 2001 13:23:05 +0000 Subject: [PATCH] Moved AttributeDescription caching into main code: Changed AttributeDescription.{ad_cname,ad_lang} to struct berval everywhere Deleted ad_free() everywhere Added ad_mutex to init.c The AttributeDescriptions are in a linked list hanging off of the corresponding AttributeType. --- servers/slapd/acl.c | 18 +- servers/slapd/aclparse.c | 8 +- servers/slapd/ad.c | 252 ++++++++++++++++---------- servers/slapd/attr.c | 5 +- servers/slapd/ava.c | 2 - servers/slapd/back-bdb/attr.c | 11 +- servers/slapd/back-bdb/id2entry.c | 12 +- servers/slapd/back-bdb/index.c | 19 +- servers/slapd/back-bdb/modify.c | 4 +- servers/slapd/back-bdb/modrdn.c | 2 - servers/slapd/back-dnssrv/search.c | 4 - servers/slapd/back-ldap/add.c | 18 +- servers/slapd/back-ldap/attribute.c | 2 +- servers/slapd/back-ldap/compare.c | 2 +- servers/slapd/back-ldap/group.c | 2 +- servers/slapd/back-ldap/modify.c | 2 +- servers/slapd/back-ldap/search.c | 1 - servers/slapd/back-ldbm/attr.c | 11 +- servers/slapd/back-ldbm/attribute.c | 2 +- servers/slapd/back-ldbm/filterindex.c | 6 +- servers/slapd/back-ldbm/group.c | 2 +- servers/slapd/back-ldbm/index.c | 18 +- servers/slapd/back-ldbm/modify.c | 4 +- servers/slapd/back-ldbm/modrdn.c | 2 - servers/slapd/back-meta/add.c | 18 +- servers/slapd/back-meta/attribute.c | 2 +- servers/slapd/back-meta/compare.c | 6 +- servers/slapd/back-meta/group.c | 2 +- servers/slapd/back-meta/modify.c | 18 +- servers/slapd/back-meta/search.c | 1 - servers/slapd/back-passwd/search.c | 2 - servers/slapd/back-shell/compare.c | 2 +- servers/slapd/back-shell/modify.c | 8 +- servers/slapd/back-sql/modify.c | 14 +- servers/slapd/back-sql/search.c | 6 +- servers/slapd/back-sql/util.c | 1 - servers/slapd/backend.c | 2 +- servers/slapd/compare.c | 9 +- servers/slapd/entry.c | 17 +- servers/slapd/filter.c | 43 ++--- servers/slapd/init.c | 2 + servers/slapd/modify.c | 8 +- servers/slapd/mods.c | 2 - servers/slapd/mra.c | 1 - servers/slapd/proto-slap.h | 6 +- servers/slapd/repl.c | 2 +- servers/slapd/result.c | 20 +- servers/slapd/saslauthz.c | 1 - servers/slapd/schema_check.c | 4 +- servers/slapd/slap.h | 10 +- 50 files changed, 317 insertions(+), 299 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 9ae0246de2..9dbe23de9e 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -94,7 +94,7 @@ access_allowed( assert( desc != NULL ); assert( access > ACL_NONE ); - attr = desc->ad_cname->bv_val; + attr = desc->ad_cname.bv_val; assert( attr != NULL ); @@ -292,7 +292,7 @@ acl_get( assert( count != NULL ); assert( desc != NULL ); - attr = desc->ad_cname->bv_val; + attr = desc->ad_cname.bv_val; assert( attr != NULL ); @@ -463,7 +463,7 @@ acl_mask( assert( mask != NULL ); assert( desc != NULL ); - attr = desc->ad_cname->bv_val; + attr = desc->ad_cname.bv_val; assert( attr != NULL ); @@ -685,7 +685,7 @@ acl_mask( struct berval bv; int rc, match = 0; const char *text; - const char *attr = b->a_dn_at->ad_cname->bv_val; + const char *attr = b->a_dn_at->ad_cname.bv_val; assert( attr != NULL ); @@ -1081,11 +1081,11 @@ acl_check_modlist( #ifdef NEW_LOGGING LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1, "acl_check_modlist: conn %d no-user-mod %s: modify access granted\n", - conn->c_connid, mlist->sml_desc->ad_cname->bv_val )); + conn->c_connid, mlist->sml_desc->ad_cname.bv_val )); #else Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:" " modify access granted\n", - mlist->sml_desc->ad_cname->bv_val, 0, 0 ); + mlist->sml_desc->ad_cname.bv_val, 0, 0 ); #endif continue; } @@ -1236,7 +1236,6 @@ aci_set_gather (void *cookie, char *name, char *attr) } ber_bvecfree(bvals); } - ad_free(desc, 1); } } ch_free(ndn); @@ -1294,7 +1293,6 @@ aci_match_set ( { backend_attribute(be, NULL, NULL, e, subjdn, desc, &bvals); - ad_free(desc, 1); if ( bvals != NULL ) { if ( bvals[0] != NULL ) set = ch_strdup(bvals[0]->bv_val); @@ -1533,7 +1531,6 @@ aci_group_member ( } done: - if( grp_ad != NULL ) ad_free( grp_ad, 1 ); ch_free(grpdn); ch_free(grpat); ch_free(grpoc); @@ -1558,7 +1555,7 @@ aci_mask( struct berval bv, perms, sdn; char *subjdn; int rc; - char *attr = desc->ad_cname->bv_val; + char *attr = desc->ad_cname.bv_val; assert( attr != NULL ); @@ -1645,7 +1642,6 @@ aci_mask( } } - ad_free( ad, 1 ); return rc; diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index a7df30bd8e..c18f36e27f 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -539,7 +539,7 @@ parse_acl( fprintf( stderr, "%s: line %d: group: \"%s\" not allowed by \"%s\"\n", fname, lineno, - b->a_group_at->ad_cname->bv_val, + b->a_group_at->ad_cname.bv_val, b->a_group_oc->soc_oid ); acl_usage(); } @@ -1200,7 +1200,7 @@ print_access( Access *b ) } if ( b->a_dn_at != NULL ) { - fprintf( stderr, " dnattr=%s", b->a_dn_at->ad_cname->bv_val ); + fprintf( stderr, " dnattr=%s", b->a_dn_at->ad_cname.bv_val ); } if ( b->a_group_pat != NULL ) { @@ -1211,7 +1211,7 @@ print_access( Access *b ) b->a_group_oc->soc_oclass.oc_oid ); if ( b->a_group_at ) { - fprintf( stderr, " attributeType: %s", b->a_group_at->ad_cname->bv_val ); + fprintf( stderr, " attributeType: %s", b->a_group_at->ad_cname.bv_val ); } } } @@ -1234,7 +1234,7 @@ print_access( Access *b ) #ifdef SLAPD_ACI_ENABLED if ( b->a_aci_at != NULL ) { - fprintf( stderr, " aci=%s", b->a_aci_at->ad_cname->bv_val ); + fprintf( stderr, " aci=%s", b->a_aci_at->ad_cname.bv_val ); } #endif diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index e2a028c90d..7ea0734aab 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -18,43 +18,7 @@ #include "ldap_pvt.h" #include "slap.h" -AttributeDescription *ad_dup( - AttributeDescription *desc ) -{ - AttributeDescription *ad; - - if( desc == NULL ) { - return NULL; - } - - ad = (AttributeDescription *) ch_malloc( sizeof(AttributeDescription) ); - - *ad = *desc; - - if( ad->ad_cname != NULL ) { - ad->ad_cname = ber_bvdup( ad->ad_cname ); - } - - if( ad->ad_lang != NULL ) { - ad->ad_lang = ch_strdup( ad->ad_lang ); - } - - return ad; -} - -void -ad_free( AttributeDescription *ad, int freeit ) -{ - if( ad == NULL ) return; - - if( ad->ad_cname != NULL ) { - ber_bvfree( ad->ad_cname ); - } - - free( ad->ad_lang ); - - if( freeit ) free( ad ); -} +extern ldap_pvt_thread_mutex_t ad_mutex; /* init.c */ static int ad_keystring( struct berval *bv ) @@ -92,8 +56,8 @@ int slap_bv2ad( { int rtn = LDAP_UNDEFINED_TYPE; int i; - AttributeDescription desc; - char **tokens; + AttributeDescription desc, *d2; + char *name, *options; assert( ad != NULL ); assert( *ad == NULL ); /* temporary */ @@ -109,25 +73,37 @@ int slap_bv2ad( return rtn; } - tokens = str2charray( bv->bv_val, ";"); - - if( tokens == NULL || *tokens == NULL ) { - *text = "no attribute type"; - goto done; - } - - desc.ad_type = at_find( *tokens ); - + /* find valid base attribute type; parse in place */ + name = bv->bv_val; + options = strchr(name, ';'); + if (options != NULL) *options = '\0'; + desc.ad_type = at_find( name ); + if (options != NULL) *options = ';'; if( desc.ad_type == NULL ) { *text = "attribute type undefined"; - goto done; + + return rtn; } - desc.ad_flags = SLAP_DESC_NONE; - desc.ad_lang = NULL; + if (options != NULL) + desc.ad_cname.bv_len = options - name; + else + desc.ad_cname.bv_len = strlen(name); - for( i=1; tokens[i] != NULL; i++ ) { - if( strcasecmp( tokens[i], "binary" ) == 0 ) { + desc.ad_flags = SLAP_DESC_NONE; + desc.ad_lang.bv_len = 0; + desc.ad_lang.bv_val = NULL; + + /* parse options in place */ + for( ; options != NULL; ) { + name = options+1; + options = strchr( name, ';' ); + if ( options != NULL ) + i = options - name; + else + i = strlen(name); + + if( i == sizeof("binary")-1 && strncasecmp( name, "binary", i) == 0 ) { if( slap_ad_is_binary( &desc ) ) { *text = "option \"binary\" specified multiple times"; goto done; @@ -141,57 +117,126 @@ int slap_bv2ad( desc.ad_flags |= SLAP_DESC_BINARY; - } else if ( strncasecmp( tokens[i], "lang-", - sizeof("lang-")-1 ) == 0 && tokens[i][sizeof("lang-")-1] ) + } else if ( i >= sizeof("lang-") && strncasecmp( name, "lang-", + sizeof("lang-")-1 ) == 0) { - if( desc.ad_lang != NULL ) { + if( desc.ad_lang.bv_len != 0 ) { *text = "multiple language tag options specified"; goto done; } - desc.ad_lang = ch_strdup( tokens[i] ); - - /* normalize to all lower case, it's easy */ - ldap_pvt_str2lower( desc.ad_lang ); - + desc.ad_lang.bv_val = name; + desc.ad_lang.bv_len = i; } else { *text = "unrecognized option"; goto done; } } - desc.ad_cname = ch_malloc( sizeof( struct berval ) ); - - desc.ad_cname->bv_len = strlen( desc.ad_type->sat_cname ); - if( slap_ad_is_binary( &desc ) ) { - desc.ad_cname->bv_len += sizeof("binary"); - } - if( desc.ad_lang != NULL ) { - desc.ad_cname->bv_len += 1 + strlen( desc.ad_lang ); + /* see if a matching description is already cached */ + for (d2 = desc.ad_type->sat_ad; d2; d2=d2->ad_next) { + if (d2->ad_flags != desc.ad_flags) + continue; + if (d2->ad_lang.bv_len != desc.ad_lang.bv_len) + continue; + if (d2->ad_lang.bv_len == 0) + break; + if (strncasecmp(d2->ad_lang.bv_val, desc.ad_lang.bv_val, + desc.ad_lang.bv_len) == 0) + break; } - desc.ad_cname->bv_val = ch_malloc( desc.ad_cname->bv_len + 1 ); + /* Not found, add new one */ + while (d2 == NULL) { + int dlen = 0; + /* uses a single mutex instead of one per attributetype. + * I don't believe this is a significant bottleneck. If + * necessary, could change to a per-AttrType rwlock. + */ + ldap_pvt_thread_mutex_lock( &ad_mutex ); + /* Check again just in case another thread added it */ + for (d2 = desc.ad_type->sat_ad; d2; d2=d2->ad_next) { + if (d2->ad_flags != desc.ad_flags) + continue; + if (d2->ad_lang.bv_len != desc.ad_lang.bv_len) + continue; + if (d2->ad_lang.bv_len == 0) + break; + if (strncasecmp(d2->ad_lang.bv_val,desc.ad_lang.bv_val, + desc.ad_lang.bv_len) == 0) + break; + } + /* Some other thread added it before we got the lock. */ + if (d2 != NULL) { + ldap_pvt_thread_mutex_unlock( &ad_mutex ); + break; + } - strcpy( desc.ad_cname->bv_val, desc.ad_type->sat_cname ); - if( slap_ad_is_binary( &desc ) ) { - strcat( desc.ad_cname->bv_val, ";binary" ); - } + /* Allocate a single contiguous block. If there are no + * options, we just need space for the AttrDesc structure. + * Otherwise, we need to tack on the full name length + + * options length. + */ + i = sizeof(AttributeDescription); + if (desc.ad_lang.bv_len || desc.ad_flags != SLAP_DESC_NONE) { + if (desc.ad_lang.bv_len) + dlen = desc.ad_lang.bv_len+1; + dlen += strlen(desc.ad_type->sat_cname)+1; + if( slap_ad_is_binary( &desc ) ) { + dlen += sizeof("binary"); + } + } - if( desc.ad_lang != NULL ) { - strcat( desc.ad_cname->bv_val, ";" ); - strcat( desc.ad_cname->bv_val, desc.ad_lang ); + d2 = ch_malloc(i + dlen); + d2->ad_type = desc.ad_type; + d2->ad_flags = desc.ad_flags; + d2->ad_cname.bv_len = desc.ad_cname.bv_len; + d2->ad_lang.bv_len = desc.ad_lang.bv_len; + if (dlen == 0) { + d2->ad_cname.bv_val = d2->ad_type->sat_cname; + d2->ad_lang.bv_val = NULL; + } else { + d2->ad_cname.bv_val = (char *)(d2+1); + strcpy(d2->ad_cname.bv_val, d2->ad_type->sat_cname); + if( slap_ad_is_binary( &desc ) ) { + strcpy(d2->ad_cname.bv_val+d2->ad_cname.bv_len, + ";binary"); + d2->ad_cname.bv_len += sizeof("binary"); + } + if( d2->ad_lang.bv_len ) { + d2->ad_cname.bv_val[d2->ad_cname.bv_len++]=';'; + d2->ad_lang.bv_val = d2->ad_cname.bv_val+ + d2->ad_cname.bv_len; + strncpy(d2->ad_lang.bv_val,desc.ad_lang.bv_val, + d2->ad_lang.bv_len); + d2->ad_lang.bv_val[d2->ad_lang.bv_len] = '\0'; + ldap_pvt_str2lower(d2->ad_lang.bv_val); + d2->ad_cname.bv_len += d2->ad_lang.bv_len; + } + } + /* Add new desc to list. We always want the bare Desc with + * no options to stay at the head of the list, assuming + * that one will be used most frequently. + */ + if (desc.ad_type->sat_ad == NULL || dlen == 0) { + d2->ad_next = desc.ad_type->sat_ad; + desc.ad_type->sat_ad = d2; + } else { + d2->ad_next = desc.ad_type->sat_ad->ad_next; + desc.ad_type->sat_ad->ad_next = d2; + } + ldap_pvt_thread_mutex_unlock( &ad_mutex ); } if( *ad == NULL ) { - *ad = ch_malloc( sizeof( AttributeDescription ) ); + *ad = d2; + } else { + **ad = *d2; } - **ad = desc; - rtn = LDAP_SUCCESS; done: - charray_free( tokens ); return rtn; } @@ -208,8 +253,9 @@ int is_ad_subtype( return 0; } - if( super->ad_lang != NULL && ( sub->ad_lang == NULL - || strcasecmp( super->ad_lang, sub->ad_lang ))) + if( super->ad_lang.bv_len && (sub->ad_lang.bv_len != + super->ad_lang.bv_len || strcmp( super->ad_lang.bv_val, + sub->ad_lang.bv_val))) { return 0; } @@ -234,8 +280,6 @@ int ad_inlist( rc = is_ad_subtype( desc, ad ); - ad_free( ad, 1 ); - if( rc ) return 1; } @@ -260,10 +304,9 @@ int slap_bv2undef_ad( AttributeDescription **ad, const char **text ) { - AttributeDescription desc; + AttributeDescription *desc; assert( ad != NULL ); - assert( *ad == NULL ); /* temporary */ if( bv == NULL || bv->bv_len == 0 ) { *text = "empty attribute description"; @@ -276,21 +319,36 @@ int slap_bv2undef_ad( return LDAP_UNDEFINED_TYPE; } - desc.ad_type = slap_schema.si_at_undefined; - desc.ad_flags = SLAP_DESC_NONE; - desc.ad_lang = NULL; + for (desc = slap_schema.si_at_undefined->sat_ad; desc; + desc=desc->ad_next) + if (desc->ad_cname.bv_len == bv->bv_len && + !strcasecmp(desc->ad_cname.bv_val, bv->bv_val)) + break; + + if (!desc) { + desc = ch_malloc(sizeof(AttributeDescription) + + bv->bv_len + 1); + + desc->ad_flags = SLAP_DESC_NONE; + desc->ad_lang.bv_val = NULL; + desc->ad_lang.bv_len = 0; - desc.ad_cname = ber_bvdup( bv ); + desc->ad_cname.bv_len = bv->bv_len; + desc->ad_cname.bv_val = (char *)(desc+1); + strcpy(desc->ad_cname.bv_val, bv->bv_val); - /* canoncial to upper case */ - ldap_pvt_str2upper( bv->bv_val ); + /* canonical to upper case */ + ldap_pvt_str2upper( desc->ad_cname.bv_val ); - if( *ad == NULL ) { - *ad = ch_malloc( sizeof( AttributeDescription ) ); + desc->ad_type = slap_schema.si_at_undefined; + desc->ad_next = desc->ad_type->sat_ad; + desc->ad_type->sat_ad = desc; } - **ad = desc; + if (!*ad) + *ad = desc; + else + **ad = *desc; return LDAP_SUCCESS; } - diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 9239e161f8..d5b9e3a078 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -29,7 +29,6 @@ static void at_index_print( void ); void attr_free( Attribute *a ) { - ad_free( a->a_desc, 1 ); ber_bvecfree( a->a_vals ); free( a ); } @@ -74,7 +73,7 @@ Attribute *attr_dup( Attribute *a ) tmp->a_vals = NULL; } - tmp->a_desc = ad_dup( a->a_desc ); + tmp->a_desc = a->a_desc; tmp->a_next = NULL; return tmp; @@ -124,7 +123,7 @@ attr_merge( if ( *a == NULL ) { *a = (Attribute *) ch_malloc( sizeof(Attribute) ); - (*a)->a_desc = ad_dup( desc ); + (*a)->a_desc = desc; (*a)->a_vals = NULL; (*a)->a_next = NULL; } diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index 69157a954a..da6a2e3355 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -21,7 +21,6 @@ ava_free( int freeit ) { - ad_free( ava->aa_desc, 1 ); ber_bvfree( ava->aa_value ); if ( freeit ) { ch_free( (char *) ava ); @@ -70,7 +69,6 @@ get_ava( ch_free( value.bv_val ); if( rc != LDAP_SUCCESS ) { - ad_free( aa->aa_desc, 1 ); ch_free( aa ); return rc; } diff --git a/servers/slapd/back-bdb/attr.c b/servers/slapd/back-bdb/attr.c index 66c77242cd..dd1fe3b851 100644 --- a/servers/slapd/back-bdb/attr.c +++ b/servers/slapd/back-bdb/attr.c @@ -203,18 +203,17 @@ bdb_attr_index_config( #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, "attr_index_config: index %s 0x%04x\n", - ad->ad_cname->bv_val, mask )); + ad->ad_cname.bv_val, mask )); #else Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04x\n", - ad->ad_cname->bv_val, mask, 0 ); + ad->ad_cname.bv_val, mask, 0 ); #endif #ifdef SLAPD_USE_AD a->ai_desc = ad; #else - a->ai_desc = ch_strdup( ad->ad_cname->bv_val ); - ad_free( ad, 1 ); + a->ai_desc = ch_strdup( ad->ad_cname.bv_val ); #endif a->ai_indexmask = mask; @@ -242,9 +241,7 @@ static void ainfo_free( void *attr ) { AttrInfo *ai = attr; -#ifdef SLAPD_USE_AD - ad_free( ai->ai_desc, 1 ); -#else +#ifndef SLAPD_USE_AD free( ai->ai_desc ); #endif free( ai ); diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index 538249eb34..8c02c77b3c 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -26,7 +26,7 @@ ad_type_cmp( AttributeDescription *ad ) { - return strcasecmp(desc, ad->ad_cname->bv_val); + return strcasecmp(desc, ad->ad_cname.bv_val); } static int @@ -35,7 +35,7 @@ ad_info_cmp( AttributeDescription *a2 ) { - return strcasecmp(a1->ad_cname->bv_val, a2->ad_cname->bv_val); + return strcasecmp(a1->ad_cname.bv_val, a2->ad_cname.bv_val); } AttributeDescription * @@ -87,7 +87,7 @@ int bdb_encode(Entry *e, struct berval **bv) for (a=e->e_attrs; a; a=a->a_next) { /* For AttributeDesc, we only store the attr name */ siz += sizeof(Attribute); - len += a->a_desc->ad_cname->bv_len+1; + len += a->a_desc->ad_cname.bv_len+1; for (i=0; a->a_vals[i]; i++) { siz += sizeof(struct berval *); siz += sizeof(struct berval); @@ -116,9 +116,9 @@ int bdb_encode(Entry *e, struct berval **bv) b = (Attribute *)data; data = (char *)(b+1); b->a_desc = (AttributeDescription *)(ptr-base); - memcpy(ptr, a->a_desc->ad_cname->bv_val, - a->a_desc->ad_cname->bv_len); - ptr += a->a_desc->ad_cname->bv_len; + memcpy(ptr, a->a_desc->ad_cname.bv_val, + a->a_desc->ad_cname.bv_len); + ptr += a->a_desc->ad_cname.bv_len; *ptr++ = '\0'; if (a->a_vals) { bvl = (struct berval **)data; diff --git a/servers/slapd/back-bdb/index.c b/servers/slapd/back-bdb/index.c index eb259c5efd..71e902e764 100644 --- a/servers/slapd/back-bdb/index.c +++ b/servers/slapd/back-bdb/index.c @@ -27,11 +27,11 @@ static slap_mask_t index_mask( /* we do not support indexing of binary attributes */ if( slap_ad_is_binary( desc ) ) return 0; - bdb_attr_mask( be->be_private, desc->ad_cname->bv_val, &mask ); + bdb_attr_mask( be->be_private, desc->ad_cname.bv_val, &mask ); if( mask ) { - *atname = desc->ad_cname->bv_val; - *dbname = desc->ad_cname->bv_val; + *atname = desc->ad_cname.bv_val; + *dbname = desc->ad_cname.bv_val; return mask; } @@ -40,7 +40,7 @@ static slap_mask_t index_mask( bdb_attr_mask( be->be_private, desc->ad_type->sat_cname, &mask ); if( mask & SLAP_INDEX_AUTO_LANG ) { - *atname = desc->ad_cname->bv_val; + *atname = desc->ad_cname.bv_val; *dbname = desc->ad_type->sat_cname; return mask; } @@ -248,7 +248,6 @@ static int indexer( } done: - ad_free( ad, 1 ); return rc; } @@ -256,7 +255,7 @@ static int index_at_values( Backend *be, DB_TXN *txn, AttributeType *type, - const char *lang, + struct berval *lang, struct berval **vals, ID id, int op, @@ -295,13 +294,13 @@ static int index_at_values( if( rc ) return rc; } - if( lang ) { + if( lang->bv_len ) { char *dbname = NULL; size_t tlen = strlen( type->sat_cname ); - size_t llen = strlen( lang ); + size_t llen = lang->bv_len; char *lname = ch_malloc( tlen + llen + sizeof(";") ); - sprintf( lname, "%s;%s", type->sat_cname, lang ); + sprintf( lname, "%s;%s", type->sat_cname, lang->bv_val ); bdb_attr_mask( be->be_private, lname, &tmpmask ); @@ -347,7 +346,7 @@ int bdb_index_values( } rc = index_at_values( be, txn, - desc->ad_type, desc->ad_lang, + desc->ad_type, &desc->ad_lang, vals, id, op, &dbname, &mask ); diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 279a8776a1..5bcd494e78 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -354,7 +354,7 @@ add_values( int i; Attribute *a; - /* char *desc = mod->sm_desc->ad_cname->bv_val; */ + /* char *desc = mod->sm_desc->ad_cname.bv_val; */ MatchingRule *mr = mod->sm_desc->ad_type->sat_equality; a = attr_find( e->e_attrs, mod->sm_desc ); @@ -415,7 +415,7 @@ delete_values( { int i, j, k, found; Attribute *a; - char *desc = mod->sm_desc->ad_cname->bv_val; + char *desc = mod->sm_desc->ad_cname.bv_val; MatchingRule *mr = mod->sm_desc->ad_type->sat_equality; /* delete the entire attribute */ diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 3da231e231..b2e989c426 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -397,7 +397,6 @@ retry: /* transaction retry */ "bdb_modrdn: access to attr \"%s\" " "(new) not allowed\n", new_rdn_types[ a_cnt ], 0, 0 ); - ad_free( desc, 1); rc = LDAP_INSUFFICIENT_ACCESS; goto return_results; } @@ -450,7 +449,6 @@ retry: /* transaction retry */ "bdb_modrdn: access to attr \"%s\" " "(old) not allowed\n", old_rdn_types[ d_cnt ], 0, 0 ); - ad_free( desc, 1); rc = LDAP_INSUFFICIENT_ACCESS; goto return_results; } diff --git a/servers/slapd/back-dnssrv/search.c b/servers/slapd/back-dnssrv/search.c index 28f32d3a1e..ba1d6816b7 100644 --- a/servers/slapd/back-dnssrv/search.c +++ b/servers/slapd/back-dnssrv/search.c @@ -176,8 +176,6 @@ dnssrv_back_search( val.bv_len = strlen(val.bv_val); attr_merge( e, ad, vals ); - - ad_free( ad, 1 ); } } @@ -191,8 +189,6 @@ dnssrv_back_search( val.bv_val = domain; val.bv_len = strlen(domain); attr_merge( e, ad, vals ); - - ad_free( ad, 1 ); } } diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c index 32fc5bb910..d5c3ad0cb9 100644 --- a/servers/slapd/back-ldap/add.c +++ b/servers/slapd/back-ldap/add.c @@ -119,20 +119,20 @@ ldap_back_add( * of the target directory are used, if available */ #if 0 - if ( !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_creatorsName->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_createTimestamp->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_modifiersName->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_modifyTimestamp->ad_cname->bv_val ) + if ( !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_creatorsName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_createTimestamp->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifiersName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val ) ) { continue; } #endif - mapped = ldap_back_map(&li->at_map, a->a_desc->ad_cname->bv_val, 0); + mapped = ldap_back_map(&li->at_map, a->a_desc->ad_cname.bv_val, 0); if (mapped == NULL) { continue; } diff --git a/servers/slapd/back-ldap/attribute.c b/servers/slapd/back-ldap/attribute.c index e8b49e052a..3fe917754c 100644 --- a/servers/slapd/back-ldap/attribute.c +++ b/servers/slapd/back-ldap/attribute.c @@ -62,7 +62,7 @@ ldap_back_attribute( } } else { - mapped = ldap_back_map(&li->at_map, entry_at->ad_cname->bv_val, 0); + mapped = ldap_back_map(&li->at_map, entry_at->ad_cname.bv_val, 0); if (mapped == NULL) return(1); diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c index 23d65f9e56..21bc19279b 100644 --- a/servers/slapd/back-ldap/compare.c +++ b/servers/slapd/back-ldap/compare.c @@ -100,7 +100,7 @@ ldap_back_compare( } #endif /* !ENABLE_REWRITE */ - mapped_oc = ldap_back_map(&li->oc_map, ava->aa_desc->ad_cname->bv_val, 0); + mapped_oc = ldap_back_map(&li->oc_map, ava->aa_desc->ad_cname.bv_val, 0); if (mapped_oc == NULL) return( -1 ); diff --git a/servers/slapd/back-ldap/group.c b/servers/slapd/back-ldap/group.c index a8a167766b..2080f64c15 100644 --- a/servers/slapd/back-ldap/group.c +++ b/servers/slapd/back-ldap/group.c @@ -45,7 +45,7 @@ ldap_back_group( AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; char *group_oc_name = NULL; - char *group_at_name = group_at->ad_cname->bv_val; + char *group_at_name = group_at->ad_cname.bv_val; if( group_oc->soc_names && group_oc->soc_names[0] ) { group_oc_name = group_oc->soc_names[0]; diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index a59d4179ca..e1e54052f9 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -113,7 +113,7 @@ ldap_back_modify( } for (i=0, ml=modlist; ml; ml=ml->sml_next) { - mapped = ldap_back_map(&li->at_map, ml->sml_desc->ad_cname->bv_val, 0); + mapped = ldap_back_map(&li->at_map, ml->sml_desc->ad_cname.bv_val, 0); if (mapped == NULL) { continue; } diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index fa35d582e5..0de3e828fc 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -543,7 +543,6 @@ ldap_send_entry( while (ent.e_attrs) { attr = ent.e_attrs; ent.e_attrs = attr->a_next; - ad_free(attr->a_desc, 1); if (attr->a_vals != &dummy) ber_bvecfree(attr->a_vals); free(attr); diff --git a/servers/slapd/back-ldbm/attr.c b/servers/slapd/back-ldbm/attr.c index f642aedec9..7aef298fa5 100644 --- a/servers/slapd/back-ldbm/attr.c +++ b/servers/slapd/back-ldbm/attr.c @@ -204,18 +204,17 @@ attr_index_config( #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, "attr_index_config: index %s 0x%04x\n", - ad->ad_cname->bv_val, mask )); + ad->ad_cname.bv_val, mask )); #else Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04x\n", - ad->ad_cname->bv_val, mask, 0 ); + ad->ad_cname.bv_val, mask, 0 ); #endif #ifdef SLAPD_USE_AD a->ai_desc = ad; #else - a->ai_desc = ch_strdup( ad->ad_cname->bv_val ); - ad_free( ad, 1 ); + a->ai_desc = ch_strdup( ad->ad_cname.bv_val ); #endif a->ai_indexmask = mask; @@ -243,9 +242,7 @@ static void ainfo_free( void *attr ) { AttrInfo *ai = attr; -#ifdef SLAPD_USE_AD - ad_free( ai->ai_desc, 1 ); -#else +#ifndef SLAPD_USE_AD free( ai->ai_desc ); #endif free( ai ); diff --git a/servers/slapd/back-ldbm/attribute.c b/servers/slapd/back-ldbm/attribute.c index bad3eed2e2..9dffdce630 100644 --- a/servers/slapd/back-ldbm/attribute.c +++ b/servers/slapd/back-ldbm/attribute.c @@ -35,7 +35,7 @@ ldbm_back_attribute( int i, j, rc; Attribute *attr; struct berval **v; - const char *entry_at_name = entry_at->ad_cname->bv_val; + const char *entry_at_name = entry_at->ad_cname.bv_val; #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ARGS, diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index c6df7e2d2c..8732599d74 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -82,7 +82,7 @@ filter_candidates( case LDAP_FILTER_PRESENT: #ifdef NEW_LOGGING LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, - "filter_candidates: Present (%s)\n", f->f_desc->ad_cname->bv_val )); + "filter_candidates: Present (%s)\n", f->f_desc->ad_cname.bv_val )); #else Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 ); #endif @@ -94,7 +94,7 @@ filter_candidates( #ifdef NEW_LOGGING LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, "filter_candidates: EQUALITY (%s),(%s)\n", - f->f_ava->aa_desc->ad_cname->bv_val, + f->f_ava->aa_desc->ad_cname.bv_val, f->f_ava->aa_value->bv_val )); #else Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 ); @@ -107,7 +107,7 @@ filter_candidates( #ifdef NEW_LOGGING LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1, "filter_candidates: APPROX (%s), (%s)\n", - f->f_ava->aa_desc->ad_cname->bv_val, + f->f_ava->aa_desc->ad_cname.bv_val, f->f_ava->aa_value->bv_val )); #else Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 ); diff --git a/servers/slapd/back-ldbm/group.c b/servers/slapd/back-ldbm/group.c index ff597f41f9..2de91fd5e8 100644 --- a/servers/slapd/back-ldbm/group.c +++ b/servers/slapd/back-ldbm/group.c @@ -41,7 +41,7 @@ ldbm_back_group( AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; const char *group_oc_name = NULL; - const char *group_at_name = group_at->ad_cname->bv_val; + const char *group_at_name = group_at->ad_cname.bv_val; if( group_oc->soc_names && group_oc->soc_names[0] ) { group_oc_name = group_oc->soc_names[0]; diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index f24903003d..54ad4442b7 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -27,11 +27,11 @@ static slap_mask_t index_mask( /* we do not support indexing of binary attributes */ if( slap_ad_is_binary( desc ) ) return 0; - attr_mask( be->be_private, desc->ad_cname->bv_val, &mask ); + attr_mask( be->be_private, desc->ad_cname.bv_val, &mask ); if( mask ) { - *atname = desc->ad_cname->bv_val; - *dbname = desc->ad_cname->bv_val; + *atname = desc->ad_cname.bv_val; + *dbname = desc->ad_cname.bv_val; return mask; } @@ -40,7 +40,7 @@ static slap_mask_t index_mask( attr_mask( be->be_private, desc->ad_type->sat_cname, &mask ); if( mask & SLAP_INDEX_AUTO_LANG ) { - *atname = desc->ad_cname->bv_val; + *atname = desc->ad_cname.bv_val; *dbname = desc->ad_type->sat_cname; return mask; } @@ -166,7 +166,6 @@ static int indexer( dbname, LDBM_SUFFIX, 0 ); #endif - ad_free( ad, 1 ); return LDAP_OTHER; } @@ -223,14 +222,13 @@ static int indexer( } ldbm_cache_close( be, db ); - ad_free( ad, 1 ); return LDAP_SUCCESS; } static int index_at_values( Backend *be, AttributeType *type, - const char *lang, + struct berval *lang, struct berval **vals, ID id, int op, @@ -267,10 +265,10 @@ static int index_at_values( if( lang ) { char *dbname = NULL; size_t tlen = strlen( type->sat_cname ); - size_t llen = strlen( lang ); + size_t llen = lang->bv_len; char *lname = ch_malloc( tlen + llen + sizeof(";") ); - sprintf( lname, "%s;%s", type->sat_cname, lang ); + sprintf( lname, "%s;%s", type->sat_cname, lang->bv_val ); attr_mask( be->be_private, lname, &tmpmask ); @@ -309,7 +307,7 @@ int index_values( } (void) index_at_values( be, - desc->ad_type, desc->ad_lang, + desc->ad_type, &desc->ad_lang, vals, id, op, &dbname, &mask ); diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 5ae6bb1959..18c83efc7c 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -357,7 +357,7 @@ add_values( int i; Attribute *a; - /* char *desc = mod->sm_desc->ad_cname->bv_val; */ + /* char *desc = mod->sm_desc->ad_cname.bv_val; */ MatchingRule *mr = mod->sm_desc->ad_type->sat_equality; a = attr_find( e->e_attrs, mod->sm_desc ); @@ -418,7 +418,7 @@ delete_values( { int i, j, k, found; Attribute *a; - char *desc = mod->sm_desc->ad_cname->bv_val; + char *desc = mod->sm_desc->ad_cname.bv_val; MatchingRule *mr = mod->sm_desc->ad_type->sat_equality; /* delete the entire attribute */ diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 7415c75794..0d1cd28f71 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -524,7 +524,6 @@ ldbm_back_modrdn( "to attr \"%s\"\n%s%s", new_rdn_types[a_cnt], "", "" ); #endif - ad_free( desc, 1 ); send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, NULL, NULL, NULL, NULL ); @@ -601,7 +600,6 @@ ldbm_back_modrdn( "to attr \"%s\"\n%s%s", old_rdn_types[d_cnt], "", "" ); #endif - ad_free( desc, 1 ); send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, NULL, NULL, NULL, NULL ); diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index f344c793f5..f23c4bb154 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -151,21 +151,21 @@ meta_back_add( * of the target directory are used, if available */ #if 0 - if ( !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_creatorsName->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_createTimestamp->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_modifiersName->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_modifyTimestamp->ad_cname->bv_val ) + if ( !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_creatorsName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_createTimestamp->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifiersName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val ) ) { continue; } #endif mapped = ldap_back_map( &li->targets[ candidate ]->at_map, - a->a_desc->ad_cname->bv_val, 0); + a->a_desc->ad_cname.bv_val, 0); if ( mapped == NULL ) { continue; } diff --git a/servers/slapd/back-meta/attribute.c b/servers/slapd/back-meta/attribute.c index f270bed4a1..f8c894a21c 100644 --- a/servers/slapd/back-meta/attribute.c +++ b/servers/slapd/back-meta/attribute.c @@ -138,7 +138,7 @@ meta_back_attribute( } mapped = ldap_back_map( &li->targets[ candidate ]->at_map, - entry_at->ad_cname->bv_val, 0 ); + entry_at->ad_cname.bv_val, 0 ); if ( mapped == NULL ) return 1; diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index 12cf49ed60..192a61e7f3 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -109,7 +109,7 @@ meta_back_compare( */ for ( i = 0, lsc = lc->conns; lsc[ 0 ] != NULL; ++i, ++lsc ) { char *mdn = NULL; - char *mapped_attr = ava->aa_desc->ad_cname->bv_val; + char *mapped_attr = ava->aa_desc->ad_cname.bv_val; char *mapped_value = ava->aa_value->bv_val; if ( lsc[ 0 ]->candidate != META_CANDIDATE ) { @@ -166,7 +166,7 @@ meta_back_compare( */ } else { mapped_attr = ldap_back_map( &li->targets[ i ]->at_map, - ava->aa_desc->ad_cname->bv_val, 0 ); + ava->aa_desc->ad_cname.bv_val, 0 ); if ( mapped_attr == NULL ) { lsc[ 0 ]->candidate = META_NOT_CANDIDATE; continue; @@ -188,7 +188,7 @@ meta_back_compare( if ( mdn != dn ) { free( mdn ); } - if ( mapped_attr != ava->aa_desc->ad_cname->bv_val ) { + if ( mapped_attr != ava->aa_desc->ad_cname.bv_val ) { free( mapped_attr ); } if ( mapped_value != ava->aa_value->bv_val ) { diff --git a/servers/slapd/back-meta/group.c b/servers/slapd/back-meta/group.c index 3fd884208e..56cf41fe86 100644 --- a/servers/slapd/back-meta/group.c +++ b/servers/slapd/back-meta/group.c @@ -105,7 +105,7 @@ meta_back_group( char *mop_ndn, *mgr_ndn; char *group_oc_name = NULL; - char *group_at_name = group_at->ad_cname->bv_val; + char *group_at_name = group_at->ad_cname.bv_val; if ( group_oc->soc_names && group_oc->soc_names[ 0 ] ) { group_oc_name = group_oc->soc_names[ 0 ]; diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index dd3ea4c3b2..7fc8b8e6e3 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -153,20 +153,20 @@ meta_back_modify( * lastmod should always be */ #if 0 - if ( !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_creatorsName->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_createTimestamp->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_modifiersName->ad_cname->bv_val ) - || !strcasecmp( a->a_desc->ad_cname->bv_val, - slap_schema.si_ad_modifyTimestamp->ad_cname->bv_val ) ) { + if ( !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_creatorsName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_createTimestamp->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifiersName->ad_cname.bv_val ) + || !strcasecmp( a->a_desc->ad_cname.bv_val, + slap_schema.si_ad_modifyTimestamp->ad_cname.bv_val ) ) { continue; } #endif mapped = ldap_back_map( &li->targets[ candidate ]->at_map, - ml->sml_desc->ad_cname->bv_val, 0 ); + ml->sml_desc->ad_cname.bv_val, 0 ); if ( mapped == NULL ) { continue; } diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index c033f66d8b..0700f137d7 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -760,7 +760,6 @@ meta_send_entry( while ( ent.e_attrs ) { attr = ent.e_attrs; ent.e_attrs = attr->a_next; - ad_free( attr->a_desc, 1 ); if ( attr->a_vals != &dummy ) { ber_bvecfree(attr->a_vals); } diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 4cc91c042a..fe386246d9 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -115,8 +115,6 @@ passwd_back_search( attr_merge( e, desc, vals ); - ad_free( desc, 1 ); - free(rdn); rdn = NULL; diff --git a/servers/slapd/back-shell/compare.c b/servers/slapd/back-shell/compare.c index c7c85f8d68..6e68ae90f5 100644 --- a/servers/slapd/back-shell/compare.c +++ b/servers/slapd/back-shell/compare.c @@ -52,7 +52,7 @@ shell_back_compare( print_suffixes( wfp, be ); fprintf( wfp, "dn: %s\n", dn ); fprintf( wfp, "%s: %s\n", - ava->aa_desc->ad_cname->bv_val, + ava->aa_desc->ad_cname.bv_val, ava->aa_value->bv_val /* could be binary! */ ); fclose( wfp ); diff --git a/servers/slapd/back-shell/modify.c b/servers/slapd/back-shell/modify.c index 0f6d66fd4b..3eb2e2e1ea 100644 --- a/servers/slapd/back-shell/modify.c +++ b/servers/slapd/back-shell/modify.c @@ -55,21 +55,21 @@ shell_back_modify( switch ( mod->sm_op ) { case LDAP_MOD_ADD: - fprintf( wfp, "add: %s\n", mod->sm_desc->ad_cname->bv_val ); + fprintf( wfp, "add: %s\n", mod->sm_desc->ad_cname.bv_val ); break; case LDAP_MOD_DELETE: - fprintf( wfp, "delete: %s\n", mod->sm_desc->ad_cname->bv_val ); + fprintf( wfp, "delete: %s\n", mod->sm_desc->ad_cname.bv_val ); break; case LDAP_MOD_REPLACE: - fprintf( wfp, "replace: %s\n", mod->sm_desc->ad_cname->bv_val ); + fprintf( wfp, "replace: %s\n", mod->sm_desc->ad_cname.bv_val ); break; } if( mod->sm_bvalues != NULL ) { for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) { - fprintf( wfp, "%s: %s\n", mod->sm_desc->ad_cname->bv_val, + fprintf( wfp, "%s: %s\n", mod->sm_desc->ad_cname.bv_val, mod->sm_bvalues[i]->bv_val /* binary! */ ); } } diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index fa5bc70b6e..bf4f0bb1ed 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -68,11 +68,11 @@ int backsql_modify(BackendDB *be,Connection *conn,Operation *op, for(ml=modlist;ml!=NULL;ml=ml->sml_next) { c_mod=&ml->sml_mod; - Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute '%s'\n",c_mod->sm_desc->ad_cname->bv_val,0,0); - at=backsql_at_with_name(oc,c_mod->sm_desc->ad_cname->bv_val); + Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute '%s'\n",c_mod->sm_desc->ad_cname.bv_val,0,0); + at=backsql_at_with_name(oc,c_mod->sm_desc->ad_cname.bv_val); if (at==NULL) { - Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute provided is not registered in this objectclass ('%s')\n",c_mod->sm_desc->ad_cname->bv_val,0,0); + Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute provided is not registered in this objectclass ('%s')\n",c_mod->sm_desc->ad_cname.bv_val,0,0); continue; } @@ -371,7 +371,7 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e) for(at=e->e_attrs;at!=NULL;at=at->a_next) { /*Debug(LDAP_DEBUG_TRACE,"backsql_add(): scanning entry -- %s\n",at->a_type,0,0);*/ - if (!strcasecmp(at->a_desc->ad_cname->bv_val,"objectclass")) + if (!strcasecmp(at->a_desc->ad_cname.bv_val,"objectclass")) { oc=backsql_oc_with_name(bi,at->a_vals[0]->bv_val); break; @@ -417,16 +417,16 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e) for(at=e->e_attrs;at!=NULL;at=at->a_next) { - at_rec=backsql_at_with_name(oc,at->a_desc->ad_cname->bv_val); + at_rec=backsql_at_with_name(oc,at->a_desc->ad_cname.bv_val); if (at_rec==NULL) { - Debug(LDAP_DEBUG_TRACE,"backsql_add(): attribute provided is not registered in this objectclass ('%s')\n",at->a_desc->ad_cname->bv_val,0,0); + Debug(LDAP_DEBUG_TRACE,"backsql_add(): attribute provided is not registered in this objectclass ('%s')\n",at->a_desc->ad_cname.bv_val,0,0); continue; } if (at_rec->add_proc==NULL) { - Debug(LDAP_DEBUG_TRACE,"backsql_add(): add procedure is not defined for this attribute ('%s')\n",at->a_desc->ad_cname->bv_val,0,0); + Debug(LDAP_DEBUG_TRACE,"backsql_add(): add procedure is not defined for this attribute ('%s')\n",at->a_desc->ad_cname.bv_val,0,0); continue; } diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index ba3bfc03ca..5853597451 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -113,7 +113,7 @@ int backsql_process_filter_list(backsql_srch_info *bsi,Filter *f,int op) int backsql_process_sub_filter(backsql_srch_info *bsi,Filter *f) { int i; - backsql_at_map_rec *at=backsql_at_with_name(bsi->oc,f->f_sub_desc->ad_cname->bv_val); + backsql_at_map_rec *at=backsql_at_with_name(bsi->oc,f->f_sub_desc->ad_cname.bv_val); if (!f) return 0; @@ -208,10 +208,10 @@ int backsql_process_filter(backsql_srch_info *bsi,Filter *f) done=1; break; case LDAP_FILTER_PRESENT: - at_name=f->f_desc->ad_cname->bv_val; + at_name=f->f_desc->ad_cname.bv_val; break; default: - at_name=f->f_av_desc->ad_cname->bv_val; + at_name=f->f_av_desc->ad_cname.bv_val; break; } diff --git a/servers/slapd/back-sql/util.c b/servers/slapd/back-sql/util.c index 3de62bae80..fcb1254db2 100644 --- a/servers/slapd/back-sql/util.c +++ b/servers/slapd/back-sql/util.c @@ -93,7 +93,6 @@ int backsql_entry_addattr(Entry *e,char *at_name,char *at_val,unsigned int at_va } rc = attr_merge(e,ad,add_val); - ad_free( ad, 1 ); if( rc != 0 ) { diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index ca5fe46074..31a031963d 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -1011,7 +1011,7 @@ Attribute *backend_operational( #ifdef SLAPD_SCHEMA_DN a = ch_malloc( sizeof( Attribute ) ); - a->a_desc = ad_dup( slap_schema.si_ad_subschemaSubentry ); + a->a_desc = slap_schema.si_ad_subschemaSubentry; /* Should be backend specific */ a->a_vals = ch_malloc( 2 * sizeof( struct berval * ) ); diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 886ce341dc..8196988daf 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -192,15 +192,15 @@ do_compare( #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, "do_compare: conn %d dn (%s) attr(%s) value (%s)\n", - conn->c_connid, dn, ava.aa_desc->ad_cname->bv_val, + conn->c_connid, dn, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val )); #else Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n", - dn, ava.aa_desc->ad_cname->bv_val, ava.aa_value->bv_val ); + dn, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val ); #endif Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n", - op->o_connid, op->o_opid, dn, ava.aa_desc->ad_cname->bv_val, 0 ); + op->o_connid, op->o_opid, dn, ava.aa_desc->ad_cname.bv_val, 0 ); /* deref suffix alias if appropriate */ @@ -218,9 +218,6 @@ cleanup: free( ndn ); free( desc.bv_val ); free( value.bv_val ); - if( ava.aa_desc != NULL ) { - ad_free( ava.aa_desc, 1 ); - } return rc; } diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 2c9ce52b6f..0bea4e125c 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -215,8 +215,6 @@ str2entry( char *s ) rc = attr_merge( e, ad, vals ); - ad_free( ad, 1 ); - if( rc != 0 ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, @@ -307,10 +305,10 @@ entry2str( /* put ":[:] " line for each value */ for ( i = 0; a->a_vals[i] != NULL; i++ ) { bv = a->a_vals[i]; - tmplen = a->a_desc->ad_cname->bv_len; + tmplen = a->a_desc->ad_cname.bv_len; MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len )); ldif_sput( (char **) &ecur, LDIF_PUT_VALUE, - a->a_desc->ad_cname->bv_val, + a->a_desc->ad_cname.bv_val, bv->bv_val, bv->bv_len ); } } @@ -501,21 +499,21 @@ int entry_decode( struct berval *bv, Entry **entry ) if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "entry_decode: str2ad(%s): %s\n", type, text )); + "entry_decode: str2ad(%s): %s\n", type->bv_val, text )); #else Debug( LDAP_DEBUG_TRACE, - "<= entry_decode: str2ad(%s): %s\n", type, text, 0 ); + "<= entry_decode: str2ad(%s): %s\n", type->bv_val, text, 0 ); #endif rc = slap_bv2undef_ad( type, &ad, &text ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "entry_decode: str2undef_ad(%s): %s\n", type, text)); + "entry_decode: str2undef_ad(%s): %s\n", type->bv_val, text)); #else Debug( LDAP_DEBUG_ANY, "<= entry_decode: str2undef_ad(%s): %s\n", - type, text, 0 ); + type->bv_val, text, 0 ); #endif ber_bvfree( type ); ber_bvecfree( vals ); @@ -525,7 +523,6 @@ int entry_decode( struct berval *bv, Entry **entry ) } rc = attr_merge( e, ad, vals ); - ad_free( ad, 1 ); if( rc != 0 ) { #ifdef NEW_LOGGING @@ -591,7 +588,7 @@ int entry_encode( for ( a = e->e_attrs; a != NULL; a = a->a_next ) { rc = ber_printf( ber, "{O{V}}", - a->a_desc->ad_cname, + &a->a_desc->ad_cname, a->a_vals ); if( rc < 0 ) { goto done; diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 70aa4b5e28..b06f345935 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -118,11 +118,11 @@ get_filter( filter_escape_value( f->f_av_value, &escaped ); *fstr = ch_malloc( sizeof("(=)") - + f->f_av_desc->ad_cname->bv_len + + f->f_av_desc->ad_cname.bv_len + escaped.bv_len ); sprintf( *fstr, "(%s=%s)", - f->f_av_desc->ad_cname->bv_val, + f->f_av_desc->ad_cname.bv_val, escaped.bv_val ); ber_memfree( escaped.bv_val ); @@ -153,11 +153,11 @@ get_filter( filter_escape_value( f->f_av_value, &escaped ); *fstr = ch_malloc( sizeof("(>=)") - + f->f_av_desc->ad_cname->bv_len + + f->f_av_desc->ad_cname.bv_len + escaped.bv_len ); sprintf( *fstr, "(%s>=%s)", - f->f_av_desc->ad_cname->bv_val, + f->f_av_desc->ad_cname.bv_val, escaped.bv_val ); ber_memfree( escaped.bv_val ); @@ -179,11 +179,11 @@ get_filter( filter_escape_value( f->f_av_value, &escaped ); *fstr = ch_malloc( sizeof("(<=)") - + f->f_av_desc->ad_cname->bv_len + + f->f_av_desc->ad_cname.bv_len + escaped.bv_len ); sprintf( *fstr, "(%s<=%s)", - f->f_av_desc->ad_cname->bv_val, + f->f_av_desc->ad_cname.bv_val, escaped.bv_val ); ber_memfree( escaped.bv_val ); @@ -215,9 +215,9 @@ get_filter( ch_free( type.bv_val ); *fstr = ch_malloc( sizeof("(=*)") - + f->f_desc->ad_cname->bv_len ); + + f->f_desc->ad_cname.bv_len ); sprintf( *fstr, "(%s=*)", - f->f_desc->ad_cname->bv_val ); + f->f_desc->ad_cname.bv_val ); } break; @@ -236,11 +236,11 @@ get_filter( filter_escape_value( f->f_av_value, &escaped ); *fstr = ch_malloc( sizeof("(~=)") - + f->f_av_desc->ad_cname->bv_len + + f->f_av_desc->ad_cname.bv_len + escaped.bv_len ); sprintf( *fstr, "(%s~=%s)", - f->f_av_desc->ad_cname->bv_val, + f->f_av_desc->ad_cname.bv_val, escaped.bv_val ); ber_memfree( escaped.bv_val ); @@ -316,12 +316,12 @@ get_filter( filter_escape_value( f->f_mr_value, &escaped ); *fstr = ch_malloc( sizeof("(:dn::=)") - + (f->f_mr_desc ? f->f_mr_desc->ad_cname->bv_len : 0) + + (f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_len : 0) + (f->f_mr_rule_text ? strlen(f->f_mr_rule_text) : 0) + escaped.bv_len ); sprintf( *fstr, "(%s%s%s%s:=%s)", - (f->f_mr_desc ? f->f_mr_desc->ad_cname->bv_val : ""), + (f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_val : ""), (f->f_mr_dnattrs ? ":dn" : ""), (f->f_mr_rule_text ? ":" : ""), (f->f_mr_rule_text ? f->f_mr_rule_text : ""), @@ -474,8 +474,8 @@ get_substring_filter( if( fstr ) { *fstr = ch_malloc( sizeof("(=" /*)*/) + - f->f_sub_desc->ad_cname->bv_len ); - sprintf( *fstr, "(%s=" /*)*/, f->f_sub_desc->ad_cname->bv_val ); + f->f_sub_desc->ad_cname.bv_len ); + sprintf( *fstr, "(%s=" /*)*/, f->f_sub_desc->ad_cname.bv_val ); } for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; @@ -646,7 +646,6 @@ return_error: *fstr = NULL; } - ad_free( f->f_sub_desc, 1 ); ber_bvfree( f->f_sub_initial ); ber_bvecfree( f->f_sub_any ); ber_bvfree( f->f_sub_final ); @@ -683,7 +682,6 @@ filter_free( Filter *f ) switch ( f->f_choice ) { case LDAP_FILTER_PRESENT: - ad_free( f->f_desc, 1 ); break; case LDAP_FILTER_EQUALITY: @@ -694,7 +692,6 @@ filter_free( Filter *f ) break; case LDAP_FILTER_SUBSTRINGS: - ad_free( f->f_sub_desc, 1 ); if ( f->f_sub_initial != NULL ) { ber_bvfree( f->f_sub_initial ); } @@ -747,7 +744,7 @@ filter_print( Filter *f ) case LDAP_FILTER_EQUALITY: filter_escape_value( f->f_av_value, &escaped ); fprintf( stderr, "(%s=%s)", - f->f_av_desc->ad_cname->bv_val, + f->f_av_desc->ad_cname.bv_val, escaped.bv_val ); ber_memfree( escaped.bv_val ); break; @@ -755,7 +752,7 @@ filter_print( Filter *f ) case LDAP_FILTER_GE: filter_escape_value( f->f_av_value, &escaped ); fprintf( stderr, "(%s>=%s)", - f->f_av_desc->ad_cname->bv_val, + f->f_av_desc->ad_cname.bv_val, escaped.bv_val ); ber_memfree( escaped.bv_val ); break; @@ -763,7 +760,7 @@ filter_print( Filter *f ) case LDAP_FILTER_LE: filter_escape_value( f->f_av_value, &escaped ); fprintf( stderr, "(%s<=%s)", - f->f_ava->aa_desc->ad_cname->bv_val, + f->f_ava->aa_desc->ad_cname.bv_val, escaped.bv_val ); ber_memfree( escaped.bv_val ); break; @@ -771,14 +768,14 @@ filter_print( Filter *f ) case LDAP_FILTER_APPROX: filter_escape_value( f->f_av_value, &escaped ); fprintf( stderr, "(%s~=%s)", - f->f_ava->aa_desc->ad_cname->bv_val, + f->f_ava->aa_desc->ad_cname.bv_val, escaped.bv_val ); ber_memfree( escaped.bv_val ); break; case LDAP_FILTER_SUBSTRINGS: fprintf( stderr, "(%s=" /*)*/, - f->f_sub_desc->ad_cname->bv_val ); + f->f_sub_desc->ad_cname.bv_val ); if ( f->f_sub_initial != NULL ) { filter_escape_value( f->f_sub_initial, &escaped ); fprintf( stderr, "%s", @@ -804,7 +801,7 @@ filter_print( Filter *f ) case LDAP_FILTER_PRESENT: fprintf( stderr, "(%s=*)", - f->f_desc->ad_cname->bv_val ); + f->f_desc->ad_cname.bv_val ); break; case LDAP_FILTER_AND: diff --git a/servers/slapd/init.c b/servers/slapd/init.c index ebdb637dab..cfd38d77a2 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -43,6 +43,7 @@ ldap_pvt_thread_mutex_t gmtime_mutex; #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) ldap_pvt_thread_mutex_t passwd_mutex; #endif +ldap_pvt_thread_mutex_t ad_mutex; int num_conns; long num_ops_initiated; @@ -117,6 +118,7 @@ slap_init( int mode, const char *name ) ldap_pvt_thread_mutex_init( &num_sent_mutex ); ldap_pvt_thread_mutex_init( &gmtime_mutex ); + ldap_pvt_thread_mutex_init( &ad_mutex ); #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) ldap_pvt_thread_mutex_init( &passwd_mutex ); #endif diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 2089bff883..c3e21d1b8e 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -541,7 +541,7 @@ int slap_mods_opattrs( if( op->o_tag == LDAP_REQ_ADD ) { mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) ); mod->sml_op = mop; - mod->sml_desc = ad_dup( slap_schema.si_ad_creatorsName ); + mod->sml_desc = slap_schema.si_ad_creatorsName; mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) ); mod->sml_bvalues[0] = ber_bvdup( &name ); mod->sml_bvalues[1] = NULL; @@ -551,7 +551,7 @@ int slap_mods_opattrs( mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) ); mod->sml_op = mop; - mod->sml_desc = ad_dup( slap_schema.si_ad_createTimestamp ); + mod->sml_desc = slap_schema.si_ad_createTimestamp; mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) ); mod->sml_bvalues[0] = ber_bvdup( ×tamp ); mod->sml_bvalues[1] = NULL; @@ -561,7 +561,7 @@ int slap_mods_opattrs( mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) ); mod->sml_op = mop; - mod->sml_desc = ad_dup( slap_schema.si_ad_modifiersName ); + mod->sml_desc = slap_schema.si_ad_modifiersName; mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) ); mod->sml_bvalues[0] = ber_bvdup( &name ); mod->sml_bvalues[1] = NULL; @@ -570,7 +570,7 @@ int slap_mods_opattrs( mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) ); mod->sml_op = mop; - mod->sml_desc = ad_dup( slap_schema.si_ad_modifyTimestamp ); + mod->sml_desc = slap_schema.si_ad_modifyTimestamp; mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) ); mod->sml_bvalues[0] = ber_bvdup( ×tamp ); mod->sml_bvalues[1] = NULL; diff --git a/servers/slapd/mods.c b/servers/slapd/mods.c index 7b59cc5e1e..328cfc7287 100644 --- a/servers/slapd/mods.c +++ b/servers/slapd/mods.c @@ -24,8 +24,6 @@ slap_mod_free( int freeit ) { - ad_free( mod->sm_desc, 1 ); - if ( mod->sm_bvalues != NULL ) ber_bvecfree( mod->sm_bvalues ); diff --git a/servers/slapd/mra.c b/servers/slapd/mra.c index fe883e6e54..1e66f91f6d 100644 --- a/servers/slapd/mra.c +++ b/servers/slapd/mra.c @@ -21,7 +21,6 @@ mra_free( int freeit ) { - ad_free( mra->ma_desc, 1 ); ch_free( mra->ma_rule_text ); ber_bvfree( mra->ma_value ); if ( freeit ) { diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index e8bf36c2f8..05acf2ded5 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -28,12 +28,8 @@ LDAP_SLAPD_F (int) slap_bv2ad LDAP_P(( LDAP_SLAPD_F (AttributeDescription *) ad_dup LDAP_P(( AttributeDescription *desc )); -LDAP_SLAPD_F (void) ad_free LDAP_P(( - AttributeDescription *desc, - int freeit )); - #define ad_cmp(l,r) ( strcasecmp( \ - (l)->ad_cname->bv_val, (r)->ad_cname->bv_val )) + (l)->ad_cname.bv_val, (r)->ad_cname.bv_val )) LDAP_SLAPD_F (int) is_ad_subtype LDAP_P(( AttributeDescription *sub, diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index 2dc8344f8e..e309d942cf 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -136,7 +136,7 @@ replog( ml = change; for ( ; ml != NULL; ml = ml->sml_next ) { char *type; - type = ml->sml_desc->ad_cname->bv_val; + type = ml->sml_desc->ad_cname.bv_val; switch ( ml->sml_op ) { case LDAP_MOD_ADD: fprintf( fp, "add: %s\n", type ); diff --git a/servers/slapd/result.c b/servers/slapd/result.c index f869f86c91..0248a659ac 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -810,7 +810,7 @@ send_search_entry( for ( a = e->e_attrs; a != NULL; a = a->a_next ) { AttributeDescription *desc = a->a_desc; - char *type = desc->ad_cname->bv_val; + char *type = desc->ad_cname.bv_val; if ( attrs == NULL ) { /* all addrs request, skip operational attributes */ @@ -836,10 +836,10 @@ send_search_entry( #ifdef NEW_LOGGING LDAP_LOG(( "acl", LDAP_LEVEL_INFO, "send_search_entry: conn %d access to attribute %s not allowed\n", - op->o_connid, desc->ad_cname->bv_val )); + op->o_connid, desc->ad_cname.bv_val )); #else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n", - desc->ad_cname->bv_val, 0, 0 ); + desc->ad_cname.bv_val, 0, 0 ); #endif continue; @@ -868,11 +868,11 @@ send_search_entry( #ifdef NEW_LOGGING LDAP_LOG(( "acl", LDAP_LEVEL_INFO, "send_search_entry: conn %d access to attribute %s, value %d not allowed\n", - op->o_connid, desc->ad_cname->bv_val, i )); + op->o_connid, desc->ad_cname.bv_val, i )); #else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s, value %d not allowed\n", - desc->ad_cname->bv_val, i, 0 ); + desc->ad_cname.bv_val, i, 0 ); #endif continue; @@ -943,16 +943,16 @@ send_search_entry( #ifdef NEW_LOGGING LDAP_LOG(( "acl", LDAP_LEVEL_INFO, "send_search_entry: conn %s access to attribute %s not allowed\n", - op->o_connid, desc->ad_cname->bv_val )); + op->o_connid, desc->ad_cname.bv_val )); #else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n", - desc->ad_cname->bv_val, 0, 0 ); + desc->ad_cname.bv_val, 0, 0 ); #endif continue; } - rc = ber_printf( ber, "{s[" /*]}*/ , desc->ad_cname->bv_val ); + rc = ber_printf( ber, "{s[" /*]}*/ , desc->ad_cname.bv_val ); if ( rc == -1 ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR, @@ -977,11 +977,11 @@ send_search_entry( #ifdef NEW_LOGGING LDAP_LOG(( "acl", LDAP_LEVEL_INFO, "send_search_entry: conn %d access to %s, value %d not allowed\n", - op->o_connid, desc->ad_cname->bv_val, i )); + op->o_connid, desc->ad_cname.bv_val, i )); #else Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s, value %d not allowed\n", - desc->ad_cname->bv_val, i, 0 ); + desc->ad_cname.bv_val, i, 0 ); #endif continue; diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index fcc6c05ce9..5a8b689be5 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -567,7 +567,6 @@ slap_sasl_check_authz(char *searchDN, char *assertDN, char *attr, char *authc) COMPLETE: if( vals ) ber_bvecfree( vals ); - if( ad ) ad_free( ad, 1 ); #ifdef NEW_LOGGING LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 6f7d993dd6..4fcc00fbf9 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -48,7 +48,7 @@ entry_schema_check( if( is_at_single_value( a->a_desc->ad_type ) && a->a_vals[1] != NULL ) { - char *type = a->a_desc->ad_cname->bv_val; + char *type = a->a_desc->ad_cname.bv_val; snprintf( textbuf, textlen, "attribute '%s' cannot have multiple values", @@ -139,7 +139,7 @@ entry_schema_check( for ( a = e->e_attrs; a != NULL; a = a->a_next ) { int ret = oc_check_allowed( a->a_desc->ad_type, aoc->a_vals ); if ( ret != LDAP_SUCCESS ) { - char *type = a->a_desc->ad_cname->bv_val; + char *type = a->a_desc->ad_cname.bv_val; snprintf( textbuf, textlen, "attribute '%s' not allowed", diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index a8c770a03f..cef3d3e3d9 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -364,6 +364,8 @@ typedef struct slap_matching_rule { #define smr_extensions smr_mrule.mr_extensions } MatchingRule; +struct slap_attr_desc; + typedef struct slap_attribute_type { char *sat_cname; LDAPAttributeType sat_atype; @@ -374,6 +376,7 @@ typedef struct slap_attribute_type { MatchingRule *sat_ordering; MatchingRule *sat_substr; Syntax *sat_syntax; + struct slap_attr_desc *sat_ad; struct slap_attribute_type *sat_next; #define sat_oid sat_atype.at_oid #define sat_names sat_atype.at_names @@ -419,15 +422,16 @@ typedef struct slap_object_class { * represents a recognized attribute description ( type + options ) */ typedef struct slap_attr_desc { - struct berval *ad_cname; /* canonical name, must be specified */ + struct slap_attr_desc *ad_next; AttributeType *ad_type; /* attribute type, must be specified */ - char *ad_lang; /* NULL if no language tags */ + struct berval ad_cname; /* canonical name, must be specified */ + struct berval ad_lang; /* empty if no language tags */ unsigned ad_flags; #define SLAP_DESC_NONE 0x0U #define SLAP_DESC_BINARY 0x1U } AttributeDescription; -#define slap_ad_is_lang(ad) ( (ad)->ad_lang != NULL ) +#define slap_ad_is_lang(ad) ( (ad)->ad_lang.bv_len != 0 ) #define slap_ad_is_binary(ad) ( (int)((ad)->ad_flags & SLAP_DESC_BINARY) ? 1 : 0 ) /* -- 2.39.5