mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
Attribute/Modification value counters
This commit is contained in:
parent
b99749aba4
commit
c4dbe1a274
27 changed files with 153 additions and 80 deletions
|
|
@ -380,6 +380,7 @@ slap_mods2entry(
|
|||
char *textbuf, size_t textlen )
|
||||
{
|
||||
Attribute **tail;
|
||||
int i;
|
||||
|
||||
if ( initial ) {
|
||||
assert( (*e)->e_attrs == NULL );
|
||||
|
|
@ -400,7 +401,7 @@ slap_mods2entry(
|
|||
if( attr != NULL ) {
|
||||
#define SLURPD_FRIENDLY
|
||||
#ifdef SLURPD_FRIENDLY
|
||||
ber_len_t i,j;
|
||||
int j;
|
||||
|
||||
if ( !initial ) {
|
||||
/*
|
||||
|
|
@ -413,12 +414,9 @@ slap_mods2entry(
|
|||
return LDAP_SUCCESS;
|
||||
}
|
||||
|
||||
for( i=0; attr->a_vals[i].bv_val; i++ ) {
|
||||
/* count them */
|
||||
}
|
||||
for( j=0; mods->sml_values[j].bv_val; j++ ) {
|
||||
/* count them */
|
||||
}
|
||||
i = attr->a_numvals;
|
||||
j = mods->sml_numvals;
|
||||
attr->a_numvals += j;
|
||||
j++; /* NULL */
|
||||
|
||||
attr->a_vals = ch_realloc( attr->a_vals,
|
||||
|
|
@ -466,9 +464,9 @@ slap_mods2entry(
|
|||
attr = attr_alloc( mods->sml_desc );
|
||||
|
||||
/* move values to attr structure */
|
||||
i = mods->sml_numvals;
|
||||
attr->a_numvals = mods->sml_numvals;
|
||||
if ( dup ) {
|
||||
int i;
|
||||
for ( i = 0; mods->sml_values[i].bv_val; i++ ) /* EMPTY */;
|
||||
attr->a_vals = (BerVarray) ch_calloc( i+1, sizeof( BerValue ));
|
||||
for ( i = 0; mods->sml_values[i].bv_val; i++ ) {
|
||||
ber_dupbv( &attr->a_vals[i], &mods->sml_values[i] );
|
||||
|
|
@ -480,8 +478,7 @@ slap_mods2entry(
|
|||
|
||||
if ( mods->sml_nvalues ) {
|
||||
if ( dup ) {
|
||||
int i;
|
||||
for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) /* EMPTY */;
|
||||
i = mods->sml_numvals;
|
||||
attr->a_nvals = (BerVarray) ch_calloc( i+1, sizeof( BerValue ));
|
||||
for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) {
|
||||
ber_dupbv( &attr->a_nvals[i], &mods->sml_nvalues[i] );
|
||||
|
|
@ -528,7 +525,8 @@ slap_entry2mods(
|
|||
|
||||
mod->sml_type = a_new_desc->ad_cname;
|
||||
|
||||
for ( count = 0; a_new->a_vals[count].bv_val; count++ ) /* EMPTY */;
|
||||
count = a_new->a_numvals;
|
||||
mod->sml_numvals = a_new->a_numvals;
|
||||
|
||||
mod->sml_values = (struct berval*) malloc(
|
||||
(count+1) * sizeof( struct berval) );
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ attr_clean( Attribute *a )
|
|||
a->a_comp_data = NULL;
|
||||
#endif
|
||||
a->a_flags = 0;
|
||||
a->a_numvals = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -213,12 +214,9 @@ attr_dup2( Attribute *tmp, Attribute *a )
|
|||
if ( a->a_vals != NULL ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) {
|
||||
/* EMPTY */ ;
|
||||
}
|
||||
|
||||
tmp->a_vals = ch_malloc( (i + 1) * sizeof(struct berval) );
|
||||
for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) {
|
||||
tmp->a_numvals = a->a_numvals;
|
||||
tmp->a_vals = ch_malloc( (tmp->a_numvals + 1) * sizeof(struct berval) );
|
||||
for ( i = 0; i < tmp->a_numvals; i++ ) {
|
||||
ber_dupbv( &tmp->a_vals[i], &a->a_vals[i] );
|
||||
if ( BER_BVISNULL( &tmp->a_vals[i] ) ) break;
|
||||
/* FIXME: error? */
|
||||
|
|
@ -231,7 +229,7 @@ attr_dup2( Attribute *tmp, Attribute *a )
|
|||
if ( a->a_nvals != a->a_vals ) {
|
||||
int j;
|
||||
|
||||
tmp->a_nvals = ch_malloc( (i + 1) * sizeof(struct berval) );
|
||||
tmp->a_nvals = ch_malloc( (tmp->a_numvals + 1) * sizeof(struct berval) );
|
||||
for ( j = 0; !BER_BVISNULL( &a->a_nvals[j] ); j++ ) {
|
||||
assert( j < i );
|
||||
ber_dupbv( &tmp->a_nvals[j], &a->a_nvals[j] );
|
||||
|
|
@ -283,6 +281,55 @@ attrs_dup( Attribute *a )
|
|||
return anew;
|
||||
}
|
||||
|
||||
int
|
||||
attr_valadd(
|
||||
Attribute *a,
|
||||
BerVarray vals,
|
||||
BerVarray nvals,
|
||||
int nn )
|
||||
{
|
||||
int i;
|
||||
BerVarray v2;
|
||||
|
||||
v2 = (BerVarray) SLAP_REALLOC( (char *) a->a_vals,
|
||||
(a->a_numvals + nn + 1) * sizeof(struct berval) );
|
||||
if( v2 == NULL ) {
|
||||
Debug(LDAP_DEBUG_TRACE,
|
||||
"attr_valadd: SLAP_REALLOC failed.\n", 0, 0, 0 );
|
||||
return LBER_ERROR_MEMORY;
|
||||
}
|
||||
a->a_vals = v2;
|
||||
if ( nvals ) {
|
||||
v2 = (BerVarray) SLAP_REALLOC( (char *) a->a_nvals,
|
||||
(a->a_numvals + nn + 1) * sizeof(struct berval) );
|
||||
if( v2 == NULL ) {
|
||||
Debug(LDAP_DEBUG_TRACE,
|
||||
"attr_valadd: SLAP_REALLOC failed.\n", 0, 0, 0 );
|
||||
return LBER_ERROR_MEMORY;
|
||||
}
|
||||
a->a_nvals = v2;
|
||||
} else {
|
||||
a->a_nvals = a->a_vals;
|
||||
}
|
||||
|
||||
v2 = &a->a_vals[a->a_numvals];
|
||||
for ( i = 0 ; i < nn; i++ ) {
|
||||
ber_dupbv( &v2[i], &vals[i] );
|
||||
if ( BER_BVISNULL( &v2[i] ) ) break;
|
||||
}
|
||||
BER_BVZERO( &v2[i] );
|
||||
|
||||
if ( nvals ) {
|
||||
v2 = &a->a_nvals[a->a_numvals];
|
||||
for ( i = 0 ; i < nn; i++ ) {
|
||||
ber_dupbv( &v2[i], &nvals[i] );
|
||||
if ( BER_BVISNULL( &v2[i] ) ) break;
|
||||
}
|
||||
BER_BVZERO( &v2[i] );
|
||||
}
|
||||
a->a_numvals += i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* attr_merge - merge the given type and value with the list of
|
||||
|
|
@ -302,7 +349,7 @@ attr_merge(
|
|||
BerVarray vals,
|
||||
BerVarray nvals )
|
||||
{
|
||||
int rc;
|
||||
int i = 0;
|
||||
|
||||
Attribute **a;
|
||||
|
||||
|
|
@ -325,18 +372,10 @@ attr_merge(
|
|||
|| ( (*a)->a_nvals != (*a)->a_vals ) ) ) );
|
||||
}
|
||||
|
||||
rc = value_add( &(*a)->a_vals, vals );
|
||||
|
||||
if ( rc == LDAP_SUCCESS ) {
|
||||
if ( nvals ) {
|
||||
rc = value_add( &(*a)->a_nvals, nvals );
|
||||
/* FIXME: what if rc != LDAP_SUCCESS ? */
|
||||
} else {
|
||||
(*a)->a_nvals = (*a)->a_vals;
|
||||
}
|
||||
if ( vals != NULL ) {
|
||||
for ( ; !BER_BVISNULL( &vals[i] ); i++ ) ;
|
||||
}
|
||||
|
||||
return rc;
|
||||
return attr_valadd( *a, vals, nvals, i );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -415,7 +454,6 @@ attr_merge_one(
|
|||
struct berval *val,
|
||||
struct berval *nval )
|
||||
{
|
||||
int rc;
|
||||
Attribute **a;
|
||||
|
||||
for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
|
||||
|
|
@ -428,17 +466,7 @@ attr_merge_one(
|
|||
*a = attr_alloc( desc );
|
||||
}
|
||||
|
||||
rc = value_add_one( &(*a)->a_vals, val );
|
||||
|
||||
if ( rc == LDAP_SUCCESS ) {
|
||||
if ( nval ) {
|
||||
rc = value_add_one( &(*a)->a_nvals, nval );
|
||||
/* FIXME: what if rc != LDAP_SUCCESS ? */
|
||||
} else {
|
||||
(*a)->a_nvals = (*a)->a_vals;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
return attr_valadd( *a, val, nval, 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -371,26 +371,22 @@ bdb_monitor_db_open( BackendDB *be )
|
|||
}
|
||||
|
||||
a->a_desc = slap_schema.si_ad_objectClass;
|
||||
value_add_one( &a->a_vals, &oc_olmBDBDatabase->soc_cname );
|
||||
a->a_nvals = a->a_vals;
|
||||
attr_valadd( a, &oc_olmBDBDatabase->soc_cname, NULL, 1 );
|
||||
next = a->a_next;
|
||||
|
||||
{
|
||||
struct berval bv = BER_BVC( "0" );
|
||||
|
||||
next->a_desc = ad_olmBDBEntryCache;
|
||||
value_add_one( &next->a_vals, &bv );
|
||||
next->a_nvals = next->a_vals;
|
||||
attr_valadd( next, &bv, NULL, 1 );
|
||||
next = next->a_next;
|
||||
|
||||
next->a_desc = ad_olmBDBDNCache;
|
||||
value_add_one( &next->a_vals, &bv );
|
||||
next->a_nvals = next->a_vals;
|
||||
attr_valadd( next, &bv, NULL, 1 );
|
||||
next = next->a_next;
|
||||
|
||||
next->a_desc = ad_olmBDBIDLCache;
|
||||
value_add_one( &next->a_vals, &bv );
|
||||
next->a_nvals = next->a_vals;
|
||||
attr_valadd( next, &bv, NULL, 1 );
|
||||
next = next->a_next;
|
||||
}
|
||||
|
||||
|
|
@ -432,6 +428,7 @@ bdb_monitor_db_open( BackendDB *be )
|
|||
next->a_desc = ad_olmDbDirectory;
|
||||
next->a_vals = ch_calloc( sizeof( struct berval ), 2 );
|
||||
next->a_vals[ 0 ] = bv;
|
||||
next->a_numvals = 1;
|
||||
|
||||
if ( BER_BVISNULL( &nbv ) ) {
|
||||
next->a_nvals = next->a_vals;
|
||||
|
|
|
|||
|
|
@ -682,6 +682,7 @@ ldap_build_entry(
|
|||
for ( last = 0; !BER_BVISNULL( &attr->a_vals[ last ] ); last++ )
|
||||
/* just count vals */ ;
|
||||
}
|
||||
attr->a_numvals = last;
|
||||
|
||||
validate = attr->a_desc->ad_type->sat_syntax->ssyn_validate;
|
||||
pretty = attr->a_desc->ad_type->sat_syntax->ssyn_pretty;
|
||||
|
|
|
|||
|
|
@ -1885,6 +1885,7 @@ meta_send_entry(
|
|||
for ( last = 0; !BER_BVISNULL( &attr->a_vals[ last ] ); ++last )
|
||||
;
|
||||
}
|
||||
attr->a_numvals = last;
|
||||
|
||||
validate = attr->a_desc->ad_type->sat_syntax->ssyn_validate;
|
||||
pretty = attr->a_desc->ad_type->sat_syntax->ssyn_pretty;
|
||||
|
|
|
|||
|
|
@ -645,13 +645,13 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
|
|||
|
||||
/* Make space for the array of values */
|
||||
attr = attr_alloc( at->bam_true_ad );
|
||||
attr->a_numvals = count;
|
||||
attr->a_vals = ch_calloc( count + 1, sizeof( struct berval ) );
|
||||
if ( attr->a_vals == NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "Out of memory!\n", 0,0,0 );
|
||||
ch_free( attr );
|
||||
return 1;
|
||||
}
|
||||
memset( attr->a_vals, 0, ( count + 1 ) * sizeof( struct berval ) );
|
||||
if ( normfunc ) {
|
||||
attr->a_nvals = ch_calloc( count + 1, sizeof( struct berval ) );
|
||||
if ( attr->a_nvals == NULL ) {
|
||||
|
|
@ -659,8 +659,6 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
|
|||
ch_free( attr );
|
||||
return 1;
|
||||
|
||||
} else {
|
||||
memset( attr->a_nvals, 0, ( count + 1 ) * sizeof( struct berval ) );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ backsql_operational_entryUUID( backsql_info *bi, backsql_entryID *id )
|
|||
|
||||
a = attr_alloc( desc );
|
||||
|
||||
a->a_numvals = 1;
|
||||
a->a_vals = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
|
||||
a->a_vals[ 0 ] = val;
|
||||
BER_BVZERO( &a->a_vals[ 1 ] );
|
||||
|
|
@ -74,6 +75,7 @@ backsql_operational_entryCSN( Operation *op )
|
|||
Attribute *a;
|
||||
|
||||
a = attr_alloc( slap_schema.si_ad_entryCSN );
|
||||
a->a_numvals = 1;
|
||||
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
|
||||
BER_BVZERO( &a->a_vals[ 1 ] );
|
||||
|
||||
|
|
|
|||
|
|
@ -5384,6 +5384,7 @@ config_check_schema(Operation *op, CfBackInfo *cfb)
|
|||
ber_bvarray_free( a->a_vals );
|
||||
a->a_vals = NULL;
|
||||
a->a_nvals = NULL;
|
||||
a->a_numvals = 0;
|
||||
}
|
||||
oidm_unparse( &bv, NULL, NULL, 1 );
|
||||
attr_merge_normalize( e, cfAd_om, bv, NULL );
|
||||
|
|
@ -5398,6 +5399,7 @@ config_check_schema(Operation *op, CfBackInfo *cfb)
|
|||
ber_bvarray_free( a->a_vals );
|
||||
a->a_vals = NULL;
|
||||
a->a_nvals = NULL;
|
||||
a->a_numvals = 0;
|
||||
}
|
||||
at_unparse( &bv, NULL, NULL, 1 );
|
||||
attr_merge_normalize( e, cfAd_attr, bv, NULL );
|
||||
|
|
@ -5412,6 +5414,7 @@ config_check_schema(Operation *op, CfBackInfo *cfb)
|
|||
ber_bvarray_free( a->a_vals );
|
||||
a->a_vals = NULL;
|
||||
a->a_nvals = NULL;
|
||||
a->a_numvals = 0;
|
||||
}
|
||||
oc_unparse( &bv, NULL, NULL, 1 );
|
||||
attr_merge_normalize( e, cfAd_oc, bv, NULL );
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ str2entry2( char *s, int checkvals )
|
|||
atail->a_next = attr_alloc( NULL );
|
||||
atail = atail->a_next;
|
||||
atail->a_flags = 0;
|
||||
atail->a_numvals = attr_cnt;
|
||||
atail->a_desc = ad_prev;
|
||||
atail->a_vals = ch_malloc( (attr_cnt + 1) * sizeof(struct berval));
|
||||
if( ad_prev->ad_type->sat_equality &&
|
||||
|
|
@ -744,6 +745,7 @@ int entry_encode(Entry *e, struct berval *bv)
|
|||
*ptr++ = '\0';
|
||||
if (a->a_vals) {
|
||||
for (i=0; a->a_vals[i].bv_val; i++);
|
||||
assert( i == a->a_numvals );
|
||||
entry_putlen(&ptr, i);
|
||||
for (i=0; a->a_vals[i].bv_val; i++) {
|
||||
entry_putlen(&ptr, a->a_vals[i].bv_len);
|
||||
|
|
@ -805,7 +807,7 @@ int entry_decode(EntryHeader *eh, Entry **e, void *ctx)
|
|||
int entry_decode(EntryHeader *eh, Entry **e)
|
||||
#endif
|
||||
{
|
||||
int i, j, count, nattrs, nvals;
|
||||
int i, j, nattrs, nvals;
|
||||
int rc;
|
||||
Attribute *a;
|
||||
Entry *x;
|
||||
|
|
@ -857,7 +859,8 @@ int entry_decode(EntryHeader *eh, Entry **e)
|
|||
ptr += i + 1;
|
||||
a->a_desc = ad;
|
||||
a->a_flags = SLAP_ATTR_DONT_FREE_DATA | SLAP_ATTR_DONT_FREE_VALS;
|
||||
count = j = entry_getlen(&ptr);
|
||||
j = entry_getlen(&ptr);
|
||||
a->a_numvals = j;
|
||||
a->a_vals = bptr;
|
||||
|
||||
while (j) {
|
||||
|
|
@ -962,6 +965,7 @@ Entry *entry_dup_bv( Entry *e )
|
|||
dst->a_desc = src->a_desc;
|
||||
dst->a_flags = SLAP_ATTR_DONT_FREE_DATA | SLAP_ATTR_DONT_FREE_VALS;
|
||||
dst->a_vals = bvl;
|
||||
dst->a_numvals = src->a_numvals;
|
||||
for ( i=0; src->a_vals[i].bv_val; i++ ) {
|
||||
bvl->bv_len = src->a_vals[i].bv_len;
|
||||
bvl->bv_val = ptr;
|
||||
|
|
|
|||
|
|
@ -585,6 +585,7 @@ int slap_mods_check(
|
|||
ml->sml_values[nvals] = pval;
|
||||
}
|
||||
}
|
||||
ml->sml_numvals = nvals;
|
||||
|
||||
/*
|
||||
* a rough single value check... an additional check is needed
|
||||
|
|
@ -946,6 +947,7 @@ void slap_mods_opattrs(
|
|||
mod->sml_next = NULL;
|
||||
BER_BVZERO( &mod->sml_type );
|
||||
mod->sml_desc = slap_schema.si_ad_entryCSN;
|
||||
mod->sml_numvals = 1;
|
||||
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( &mod->sml_values[0], &csn );
|
||||
BER_BVZERO( &mod->sml_values[1] );
|
||||
|
|
@ -963,6 +965,7 @@ void slap_mods_opattrs(
|
|||
mod->sml_next = NULL;
|
||||
BER_BVZERO( &mod->sml_type );
|
||||
mod->sml_desc = slap_schema.si_ad_modifiersName;
|
||||
mod->sml_numvals = 1;
|
||||
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( &mod->sml_values[0], &name );
|
||||
BER_BVZERO( &mod->sml_values[1] );
|
||||
|
|
@ -983,6 +986,7 @@ void slap_mods_opattrs(
|
|||
mod->sml_next = NULL;
|
||||
BER_BVZERO( &mod->sml_type );
|
||||
mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
|
||||
mod->sml_numvals = 1;
|
||||
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( &mod->sml_values[0], ×tamp );
|
||||
BER_BVZERO( &mod->sml_values[1] );
|
||||
|
|
|
|||
|
|
@ -428,6 +428,7 @@ slap_modrdn2mods(
|
|||
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications ) );
|
||||
mod_tmp->sml_desc = desc;
|
||||
BER_BVZERO( &mod_tmp->sml_type );
|
||||
mod_tmp->sml_numvals = 1;
|
||||
mod_tmp->sml_values = ( BerVarray )ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( &mod_tmp->sml_values[0], &new_rdn[a_cnt]->la_value );
|
||||
mod_tmp->sml_values[1].bv_val = NULL;
|
||||
|
|
@ -469,6 +470,7 @@ slap_modrdn2mods(
|
|||
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications ) );
|
||||
mod_tmp->sml_desc = desc;
|
||||
BER_BVZERO( &mod_tmp->sml_type );
|
||||
mod_tmp->sml_numvals = 1;
|
||||
mod_tmp->sml_values = ( BerVarray )ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( &mod_tmp->sml_values[0], &old_rdn[d_cnt]->la_value );
|
||||
mod_tmp->sml_values[1].bv_val = NULL;
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ modify_delete_vindex(
|
|||
free( a->a_nvals[j].bv_val );
|
||||
a->a_nvals[j].bv_val = &dummy;
|
||||
}
|
||||
a->a_numvals--;
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ slap_operational_subschemaSubentry( Backend *be )
|
|||
|
||||
a = attr_alloc( slap_schema.si_ad_subschemaSubentry );
|
||||
|
||||
a->a_numvals = 1;
|
||||
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( a->a_vals, &frontendDB->be_schemadn );
|
||||
a->a_vals[1].bv_len = 0;
|
||||
|
|
@ -55,6 +56,7 @@ slap_operational_entryDN( Entry *e )
|
|||
|
||||
a = attr_alloc( slap_schema.si_ad_entryDN );
|
||||
|
||||
a->a_numvals = 1;
|
||||
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( &a->a_vals[ 0 ], &e->e_name );
|
||||
BER_BVZERO( &a->a_vals[ 1 ] );
|
||||
|
|
@ -75,6 +77,7 @@ slap_operational_hasSubordinate( int hs )
|
|||
val = hs ? slap_true_bv : slap_false_bv;
|
||||
|
||||
a = attr_alloc( slap_schema.si_ad_hasSubordinates );
|
||||
a->a_numvals = 1;
|
||||
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
|
||||
|
||||
ber_dupbv( &a->a_vals[0], &val );
|
||||
|
|
|
|||
|
|
@ -1383,6 +1383,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
|
|||
vals[i].bv_val = NULL;
|
||||
vals[i].bv_len = 0;
|
||||
a = attr_alloc( logop == LOG_EN_ADD ? ad_reqMod : ad_reqOld );
|
||||
a->a_numvals = i;
|
||||
a->a_vals = vals;
|
||||
a->a_nvals = vals;
|
||||
last_attr->a_next = a;
|
||||
|
|
@ -1478,6 +1479,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
|
|||
if ( i > 0 ) {
|
||||
BER_BVZERO( &vals[i] );
|
||||
a = attr_alloc( ad_reqMod );
|
||||
a->a_numvals = i;
|
||||
a->a_vals = vals;
|
||||
a->a_nvals = vals;
|
||||
last_attr->a_next = a;
|
||||
|
|
@ -1509,6 +1511,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
|
|||
vals[i].bv_val = NULL;
|
||||
vals[i].bv_len = 0;
|
||||
a = attr_alloc( ad_reqOld );
|
||||
a->a_numvals = i;
|
||||
a->a_vals = vals;
|
||||
a->a_nvals = vals;
|
||||
last_attr->a_next = a;
|
||||
|
|
@ -1788,10 +1791,9 @@ accesslog_operational( Operation *op, SlapReply *rs )
|
|||
ad_inlist( ad_auditContext, rs->sr_attrs ) )
|
||||
{
|
||||
*ap = attr_alloc( ad_auditContext );
|
||||
value_add_one( &(*ap)->a_vals,
|
||||
&li->li_db->be_suffix[0] );
|
||||
value_add_one( &(*ap)->a_nvals,
|
||||
&li->li_db->be_nsuffix[0] );
|
||||
attr_valadd( *ap,
|
||||
&li->li_db->be_suffix[0],
|
||||
&li->li_db->be_nsuffix[0], 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -788,6 +788,7 @@ done:;
|
|||
tmpmod->sml_op = LDAP_MOD_REPLACE;
|
||||
value_add_one( &tmpmod->sml_values, &bv );
|
||||
value_add_one( &tmpmod->sml_nvalues, &bv );
|
||||
tmpmod->sml_numvals = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -921,6 +921,7 @@ ppolicy_bind_response( Operation *op, SlapReply *rs )
|
|||
m->sml_flags = 0;
|
||||
m->sml_type = ad_pwdFailureTime->ad_cname;
|
||||
m->sml_desc = ad_pwdFailureTime;
|
||||
m->sml_numvals = 1;
|
||||
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
|
||||
m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
|
||||
|
||||
|
|
@ -970,6 +971,7 @@ ppolicy_bind_response( Operation *op, SlapReply *rs )
|
|||
m->sml_flags = 0;
|
||||
m->sml_type = ad_pwdAccountLockedTime->ad_cname;
|
||||
m->sml_desc = ad_pwdAccountLockedTime;
|
||||
m->sml_numvals = 1;
|
||||
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
|
||||
m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
|
||||
ber_dupbv( &m->sml_values[0], ×tamp );
|
||||
|
|
@ -1062,6 +1064,7 @@ grace:
|
|||
m->sml_flags = 0;
|
||||
m->sml_type = ad_pwdGraceUseTime->ad_cname;
|
||||
m->sml_desc = ad_pwdGraceUseTime;
|
||||
m->sml_numvals = 1;
|
||||
m->sml_values = ch_calloc( sizeof(struct berval), 2 );
|
||||
m->sml_nvalues = ch_calloc( sizeof(struct berval), 2 );
|
||||
ber_dupbv( &m->sml_values[0], ×tamp );
|
||||
|
|
@ -1469,6 +1472,7 @@ ppolicy_modify( Operation *op, SlapReply *rs )
|
|||
ml->sml_flags = SLAP_MOD_INTERNAL;
|
||||
ml->sml_type.bv_val = NULL;
|
||||
ml->sml_desc = ad_pwdGraceUseTime;
|
||||
ml->sml_numvals = 0;
|
||||
ml->sml_values = NULL;
|
||||
ml->sml_nvalues = NULL;
|
||||
ml->sml_next = NULL;
|
||||
|
|
@ -1481,6 +1485,7 @@ ppolicy_modify( Operation *op, SlapReply *rs )
|
|||
ml->sml_flags = SLAP_MOD_INTERNAL;
|
||||
ml->sml_type.bv_val = NULL;
|
||||
ml->sml_desc = ad_pwdAccountLockedTime;
|
||||
ml->sml_numvals = 0;
|
||||
ml->sml_values = NULL;
|
||||
ml->sml_nvalues = NULL;
|
||||
ml->sml_next = NULL;
|
||||
|
|
@ -1492,6 +1497,7 @@ ppolicy_modify( Operation *op, SlapReply *rs )
|
|||
ml->sml_flags = SLAP_MOD_INTERNAL;
|
||||
ml->sml_type.bv_val = NULL;
|
||||
ml->sml_desc = ad_pwdFailureTime;
|
||||
ml->sml_numvals = 0;
|
||||
ml->sml_values = NULL;
|
||||
ml->sml_nvalues = NULL;
|
||||
ml->sml_next = NULL;
|
||||
|
|
@ -1671,6 +1677,7 @@ ppolicy_modify( Operation *op, SlapReply *rs )
|
|||
ml->sml_flags = SLAP_MOD_INTERNAL;
|
||||
ml->sml_desc = pp.ad;
|
||||
ml->sml_type = pp.ad->ad_cname;
|
||||
ml->sml_numvals = 1;
|
||||
ml->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( &ml->sml_values[0], &oldpw );
|
||||
BER_BVZERO( &ml->sml_values[1] );
|
||||
|
|
@ -1838,6 +1845,7 @@ do_modify:
|
|||
mods->sml_desc = ad_pwdChangedTime;
|
||||
if (pwmop != LDAP_MOD_DELETE) {
|
||||
mods->sml_op = LDAP_MOD_REPLACE;
|
||||
mods->sml_numvals = 1;
|
||||
mods->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
|
||||
ber_dupbv( &mods->sml_values[0], ×tamp );
|
||||
BER_BVZERO( &mods->sml_values[1] );
|
||||
|
|
@ -1914,6 +1922,7 @@ do_modify:
|
|||
mods->sml_op = LDAP_MOD_DELETE;
|
||||
mods->sml_flags = SLAP_MOD_INTERNAL;
|
||||
mods->sml_desc = ad_pwdHistory;
|
||||
mods->sml_numvals = hsize - pp.pwdInHistory + 1;
|
||||
mods->sml_values = ch_calloc( sizeof( struct berval ),
|
||||
hsize - pp.pwdInHistory + 2 );
|
||||
BER_BVZERO( &mods->sml_values[ hsize - pp.pwdInHistory + 1 ] );
|
||||
|
|
@ -1945,6 +1954,7 @@ do_modify:
|
|||
mods->sml_type.bv_val = NULL;
|
||||
mods->sml_desc = ad_pwdHistory;
|
||||
mods->sml_nvalues = NULL;
|
||||
mods->sml_numvals = 1;
|
||||
mods->sml_values = ch_calloc( sizeof( struct berval ), 2 );
|
||||
mods->sml_values[ 1 ].bv_val = NULL;
|
||||
mods->sml_values[ 1 ].bv_len = 0;
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ refint_search_cb(
|
|||
ber_bvarray_add_x( &na->new_nvals, &newdn, op->o_tmpmemctx );
|
||||
}
|
||||
|
||||
/* count deteles */
|
||||
/* count deletes */
|
||||
if ( BER_BVISEMPTY( &rq->newdn ) ) {
|
||||
deleted++;
|
||||
}
|
||||
|
|
@ -642,6 +642,7 @@ refint_qtask( void *ctx, void *arg )
|
|||
m->sml_flags = SLAP_MOD_INTERNAL;
|
||||
m->sml_desc = slap_schema.si_ad_modifiersName;
|
||||
m->sml_type = m->sml_desc->ad_cname;
|
||||
m->sml_numvals = 1;
|
||||
m->sml_values = (BerVarray)(m+1);
|
||||
m->sml_nvalues = m->sml_values+2;
|
||||
BER_BVZERO( &m->sml_values[1] );
|
||||
|
|
@ -672,6 +673,7 @@ refint_qtask( void *ctx, void *arg )
|
|||
m->sml_nvalues = m->sml_values+2;
|
||||
BER_BVZERO( &m->sml_values[1] );
|
||||
BER_BVZERO( &m->sml_nvalues[1] );
|
||||
m->sml_numvals = 1;
|
||||
if ( BER_BVISEMPTY( &rq->newdn )) {
|
||||
op->o_tmpfree( ra, op->o_tmpmemctx );
|
||||
ra = dp->attrs;
|
||||
|
|
|
|||
|
|
@ -1225,6 +1225,7 @@ cleanup_attr:;
|
|||
mod.sm_op = LDAP_MOD_ADD;
|
||||
mod.sm_desc = (*ap)->a_desc;
|
||||
mod.sm_type = mod.sm_desc->ad_cname;
|
||||
mod.sm_numvals = (*tap)->a_numvals;
|
||||
mod.sm_values = (*tap)->a_vals;
|
||||
mod.sm_nvalues = (*tap)->a_nvals;
|
||||
|
||||
|
|
|
|||
|
|
@ -2306,9 +2306,9 @@ syncprov_operational(
|
|||
a->a_nvals = NULL;
|
||||
ber_bvarray_free( a->a_vals );
|
||||
a->a_vals = NULL;
|
||||
a->a_numvals = 0;
|
||||
}
|
||||
ber_bvarray_dup_x( &a->a_vals, si->si_ctxcsn, NULL );
|
||||
ber_bvarray_dup_x( &a->a_nvals, si->si_ctxcsn, NULL );
|
||||
attr_valadd( a, si->si_ctxcsn, si->si_ctxcsn, si->si_numcsns );
|
||||
}
|
||||
ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ void glue_parent(Operation *op) {
|
|||
ber_dupbv(&e->e_nname, &ndn);
|
||||
|
||||
a = attr_alloc( slap_schema.si_ad_objectClass );
|
||||
a->a_numvals = 2;
|
||||
a->a_vals = ch_malloc(sizeof(struct berval) * 3);
|
||||
ber_dupbv(&a->a_vals[0], &glue[0]);
|
||||
ber_dupbv(&a->a_vals[1], &glue[1]);
|
||||
|
|
@ -156,6 +157,7 @@ void glue_parent(Operation *op) {
|
|||
e->e_attrs = a;
|
||||
|
||||
a = attr_alloc( slap_schema.si_ad_structuralObjectClass );
|
||||
a->a_numvals = 1;
|
||||
a->a_vals = ch_malloc(sizeof(struct berval) * 2);
|
||||
ber_dupbv(&a->a_vals[0], &glue[1]);
|
||||
ber_dupbv(&a->a_vals[1], &glue[2]);
|
||||
|
|
@ -428,6 +430,8 @@ release:
|
|||
atmp.a_desc = m->sml_desc;
|
||||
atmp.a_vals = m->sml_values;
|
||||
atmp.a_nvals = m->sml_nvalues ? m->sml_nvalues : atmp.a_vals;
|
||||
atmp.a_numvals = m->sml_numvals;
|
||||
atmp.a_flags = 0;
|
||||
a = attr_dup( &atmp );
|
||||
a->a_next = ax;
|
||||
ax = a;
|
||||
|
|
|
|||
|
|
@ -245,6 +245,7 @@ old_good:
|
|||
nhash = 1;
|
||||
hashes = (char **)defhash;
|
||||
}
|
||||
ml->sml_numvals = nhash;
|
||||
ml->sml_values = ch_malloc( (nhash+1)*sizeof(struct berval) );
|
||||
for ( i=0; hashes[i]; i++ ) {
|
||||
slap_passwd_hash_type( &qpw->rs_new, &hash, hashes[i], &rs->sr_text );
|
||||
|
|
|
|||
|
|
@ -268,6 +268,10 @@ LDAP_SLAPD_F (void) comp_tree_free LDAP_P(( Attribute *a ));
|
|||
LDAP_SLAPD_F (Attribute *) attr_alloc LDAP_P(( AttributeDescription *ad ));
|
||||
LDAP_SLAPD_F (Attribute *) attrs_alloc LDAP_P(( int num ));
|
||||
LDAP_SLAPD_F (int) attr_prealloc LDAP_P(( int num ));
|
||||
LDAP_SLAPD_F (int) attr_valadd LDAP_P(( Attribute *a,
|
||||
BerVarray vals,
|
||||
BerVarray nvals,
|
||||
int num ));
|
||||
LDAP_SLAPD_F (int) attr_merge LDAP_P(( Entry *e,
|
||||
AttributeDescription *desc,
|
||||
BerVarray vals,
|
||||
|
|
@ -1803,8 +1807,7 @@ LDAP_SLAPD_F (int) ordered_value_match LDAP_P((
|
|||
const char ** text ));
|
||||
|
||||
LDAP_SLAPD_F (void) ordered_value_renumber LDAP_P((
|
||||
Attribute *a,
|
||||
int vals ));
|
||||
Attribute *a ));
|
||||
|
||||
LDAP_SLAPD_F (int) ordered_value_sort LDAP_P((
|
||||
Attribute *a,
|
||||
|
|
|
|||
|
|
@ -455,6 +455,7 @@ slap_auxprop_store(
|
|||
mod->sml_op = LDAP_MOD_REPLACE;
|
||||
mod->sml_flags = 0;
|
||||
ber_str2bv( pr[i].name, 0, 0, &mod->sml_type );
|
||||
mod->sml_numvals = pr[i].nvalues;
|
||||
mod->sml_values = (struct berval *)ch_malloc( (pr[i].nvalues + 1) *
|
||||
sizeof(struct berval));
|
||||
for (j=0; j<pr[i].nvalues; j++) {
|
||||
|
|
|
|||
|
|
@ -1118,11 +1118,13 @@ struct Attribute {
|
|||
ComponentData *a_comp_data; /* component values */
|
||||
#endif
|
||||
Attribute *a_next;
|
||||
unsigned a_numvals; /* number of vals */
|
||||
unsigned a_flags;
|
||||
#define SLAP_ATTR_IXADD 0x1U
|
||||
#define SLAP_ATTR_IXDEL 0x2U
|
||||
#define SLAP_ATTR_DONT_FREE_DATA 0x4U
|
||||
#define SLAP_ATTR_DONT_FREE_VALS 0x8U
|
||||
#define SLAP_ATTR_SORTED_VALS 0x10U
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1183,6 +1185,7 @@ struct Modification {
|
|||
struct berval sm_type;
|
||||
BerVarray sm_values;
|
||||
BerVarray sm_nvalues;
|
||||
unsigned sm_numvals;
|
||||
};
|
||||
|
||||
struct Modifications {
|
||||
|
|
@ -1193,17 +1196,10 @@ struct Modifications {
|
|||
#define sml_type sml_mod.sm_type
|
||||
#define sml_values sml_mod.sm_values
|
||||
#define sml_nvalues sml_mod.sm_nvalues
|
||||
#define sml_numvals sml_mod.sm_numvals
|
||||
Modifications *sml_next;
|
||||
};
|
||||
|
||||
struct LDAPModList {
|
||||
LDAPMod ml_mod;
|
||||
LDAPModList *ml_next;
|
||||
#define ml_op ml_mod.mod_op
|
||||
#define ml_type ml_mod.mod_type
|
||||
#define ml_values ml_mod.mod_values
|
||||
};
|
||||
|
||||
/*
|
||||
* represents an access control list
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2720,6 +2720,7 @@ Modifications *slapi_int_ldapmods2modifications ( Operation *op, LDAPMod **mods
|
|||
i++;
|
||||
}
|
||||
}
|
||||
mod->sml_numvals = i;
|
||||
|
||||
if ( i == 0 ) {
|
||||
mod->sml_values = NULL;
|
||||
|
|
|
|||
|
|
@ -1383,6 +1383,7 @@ syncrepl_accesslog_mods(
|
|||
mod->sml_type = ad->ad_cname;
|
||||
mod->sml_values = NULL;
|
||||
mod->sml_nvalues = NULL;
|
||||
mod->sml_numvals = 0;
|
||||
|
||||
*modtail = mod;
|
||||
modtail = &mod->sml_next;
|
||||
|
|
@ -1392,6 +1393,7 @@ syncrepl_accesslog_mods(
|
|||
bv.bv_len = vals[i].bv_len - ( bv.bv_val - vals[i].bv_val );
|
||||
ber_dupbv( &bv2, &bv );
|
||||
ber_bvarray_add( &mod->sml_values, &bv2 );
|
||||
mod->sml_numvals++;
|
||||
}
|
||||
}
|
||||
return modlist;
|
||||
|
|
@ -1724,6 +1726,7 @@ syncrepl_message_to_entry(
|
|||
mod->sml_type = tmp.sml_type;
|
||||
mod->sml_values = tmp.sml_values;
|
||||
mod->sml_nvalues = NULL;
|
||||
mod->sml_numvals = 0; /* slap_mods_check will set this */
|
||||
|
||||
*modtail = mod;
|
||||
modtail = &mod->sml_next;
|
||||
|
|
@ -2337,6 +2340,7 @@ syncrepl_del_nonpresent(
|
|||
mod1.sml_flags = 0;
|
||||
mod1.sml_desc = slap_schema.si_ad_objectClass;
|
||||
mod1.sml_type = mod1.sml_desc->ad_cname;
|
||||
mod1.sml_numvals = 2;
|
||||
mod1.sml_values = &gcbva[0];
|
||||
mod1.sml_nvalues = NULL;
|
||||
mod1.sml_next = &mod2;
|
||||
|
|
@ -2345,6 +2349,7 @@ syncrepl_del_nonpresent(
|
|||
mod2.sml_flags = 0;
|
||||
mod2.sml_desc = slap_schema.si_ad_structuralObjectClass;
|
||||
mod2.sml_type = mod2.sml_desc->ad_cname;
|
||||
mod1.sml_numvals = 1;
|
||||
mod2.sml_values = &gcbva[1];
|
||||
mod2.sml_nvalues = NULL;
|
||||
mod2.sml_next = NULL;
|
||||
|
|
@ -2472,6 +2477,7 @@ syncrepl_add_glue(
|
|||
|
||||
a = attr_alloc( slap_schema.si_ad_objectClass );
|
||||
|
||||
a->a_numvals = 2;
|
||||
a->a_vals = ch_calloc( 3, sizeof( struct berval ) );
|
||||
ber_dupbv( &a->a_vals[0], &gcbva[0] );
|
||||
ber_dupbv( &a->a_vals[1], &gcbva[1] );
|
||||
|
|
@ -2484,6 +2490,7 @@ syncrepl_add_glue(
|
|||
|
||||
a = attr_alloc( slap_schema.si_ad_structuralObjectClass );
|
||||
|
||||
a->a_numvals = 1;
|
||||
a->a_vals = ch_calloc( 2, sizeof( struct berval ) );
|
||||
ber_dupbv( &a->a_vals[0], &gcbva[1] );
|
||||
ber_dupbv( &a->a_vals[1], &gcbva[2] );
|
||||
|
|
@ -2727,6 +2734,7 @@ attr_cmp( Operation *op, Attribute *old, Attribute *new,
|
|||
mod->sml_flags = 0;
|
||||
mod->sml_desc = old->a_desc;
|
||||
mod->sml_type = mod->sml_desc->ad_cname;
|
||||
mod->sml_numvals = no;
|
||||
mod->sml_values = ch_malloc( ( no + 1 ) * sizeof(struct berval) );
|
||||
if ( old->a_vals != old->a_nvals ) {
|
||||
mod->sml_nvalues = ch_malloc( ( no + 1 ) * sizeof(struct berval) );
|
||||
|
|
@ -2758,6 +2766,7 @@ attr_cmp( Operation *op, Attribute *old, Attribute *new,
|
|||
mod->sml_flags = 0;
|
||||
mod->sml_desc = old->a_desc;
|
||||
mod->sml_type = mod->sml_desc->ad_cname;
|
||||
mod->sml_numvals = nn;
|
||||
mod->sml_values = ch_malloc( ( nn + 1 ) * sizeof(struct berval) );
|
||||
if ( old->a_vals != old->a_nvals ) {
|
||||
mod->sml_nvalues = ch_malloc( ( nn + 1 ) * sizeof(struct berval) );
|
||||
|
|
@ -2937,6 +2946,7 @@ dn_callback(
|
|||
mod->sml_flags = 0;
|
||||
mod->sml_desc = old->a_desc;
|
||||
mod->sml_type = mod->sml_desc->ad_cname;
|
||||
mod->sml_numvals = 0;
|
||||
mod->sml_values = NULL;
|
||||
mod->sml_nvalues = NULL;
|
||||
*modtail = mod;
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ int value_find_ex(
|
|||
|
||||
/* assign new indexes to an attribute's ordered values */
|
||||
void
|
||||
ordered_value_renumber( Attribute *a, int vals )
|
||||
ordered_value_renumber( Attribute *a )
|
||||
{
|
||||
char *ptr, ibuf[64]; /* many digits */
|
||||
struct berval ibv, tmp, vtmp;
|
||||
|
|
@ -271,7 +271,7 @@ ordered_value_renumber( Attribute *a, int vals )
|
|||
|
||||
ibv.bv_val = ibuf;
|
||||
|
||||
for (i=0; i<vals; i++) {
|
||||
for (i=0; i<a->a_numvals; i++) {
|
||||
ibv.bv_len = sprintf(ibv.bv_val, "{%d}", i);
|
||||
vtmp = a->a_vals[i];
|
||||
if ( vtmp.bv_val[0] == '{' ) {
|
||||
|
|
@ -405,7 +405,7 @@ ordered_value_sort( Attribute *a, int do_renumber )
|
|||
}
|
||||
|
||||
if ( do_renumber && renumber )
|
||||
ordered_value_renumber( a, vals );
|
||||
ordered_value_renumber( a );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -706,16 +706,14 @@ ordered_value_add(
|
|||
vnum = i;
|
||||
|
||||
if ( a ) {
|
||||
for (i=0; !BER_BVISNULL( a->a_vals+i ); i++) ;
|
||||
anum = i;
|
||||
ordered_value_sort( a, 0 );
|
||||
} else {
|
||||
Attribute **ap;
|
||||
anum = 0;
|
||||
for ( ap=&e->e_attrs; *ap; ap = &(*ap)->a_next ) ;
|
||||
a = attr_alloc( ad );
|
||||
*ap = a;
|
||||
}
|
||||
anum = a->a_numvals;
|
||||
|
||||
new = ch_malloc( (anum+vnum+1) * sizeof(struct berval));
|
||||
|
||||
|
|
@ -789,7 +787,8 @@ ordered_value_add(
|
|||
a->a_nvals = a->a_vals;
|
||||
}
|
||||
|
||||
ordered_value_renumber( a, anum );
|
||||
a->a_numvals = anum;
|
||||
ordered_value_renumber( a );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue