assert( desc != NULL );
assert( access > ACL_NONE );
- attr = desc->ad_cname->bv_val;
+ attr = desc->ad_cname.bv_val;
assert( attr != NULL );
assert( count != NULL );
assert( desc != NULL );
- attr = desc->ad_cname->bv_val;
+ attr = desc->ad_cname.bv_val;
assert( attr != NULL );
assert( mask != NULL );
assert( desc != NULL );
- attr = desc->ad_cname->bv_val;
+ attr = desc->ad_cname.bv_val;
assert( attr != NULL );
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 );
#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;
}
}
ber_bvecfree(bvals);
}
- ad_free(desc, 1);
}
}
ch_free(ndn);
{
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);
}
done:
- if( grp_ad != NULL ) ad_free( grp_ad, 1 );
ch_free(grpdn);
ch_free(grpat);
ch_free(grpoc);
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 );
}
}
- ad_free( ad, 1 );
return rc;
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();
}
}
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 ) {
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 );
}
}
}
#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
#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 )
{
int rtn = LDAP_UNDEFINED_TYPE;
int i;
- AttributeDescription desc;
- char **tokens;
+ AttributeDescription desc, *d2;
+ char *name, *options;
assert( ad != NULL );
assert( *ad == NULL ); /* temporary */
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;
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;
}
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;
}
rc = is_ad_subtype( desc, ad );
- ad_free( ad, 1 );
-
if( rc ) return 1;
}
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";
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;
}
-
void
attr_free( Attribute *a )
{
- ad_free( a->a_desc, 1 );
ber_bvecfree( a->a_vals );
free( 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;
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;
}
int freeit
)
{
- ad_free( ava->aa_desc, 1 );
ber_bvfree( ava->aa_value );
if ( freeit ) {
ch_free( (char *) ava );
ch_free( value.bv_val );
if( rc != LDAP_SUCCESS ) {
- ad_free( aa->aa_desc, 1 );
ch_free( aa );
return rc;
}
#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;
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 );
AttributeDescription *ad
)
{
- return strcasecmp(desc, ad->ad_cname->bv_val);
+ return strcasecmp(desc, ad->ad_cname.bv_val);
}
static int
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 *
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);
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;
/* 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;
}
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;
}
}
done:
- ad_free( ad, 1 );
return rc;
}
Backend *be,
DB_TXN *txn,
AttributeType *type,
- const char *lang,
+ struct berval *lang,
struct berval **vals,
ID id,
int op,
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 );
}
rc = index_at_values( be, txn,
- desc->ad_type, desc->ad_lang,
+ desc->ad_type, &desc->ad_lang,
vals, id, op,
&dbname, &mask );
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 );
{
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 */
"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;
}
"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;
}
val.bv_len = strlen(val.bv_val);
attr_merge( e, ad, vals );
-
- ad_free( ad, 1 );
}
}
val.bv_val = domain;
val.bv_len = strlen(domain);
attr_merge( e, ad, vals );
-
- ad_free( ad, 1 );
}
}
* 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;
}
}
} 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);
}
#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 );
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];
}
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;
}
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);
#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;
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 );
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,
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
#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 );
#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 );
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];
/* 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;
}
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;
}
dbname, LDBM_SUFFIX, 0 );
#endif
- ad_free( ad, 1 );
return LDAP_OTHER;
}
}
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,
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 );
}
(void) index_at_values( be,
- desc->ad_type, desc->ad_lang,
+ desc->ad_type, &desc->ad_lang,
vals, id, op,
&dbname, &mask );
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 );
{
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 */
"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 );
"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 );
* 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;
}
}
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;
*/
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 ) {
*/
} 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;
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 ) {
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 ];
* lastmod should always be <off>
*/
#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;
}
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);
}
attr_merge( e, desc, vals );
- ad_free( desc, 1 );
-
free(rdn);
rdn = NULL;
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 );
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! */ );
}
}
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;
}
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;
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;
}
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;
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;
}
}
rc = attr_merge(e,ad,add_val);
- ad_free( ad, 1 );
if( rc != 0 )
{
#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 * ) );
#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 */
free( ndn );
free( desc.bv_val );
free( value.bv_val );
- if( ava.aa_desc != NULL ) {
- ad_free( ava.aa_desc, 1 );
- }
return rc;
}
rc = attr_merge( e, ad, vals );
- ad_free( ad, 1 );
-
if( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
/* put "<type>:[:] <value>" 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 );
}
}
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 );
}
rc = attr_merge( e, ad, vals );
- ad_free( ad, 1 );
if( rc != 0 ) {
#ifdef NEW_LOGGING
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;
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 );
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 );
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 );
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;
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 );
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 : ""),
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;
*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 );
switch ( f->f_choice ) {
case LDAP_FILTER_PRESENT:
- ad_free( f->f_desc, 1 );
break;
case LDAP_FILTER_EQUALITY:
break;
case LDAP_FILTER_SUBSTRINGS:
- ad_free( f->f_sub_desc, 1 );
if ( f->f_sub_initial != NULL ) {
ber_bvfree( f->f_sub_initial );
}
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;
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;
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;
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",
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:
#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;
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
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;
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;
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;
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;
int freeit
)
{
- ad_free( mod->sm_desc, 1 );
-
if ( mod->sm_bvalues != NULL )
ber_bvecfree( mod->sm_bvalues );
int freeit
)
{
- ad_free( mra->ma_desc, 1 );
ch_free( mra->ma_rule_text );
ber_bvfree( mra->ma_value );
if ( freeit ) {
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,
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 );
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 */
#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;
#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;
#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,
#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;
COMPLETE:
if( vals ) ber_bvecfree( vals );
- if( ad ) ad_free( ad, 1 );
#ifdef NEW_LOGGING
LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY,
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",
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",
#define smr_extensions smr_mrule.mr_extensions
} MatchingRule;
+struct slap_attr_desc;
+
typedef struct slap_attribute_type {
char *sat_cname;
LDAPAttributeType sat_atype;
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
* 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 )
/*