From c7f043804404c80e36cac767b97f6f6ad8637526 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 8 Apr 2004 06:49:17 +0000 Subject: [PATCH] bvalue cleanup --- servers/slapd/acl.c | 6 +-- servers/slapd/add.c | 45 +++++++++++--------- servers/slapd/ava.c | 3 +- servers/slapd/back-bdb/ctxcsn.c | 2 +- servers/slapd/back-ldap/modify.c | 32 +++++++-------- servers/slapd/back-ldbm/modify.c | 55 +++++++++++++++---------- servers/slapd/back-meta/modify.c | 18 ++++---- servers/slapd/back-monitor/log.c | 31 +++++++------- servers/slapd/back-perl/modify.c | 4 +- servers/slapd/back-shell/modify.c | 6 +-- servers/slapd/back-sql/add.c | 8 ++-- servers/slapd/overlays/slapover.txt | 4 +- servers/slapd/repl.c | 13 +++--- servers/slapd/schema_check.c | 4 +- servers/slapd/slap.h | 3 -- servers/slapd/slapi/slapi_ops.c | 22 +++++----- servers/slapd/slapi/slapi_utils.c | 64 ++++++++++++++--------------- servers/slapd/syncrepl.c | 16 ++++---- 18 files changed, 175 insertions(+), 161 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 754e9539bf..c337b8fe78 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -1632,12 +1632,12 @@ acl_check_modlist( goto done; } - if ( mlist->sml_bvalues == NULL ) break; + if ( mlist->sml_values == NULL ) break; /* fall thru to check value to add */ case LDAP_MOD_ADD: - assert( mlist->sml_bvalues != NULL ); + assert( mlist->sml_values != NULL ); for ( bv = mlist->sml_nvalues ? mlist->sml_nvalues : mlist->sml_values; @@ -1653,7 +1653,7 @@ acl_check_modlist( break; case LDAP_MOD_DELETE: - if ( mlist->sml_bvalues == NULL ) { + if ( mlist->sml_values == NULL ) { if ( ! access_allowed( op, e, mlist->sml_desc, NULL, ACL_WRITE, NULL ) ) { diff --git a/servers/slapd/add.c b/servers/slapd/add.c index fb6f6e6a51..f7bcc117fd 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -36,7 +36,8 @@ #ifdef LDAP_SLAPI #include "slapi/slapi.h" -static void init_add_pblock( Operation *op, struct berval *dn, Entry *e, int manageDSAit ); +static void init_add_pblock( Operation *op, struct berval *dn, Entry *e, + int manageDSAit ); static int call_add_preop_plugins( Operation *op ); static void call_add_postop_plugins( Operation *op ); #endif /* LDAP_SLAPI */ @@ -86,7 +87,8 @@ do_add( Operation *op, SlapReply *rs ) e = (Entry *) ch_calloc( 1, sizeof(Entry) ); - rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); + rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, + op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -483,11 +485,12 @@ slap_mods2entry( /* check if the values we're adding already exist */ if( mr == NULL || !mr->smr_match ) { - for ( i = 0; mods->sml_bvalues[i].bv_val != NULL; i++ ) { + for ( i = 1; mods->sml_values[i].bv_val != NULL; i++ ) { /* test asserted values against themselves */ for( j = 0; j < i; j++ ) { - if ( bvmatch( &mods->sml_bvalues[i], - &mods->sml_bvalues[j] ) ) { + if ( bvmatch( &mods->sml_values[i], + &mods->sml_values[j] ) ) + { /* value exists already */ snprintf( textbuf, textlen, "%s: value #%d provided more than once", @@ -501,11 +504,12 @@ slap_mods2entry( int rc = LDAP_SUCCESS; int match; - for ( i = 0; mods->sml_values[i].bv_val != NULL; i++ ) { + for ( i = 1; mods->sml_values[i].bv_val != NULL; i++ ) { /* test asserted values against themselves */ for( j = 0; j < i; j++ ) { rc = value_match( &match, mods->sml_desc, mr, - SLAP_MR_EQUALITY | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX + SLAP_MR_EQUALITY + | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, mods->sml_nvalues @@ -534,17 +538,17 @@ slap_mods2entry( /* move ad to attr structure */ attr->a_desc = mods->sml_desc; - if ( !dup ) - mods->sml_desc = NULL; + if ( !dup ) mods->sml_desc = NULL; /* move values to attr structure */ /* should check for duplicates */ if ( dup ) { int i; - for ( i = 0; mods->sml_values[i].bv_val; 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++ ) + for ( i = 0; mods->sml_values[i].bv_val; i++ ) { ber_dupbv( &attr->a_vals[i], &mods->sml_values[i] ); + } attr->a_vals[i].bv_len = 0; attr->a_vals[i].bv_val = NULL; } else { @@ -555,10 +559,11 @@ slap_mods2entry( if ( mods->sml_nvalues ) { if ( dup ) { int i; - for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) ; + for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) /* EMPTY */; attr->a_nvals = (BerVarray) ch_calloc( i+1, sizeof( BerValue )); - for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) + for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) { ber_dupbv( &attr->a_nvals[i], &mods->sml_nvalues[i] ); + } attr->a_nvals[i].bv_len = 0; attr->a_nvals[i].bv_val = NULL; } else { @@ -600,10 +605,10 @@ slap_entry2mods( mod->sml_type = a_new_desc->ad_cname; - for ( count = 0; a_new->a_vals[count].bv_val; count++ ); + for ( count = 0; a_new->a_vals[count].bv_val; count++ ) /* EMPTY */; - mod->sml_bvalues = (struct berval*) malloc( - (count+1) * sizeof( struct berval) ); + mod->sml_values = (struct berval*) malloc( + (count+1) * sizeof( struct berval) ); /* see slap_mods_check() comments... * if a_vals == a_nvals, there is no normalizer. @@ -617,17 +622,17 @@ slap_entry2mods( } for ( i = 0; i < count; i++ ) { - ber_dupbv(mod->sml_bvalues+i, a_new->a_vals+i); + ber_dupbv(mod->sml_values+i, a_new->a_vals+i); if ( mod->sml_nvalues ) { ber_dupbv( mod->sml_nvalues+i, a_new->a_vals+i ); } } - mod->sml_bvalues[count].bv_val = 0; - mod->sml_bvalues[count].bv_len = 0; + mod->sml_values[count].bv_val = NULL; + mod->sml_values[count].bv_len = 0; if ( mod->sml_nvalues ) { - mod->sml_nvalues[count].bv_val = 0; + mod->sml_nvalues[count].bv_val = NULL; mod->sml_nvalues[count].bv_len = 0; } diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index 754f7ec53f..57c79e7941 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -53,8 +53,7 @@ get_ava( BerElement *ber, AttributeAssertion **ava, unsigned usage, - const char **text -) + const char **text ) { int rc; ber_tag_t rtag; diff --git a/servers/slapd/back-bdb/ctxcsn.c b/servers/slapd/back-bdb/ctxcsn.c index d95989caf0..1b4706b0bd 100644 --- a/servers/slapd/back-bdb/ctxcsn.c +++ b/servers/slapd/back-bdb/ctxcsn.c @@ -90,7 +90,7 @@ bdb_csn_commit( modvals[1].bv_len = 0; mod.sml_op = LDAP_MOD_REPLACE; - mod.sml_bvalues = modvals; + mod.sml_values = modvals; mod.sml_nvalues = NULL; mod.sml_desc = slap_schema.si_ad_contextCSN; mod.sml_type = mod.sml_desc->ad_cname; diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index 517a202e5c..c0670caf6a 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -117,42 +117,42 @@ ldap_back_modify( mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES; mods[i].mod_type = mapped.bv_val; - if ( ml->sml_bvalues != NULL ) { + if ( ml->sml_values != NULL ) { if ( is_oc ) { - for (j = 0; ml->sml_bvalues[j].bv_val; j++); - mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) * + for (j = 0; ml->sml_values[j].bv_val; j++); + mods[i].mod_values = (struct berval **)ch_malloc((j+1) * sizeof(struct berval *)); - for (j = 0; ml->sml_bvalues[j].bv_val; j++) { + for (j = 0; ml->sml_values[j].bv_val; j++) { ldap_back_map(&li->rwmap.rwm_oc, - &ml->sml_bvalues[j], + &ml->sml_values[j], &mapped, BACKLDAP_MAP); if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') { continue; } - mods[i].mod_bvalues[j] = &mapped; + mods[i].mod_values[j] = &mapped; } - mods[i].mod_bvalues[j] = NULL; + mods[i].mod_values[j] = NULL; } else { if ( ml->sml_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) { - ldap_dnattr_rewrite( &dc, ml->sml_bvalues ); + ldap_dnattr_rewrite( &dc, ml->sml_values ); } - if ( ml->sml_bvalues == NULL ) { + if ( ml->sml_values == NULL ) { continue; } - for (j = 0; ml->sml_bvalues[j].bv_val; j++); - mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) * + for (j = 0; ml->sml_values[j].bv_val; j++); + mods[i].mod_values = (struct berval **)ch_malloc((j+1) * sizeof(struct berval *)); - for (j = 0; ml->sml_bvalues[j].bv_val; j++) - mods[i].mod_bvalues[j] = &ml->sml_bvalues[j]; - mods[i].mod_bvalues[j] = NULL; + for (j = 0; ml->sml_values[j].bv_val; j++) + mods[i].mod_values[j] = &ml->sml_values[j]; + mods[i].mod_values[j] = NULL; } } else { - mods[i].mod_bvalues = NULL; + mods[i].mod_values = NULL; } i++; @@ -186,7 +186,7 @@ cleanup:; free( mdn.bv_val ); } for (i=0; modv[i]; i++) { - ch_free(modv[i]->mod_bvalues); + ch_free(modv[i]->mod_values); } ch_free( mods ); ch_free( modv ); diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 4a574fceee..3382356e5a 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -37,8 +37,7 @@ int ldbm_modify_internal( Entry *e, const char **text, char *textbuf, - size_t textlen -) + size_t textlen ) { int rc = LDAP_SUCCESS; Modification *mod; @@ -47,12 +46,19 @@ int ldbm_modify_internal( Attribute *ap; #ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_modify_internal: %s\n", e->e_name.bv_val, 0, 0 ); + LDAP_LOG( BACK_LDBM, ENTRY, + "ldbm_modify_internal: %s\n", + e->e_name.bv_val, + get_permissiveModify(op) ? " (permissive)" : "", + 0 ); #else - Debug(LDAP_DEBUG_TRACE, "ldbm_modify_internal: %s\n", e->e_name.bv_val, 0, 0); + Debug(LDAP_DEBUG_TRACE, + "ldbm_modify_internal: %s\n", + e->e_name.bv_val, + get_permissiveModify(op) ? " (permissive)" : "", + 0 ); #endif - if ( !acl_check_modlist( op, e, modlist )) { return LDAP_INSUFFICIENT_ACCESS; } @@ -66,13 +72,15 @@ int ldbm_modify_internal( switch ( mod->sm_op ) { case LDAP_MOD_ADD: #ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: add\n", 0, 0, 0); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_modify_internal: add\n", 0, 0, 0); #else - Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: add\n", 0, 0, 0); + Debug(LDAP_DEBUG_ARGS, + "ldbm_modify_internal: add\n", 0, 0, 0); #endif rc = modify_add_values( e, mod, get_permissiveModify( op ), - text, textbuf, textlen ); + text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( BACK_LDBM, INFO, @@ -86,13 +94,15 @@ int ldbm_modify_internal( case LDAP_MOD_DELETE: #ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: delete\n", 0,0,0); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_modify_internal: delete\n", 0,0,0); #else - Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: delete\n", 0, 0, 0); + Debug(LDAP_DEBUG_ARGS, + "ldbm_modify_internal: delete\n", 0, 0, 0); #endif rc = modify_delete_values( e, mod, get_permissiveModify( op ), - text, textbuf, textlen ); + text, textbuf, textlen ); assert( rc != LDAP_TYPE_OR_VALUE_EXISTS ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -107,13 +117,15 @@ int ldbm_modify_internal( case LDAP_MOD_REPLACE: #ifdef NEW_LOGGING - LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: replace\n",0,0,0); + LDAP_LOG( BACK_LDBM, DETAIL1, + "ldbm_modify_internal: replace\n",0,0,0); #else - Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: replace\n", 0, 0, 0); + Debug(LDAP_DEBUG_ARGS, + "ldbm_modify_internal: replace\n", 0, 0, 0); #endif rc = modify_replace_values( e, mod, get_permissiveModify( op ), - text, textbuf, textlen ); + text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( BACK_LDBM, INFO, @@ -152,7 +164,8 @@ int ldbm_modify_internal( LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_modify_internal: softadd\n", 0, 0, 0 ); #else - Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: softadd\n", 0, 0, 0); + Debug(LDAP_DEBUG_ARGS, + "ldbm_modify_internal: softadd\n", 0, 0, 0); #endif /* Avoid problems in index_add_mods() @@ -161,7 +174,7 @@ int ldbm_modify_internal( mod->sm_op = LDAP_MOD_ADD; rc = modify_add_values( e, mod, get_permissiveModify( op ), - text, textbuf, textlen ); + text, textbuf, textlen ); mod->sm_op = SLAP_MOD_SOFTADD; if ( rc == LDAP_TYPE_OR_VALUE_EXISTS ) { rc = LDAP_SUCCESS; @@ -170,7 +183,7 @@ int ldbm_modify_internal( if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( BACK_LDBM, INFO, - "ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 ); + "ldbm_modify_internal: failed %d (%s)\n", rc, *text, 0 ); #else Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n", rc, *text, 0); @@ -255,8 +268,8 @@ int ldbm_modify_internal( 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, - "Attribute index delete failure", - 0, 0, 0 ); + "ldbm_modify_internal: Attribute index delete failure\n", + 0, 0, 0 ); #endif goto exit; } @@ -277,8 +290,8 @@ int ldbm_modify_internal( 0, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, - "Attribute index add failure", - 0, 0, 0 ); + "ldbm_modify_internal: Attribute index add failure\n", + 0, 0, 0 ); #endif goto exit; } diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index 62ae54b1e5..8fbee1407e 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -114,19 +114,19 @@ meta_back_modify( Operation *op, SlapReply *rs ) */ if ( strcmp( ml->sml_desc->ad_type->sat_syntax->ssyn_oid, SLAPD_DN_SYNTAX ) == 0 ) { - ( void )ldap_dnattr_rewrite( &dc, ml->sml_bvalues ); + ( void )ldap_dnattr_rewrite( &dc, ml->sml_values ); } - if ( ml->sml_bvalues != NULL ){ - for (j = 0; ml->sml_bvalues[ j ].bv_val; j++); - mods[ i ].mod_bvalues = (struct berval **)ch_malloc((j+1) * + if ( ml->sml_values != NULL ){ + for (j = 0; ml->sml_values[ j ].bv_val; j++); + mods[ i ].mod_values = (struct berval **)ch_malloc((j+1) * sizeof(struct berval *)); - for (j = 0; ml->sml_bvalues[ j ].bv_val; j++) - mods[ i ].mod_bvalues[ j ] = &ml->sml_bvalues[j]; - mods[ i ].mod_bvalues[ j ] = NULL; + for (j = 0; ml->sml_values[ j ].bv_val; j++) + mods[ i ].mod_values[ j ] = &ml->sml_values[j]; + mods[ i ].mod_values[ j ] = NULL; } else { - mods[ i ].mod_bvalues = NULL; + mods[ i ].mod_values = NULL; } i++; @@ -141,7 +141,7 @@ cleanup:; } if ( modv != NULL ) { for ( i = 0; modv[ i ]; i++) { - free( modv[ i ]->mod_bvalues ); + free( modv[ i ]->mod_values ); } } free( mods ); diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 1510cbfc72..9e99fb1eed 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -160,8 +160,7 @@ monitor_subsys_log_modify( */ if ( is_at_operational( mod->sm_desc->ad_type ) ) { ( void ) attr_delete( &e->e_attrs, mod->sm_desc ); - rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, - mod->sm_nvalues ); + rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues ); if ( rc != 0 ) { rc = LDAP_OTHER; break; @@ -283,10 +282,10 @@ check_constraints( Modification *mod, int *newlevel ) { int i; - for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) { + for ( i = 0; mod->sm_values && mod->sm_values[i].bv_val != NULL; i++ ) { int l; - l = loglevel2int( &mod->sm_bvalues[i] ); + l = loglevel2int( &mod->sm_values[i] ); if ( !l ) { return LDAP_CONSTRAINT_VIOLATION; } @@ -296,9 +295,9 @@ check_constraints( Modification *mod, int *newlevel ) } assert( int_2_level[ l ].s.bv_len - == mod->sm_bvalues[i].bv_len ); + == mod->sm_values[i].bv_len ); - AC_MEMCPY( mod->sm_bvalues[i].bv_val, + AC_MEMCPY( mod->sm_values[i].bv_val, int_2_level[ l ].s.bv_val, int_2_level[ l ].s.bv_len ); @@ -332,7 +331,7 @@ add_values( Entry *e, Modification *mod, int *newlevel ) return LDAP_INAPPROPRIATE_MATCHING; } - for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) { + for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) { int rc; int j; const char *text = NULL; @@ -340,7 +339,7 @@ add_values( Entry *e, Modification *mod, int *newlevel ) rc = asserted_value_validate_normalize( mod->sm_desc, mr, SLAP_MR_EQUALITY, - &mod->sm_bvalues[i], &asserted, &text, NULL ); + &mod->sm_values[i], &asserted, &text, NULL ); if ( rc != LDAP_SUCCESS ) { return rc; @@ -349,8 +348,7 @@ add_values( Entry *e, Modification *mod, int *newlevel ) for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) { int match; int rc = value_match( &match, mod->sm_desc, mr, - 0, - &a->a_vals[j], &asserted, &text ); + 0, &a->a_vals[j], &asserted, &text ); if ( rc == LDAP_SUCCESS && match == 0 ) { free( asserted.bv_val ); @@ -363,7 +361,7 @@ add_values( Entry *e, Modification *mod, int *newlevel ) } /* no - add them */ - rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, mod->sm_nvalues ); + rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues ); if ( rc != LDAP_SUCCESS ) { /* this should return result of attr_mergeit */ return rc; @@ -387,7 +385,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) *newlevel &= ~nl; /* delete the entire attribute */ - if ( mod->sm_bvalues == NULL ) { + if ( mod->sm_values == NULL ) { int rc = attr_delete( &e->e_attrs, mod->sm_desc ); if ( rc ) { @@ -411,7 +409,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) } /* find each value to delete */ - for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) { + for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) { int rc; const char *text = NULL; @@ -419,7 +417,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) rc = asserted_value_validate_normalize( mod->sm_desc, mr, SLAP_MR_EQUALITY, - &mod->sm_bvalues[i], &asserted, &text, NULL ); + &mod->sm_values[i], &asserted, &text, NULL ); if( rc != LDAP_SUCCESS ) return rc; @@ -485,9 +483,8 @@ replace_values( Entry *e, Modification *mod, int *newlevel ) return rc; } - if ( mod->sm_bvalues != NULL ) { - rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, - mod->sm_nvalues ); + if ( mod->sm_values != NULL ) { + rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues ); if ( rc != LDAP_SUCCESS ) { return rc; } diff --git a/servers/slapd/back-perl/modify.c b/servers/slapd/back-perl/modify.c index 0841ddb6e0..56d69eb209 100644 --- a/servers/slapd/back-perl/modify.c +++ b/servers/slapd/back-perl/modify.c @@ -72,10 +72,10 @@ perl_back_modify( XPUSHs(sv_2mortal(newSVpv( mods->sm_desc->ad_cname.bv_val, 0 ))); for ( i = 0; - mods->sm_bvalues != NULL && mods->sm_bvalues[i].bv_val != NULL; + mods->sm_values != NULL && mods->sm_values[i].bv_val != NULL; i++ ) { - XPUSHs(sv_2mortal(newSVpv( mods->sm_bvalues[i].bv_val, 0 ))); + XPUSHs(sv_2mortal(newSVpv( mods->sm_values[i].bv_val, 0 ))); } } diff --git a/servers/slapd/back-shell/modify.c b/servers/slapd/back-shell/modify.c index 2115217a4d..6dbd811e91 100644 --- a/servers/slapd/back-shell/modify.c +++ b/servers/slapd/back-shell/modify.c @@ -103,10 +103,10 @@ shell_back_modify( break; } - if( mod->sm_bvalues != NULL ) { - for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) { + if( mod->sm_values != NULL ) { + for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) { fprintf( wfp, "%s: %s\n", mod->sm_desc->ad_cname.bv_val, - mod->sm_bvalues[i].bv_val /* binary! */ ); + mod->sm_values[i].bv_val /* binary! */ ); } } diff --git a/servers/slapd/back-sql/add.c b/servers/slapd/back-sql/add.c index 1ce39b93b3..36370b8259 100644 --- a/servers/slapd/back-sql/add.c +++ b/servers/slapd/back-sql/add.c @@ -89,7 +89,7 @@ backsql_modify_internal( "mappings for objectClass \"%s\"\n", ad->ad_cname.bv_val, BACKSQL_OC_NAME( oc ), 0 ); - if ( backsql_attr_skip( ad, c_mod->sm_bvalues ) ) { + if ( backsql_attr_skip( ad, c_mod->sm_values ) ) { continue; } @@ -304,7 +304,7 @@ add_only:; Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): " "adding new values for attribute \"%s\"\n", at->bam_ad->ad_cname.bv_val, 0, 0 ); - for ( i = 0, at_val = c_mod->sm_bvalues; + for ( i = 0, at_val = c_mod->sm_values; at_val->bv_val != NULL; i++, at_val++ ) { if ( BACKSQL_IS_ADD( at->bam_expect_return ) ) { @@ -377,7 +377,7 @@ add_only:; break; } - if ( c_mod->sm_bvalues == NULL ) { + if ( c_mod->sm_values == NULL ) { Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): " "no values given to delete " @@ -391,7 +391,7 @@ add_only:; "deleting values for attribute \"%s\"\n", at->bam_ad->ad_cname.bv_val, 0, 0 ); - for ( i = 0, at_val = c_mod->sm_bvalues; + for ( i = 0, at_val = c_mod->sm_values; at_val->bv_val != NULL; i++, at_val++ ) { if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) { diff --git a/servers/slapd/overlays/slapover.txt b/servers/slapd/overlays/slapover.txt index b5281e80f6..856016226a 100644 --- a/servers/slapd/overlays/slapover.txt +++ b/servers/slapd/overlays/slapover.txt @@ -147,4 +147,6 @@ being returned to the client. The proxycache overlay attaches a local database to a back-ldap (or back-meta) backend and allows search results from remote servers to be cached locally. In both cases the overlays must provide a bit of glue to swap in the appropriate be_private and bd_info pointers before invoking -the attached backend, which can then be invoked as usual. \ No newline at end of file +the attached backend, which can then be invoked as usual. + +--- diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index 5d60fc51cb..f8ac323a84 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -300,19 +300,20 @@ replog1( * in any subset, otherwise drop it. */ if ( ocs && ml->sml_desc == slap_schema.si_ad_objectClass - && ml->sml_bvalues ) { + && ml->sml_values ) + { int i, first = 1; if ( ocs == -1 ) ocs = 0; - for ( i=0; ml->sml_bvalues[i].bv_val; i++ ) { + for ( i=0; ml->sml_values[i].bv_val; i++ ) { int match = 0; for ( an = ri->ri_attrs; an->an_name.bv_val; an++ ) { if ( an->an_oc ) { ocs = 1; match |= an->an_oc_exclude; - if ( ml->sml_bvalues[i].bv_len == an->an_name.bv_len - && !strcasecmp(ml->sml_bvalues[i].bv_val, + if ( ml->sml_values[i].bv_len == an->an_name.bv_len + && !strcasecmp(ml->sml_values[i].bv_val, an->an_name.bv_val ) ) { match = !an->an_oc_exclude; break; @@ -357,8 +358,8 @@ replog1( dohdr = 0; } fprintf( fp, "%s: %s\n", did, type ); - if ( ml->sml_bvalues ) { - print_vals( fp, &ml->sml_desc->ad_cname, ml->sml_bvalues ); + if ( ml->sml_values ) { + print_vals( fp, &ml->sml_desc->ad_cname, ml->sml_values ); } fprintf( fp, "-\n" ); } diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index ccabe6dc17..2ec71868dd 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -810,12 +810,12 @@ int mods_structural_class( return LDAP_OBJECT_CLASS_VIOLATION; } - if( ocmod->sml_bvalues == NULL || ocmod->sml_bvalues[0].bv_val == NULL ) { + if( ocmod->sml_values == NULL || ocmod->sml_values[0].bv_val == NULL ) { *text = "objectClass attribute has no values"; return LDAP_OBJECT_CLASS_VIOLATION; } - return structural_class( ocmod->sml_bvalues, sc, NULL, + return structural_class( ocmod->sml_values, sc, NULL, text, textbuf, textlen ); } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index d7832fcd53..b38a2884d5 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1034,7 +1034,6 @@ typedef struct slap_mod { AttributeDescription *sm_desc; struct berval sm_type; BerVarray sm_values; -#define sm_bvalues sm_values BerVarray sm_nvalues; } Modification; @@ -1043,7 +1042,6 @@ typedef struct slap_mod_list { #define sml_op sml_mod.sm_op #define sml_desc sml_mod.sm_desc #define sml_type sml_mod.sm_type -#define sml_bvalues sml_mod.sm_values #define sml_values sml_mod.sm_values #define sml_nvalues sml_mod.sm_nvalues struct slap_mod_list *sml_next; @@ -1055,7 +1053,6 @@ typedef struct slap_ldap_modlist { #define ml_op ml_mod.mod_op #define ml_type ml_mod.mod_type #define ml_values ml_mod.mod_values -#define ml_bvalues ml_mod.mod_values } LDAPModList; /* diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index e08b23bb6d..415e80fb13 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -392,11 +392,11 @@ slapi_int_ldapmod_to_entry( * being passed in may not have been allocated on the * heap. */ - rc = bvptr2obj_copy( pMod->mod_bvalues, &bv ); + rc = bvptr2obj_copy( pMod->mod_values, &bv ); if ( rc != LDAP_SUCCESS ) goto cleanup; tmp.sml_type.bv_val = pMod->mod_type; tmp.sml_type.bv_len = strlen( pMod->mod_type ); - tmp.sml_bvalues = bv; + tmp.sml_values = bv; tmp.sml_nvalues = NULL; mod = (Modifications *) ch_malloc( sizeof(Modifications) ); @@ -405,7 +405,7 @@ slapi_int_ldapmod_to_entry( mod->sml_next = NULL; mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; - mod->sml_bvalues = tmp.sml_bvalues; + mod->sml_values = tmp.sml_values; mod->sml_nvalues = tmp.sml_nvalues; *modtail = mod; @@ -421,7 +421,7 @@ slapi_int_ldapmod_to_entry( if ( rc != LDAP_SUCCESS ) goto cleanup; tmp.sml_type.bv_val = pMod->mod_type; tmp.sml_type.bv_len = strlen( pMod->mod_type ); - tmp.sml_bvalues = bv; + tmp.sml_values = bv; tmp.sml_nvalues = NULL; mod = (Modifications *) ch_malloc( sizeof(Modifications) ); @@ -430,7 +430,7 @@ slapi_int_ldapmod_to_entry( mod->sml_next = NULL; mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; - mod->sml_bvalues = tmp.sml_bvalues; + mod->sml_values = tmp.sml_values; mod->sml_nvalues = tmp.sml_nvalues; *modtail = mod; @@ -954,12 +954,12 @@ slapi_modify_internal( * convert an array of pointers to bervals * to an array of bervals */ - rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv ); + rs.sr_err = bvptr2obj_copy( pMod->mod_values, &bv ); if ( rs.sr_err != LDAP_SUCCESS ) goto cleanup; tmp.sml_type.bv_val = pMod->mod_type; tmp.sml_type.bv_len = strlen( pMod->mod_type ); - tmp.sml_bvalues = bv; + tmp.sml_values = bv; tmp.sml_nvalues = NULL; mod = (Modifications *)ch_malloc( sizeof(Modifications) ); @@ -968,7 +968,7 @@ slapi_modify_internal( mod->sml_next = NULL; mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; - mod->sml_bvalues = tmp.sml_bvalues; + mod->sml_values = tmp.sml_values; mod->sml_nvalues = tmp.sml_nvalues; } else { rs.sr_err = values2obj_copy( pMod->mod_values, &bv ); @@ -976,7 +976,7 @@ slapi_modify_internal( goto cleanup; tmp.sml_type.bv_val = pMod->mod_type; tmp.sml_type.bv_len = strlen( pMod->mod_type ); - tmp.sml_bvalues = bv; + tmp.sml_values = bv; tmp.sml_nvalues = NULL; mod = (Modifications *) ch_malloc( sizeof(Modifications) ); @@ -985,7 +985,7 @@ slapi_modify_internal( mod->sml_next = NULL; mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; - mod->sml_bvalues = tmp.sml_bvalues; + mod->sml_values = tmp.sml_values; mod->sml_nvalues = tmp.sml_nvalues; } *modtail = mod; @@ -993,7 +993,7 @@ slapi_modify_internal( switch( pMod->mod_op & LDAP_MOD_OP ) { case LDAP_MOD_ADD: - if ( mod->sml_bvalues == NULL ) { + if ( mod->sml_values == NULL ) { rs.sr_err = LDAP_PROTOCOL_ERROR; goto cleanup; } diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 5b5172e015..98e6b94240 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -558,12 +558,12 @@ slapi_entry_add_values( Slapi_Entry *e, const char *type, struct berval **vals ) if ( vals == NULL ) { /* Apparently vals can be NULL - * FIXME: sm_bvalues = NULL ? */ - mod.sm_bvalues = (BerVarray)ch_malloc( sizeof(struct berval) ); - mod.sm_bvalues->bv_val = NULL; + * FIXME: sm_values = NULL ? */ + mod.sm_values = (BerVarray)ch_malloc( sizeof(struct berval) ); + mod.sm_values->bv_val = NULL; } else { - rc = bvptr2obj( vals, &mod.sm_bvalues ); + rc = bvptr2obj( vals, &mod.sm_values ); if ( rc != LDAP_SUCCESS ) { return LDAP_CONSTRAINT_VIOLATION; } @@ -572,7 +572,7 @@ slapi_entry_add_values( Slapi_Entry *e, const char *type, struct berval **vals ) rc = modify_add_values( e, &mod, 0, &text, textbuf, sizeof(textbuf) ); - ch_free( mod.sm_bvalues ); + ch_free( mod.sm_values ); return (rc == LDAP_SUCCESS) ? LDAP_SUCCESS : LDAP_CONSTRAINT_VIOLATION; #else @@ -638,7 +638,7 @@ slapi_entry_delete_values( Slapi_Entry *e, const char *type, struct berval **val return attr_delete( &e->e_attrs, mod.sm_desc ) ? LDAP_OTHER : LDAP_SUCCESS; } - rc = bvptr2obj( vals, &mod.sm_bvalues ); + rc = bvptr2obj( vals, &mod.sm_values ); if ( rc != LDAP_SUCCESS ) { return LDAP_CONSTRAINT_VIOLATION; } @@ -646,7 +646,7 @@ slapi_entry_delete_values( Slapi_Entry *e, const char *type, struct berval **val rc = modify_delete_values( e, &mod, 0, &text, textbuf, sizeof(textbuf) ); - ch_free( mod.sm_bvalues ); + ch_free( mod.sm_values ); return rc; #else @@ -3336,7 +3336,7 @@ int slapi_acl_check_mods(Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char mp = ml->sml_next; /* just free the containing array */ - slapi_ch_free( (void **)&ml->sml_bvalues ); + slapi_ch_free( (void **)&ml->sml_values ); slapi_ch_free( (void **)&ml ); } @@ -3377,22 +3377,22 @@ LDAPMod **slapi_int_modifications2ldapmods(Modifications **pmodlist) modp->mod_type = ml->sml_type.bv_val; ml->sml_type.bv_val = NULL; - if ( ml->sml_bvalues != NULL ) { - for( j = 0; ml->sml_bvalues[j].bv_val != NULL; j++ ) + if ( ml->sml_values != NULL ) { + for( j = 0; ml->sml_values[j].bv_val != NULL; j++ ) ; - modp->mod_bvalues = (struct berval **)ch_malloc( (j + 1) * + modp->mod_values = (struct berval **)ch_malloc( (j + 1) * sizeof(struct berval *) ); - for( j = 0; ml->sml_bvalues[j].bv_val != NULL; j++ ) { + for( j = 0; ml->sml_values[j].bv_val != NULL; j++ ) { /* Take ownership of original values. */ - modp->mod_bvalues[j] = (struct berval *)ch_malloc( sizeof(struct berval) ); - modp->mod_bvalues[j]->bv_len = ml->sml_bvalues[j].bv_len; - modp->mod_bvalues[j]->bv_val = ml->sml_bvalues[j].bv_val; - ml->sml_bvalues[j].bv_len = 0; - ml->sml_bvalues[j].bv_val = NULL; + modp->mod_values[j] = (struct berval *)ch_malloc( sizeof(struct berval) ); + modp->mod_values[j]->bv_len = ml->sml_values[j].bv_len; + modp->mod_values[j]->bv_val = ml->sml_values[j].bv_val; + ml->sml_values[j].bv_len = 0; + ml->sml_values[j].bv_val = NULL; } - modp->mod_bvalues[j] = NULL; + modp->mod_values[j] = NULL; } else { - modp->mod_bvalues = NULL; + modp->mod_values = NULL; } i++; } @@ -3438,7 +3438,7 @@ Modifications *slapi_int_ldapmods2modifications (LDAPMod **mods) mod->sml_next = NULL; if ( (*modp)->mod_op & LDAP_MOD_BVALUES ) { - for( i = 0, bvp = (*modp)->mod_bvalues; bvp != NULL && *bvp != NULL; bvp++, i++ ) + for( i = 0, bvp = (*modp)->mod_values; bvp != NULL && *bvp != NULL; bvp++, i++ ) ; } else { for( i = 0, p = (*modp)->mod_values; p != NULL && *p != NULL; p++, i++ ) @@ -3446,24 +3446,24 @@ Modifications *slapi_int_ldapmods2modifications (LDAPMod **mods) } if ( i == 0 ) { - mod->sml_bvalues = NULL; + mod->sml_values = NULL; } else { - mod->sml_bvalues = (BerVarray) ch_malloc( (i + 1) * sizeof(struct berval) ); + mod->sml_values = (BerVarray) ch_malloc( (i + 1) * sizeof(struct berval) ); /* NB: This implicitly trusts a plugin to return valid modifications. */ if ( (*modp)->mod_op & LDAP_MOD_BVALUES ) { - for( i = 0, bvp = (*modp)->mod_bvalues; bvp != NULL && *bvp != NULL; bvp++, i++ ) { - mod->sml_bvalues[i].bv_val = (*bvp)->bv_val; - mod->sml_bvalues[i].bv_len = (*bvp)->bv_len; + for( i = 0, bvp = (*modp)->mod_values; bvp != NULL && *bvp != NULL; bvp++, i++ ) { + mod->sml_values[i].bv_val = (*bvp)->bv_val; + mod->sml_values[i].bv_len = (*bvp)->bv_len; } } else { for( i = 0, p = (*modp)->mod_values; p != NULL && *p != NULL; p++, i++ ) { - mod->sml_bvalues[i].bv_val = *p; - mod->sml_bvalues[i].bv_len = strlen( *p ); + mod->sml_values[i].bv_val = *p; + mod->sml_values[i].bv_len = strlen( *p ); } } - mod->sml_bvalues[i].bv_val = NULL; - mod->sml_bvalues[i].bv_len = 0; + mod->sml_values[i].bv_val = NULL; + mod->sml_values[i].bv_len = 0; } mod->sml_nvalues = NULL; @@ -3497,10 +3497,10 @@ void slapi_int_free_ldapmods (LDAPMod **mods) * Modification list. Do free the containing array. */ if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) { - for ( j = 0; mods[i]->mod_bvalues != NULL && mods[i]->mod_bvalues[j] != NULL; j++ ) { - ch_free( mods[i]->mod_bvalues[j] ); + for ( j = 0; mods[i]->mod_values != NULL && mods[i]->mod_values[j] != NULL; j++ ) { + ch_free( mods[i]->mod_values[j] ); } - ch_free( mods[i]->mod_bvalues ); + ch_free( mods[i]->mod_values ); } else { ch_free( mods[i]->mod_values ); } diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 125d10ba68..244a7a5031 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -977,7 +977,7 @@ syncrepl_message_to_entry( mod->sml_next = NULL; mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; - mod->sml_bvalues = tmp.sml_bvalues; + mod->sml_values = tmp.sml_values; mod->sml_nvalues = NULL; *modtail = mod; @@ -1197,7 +1197,7 @@ syncrepl_entry( mod->sml_op = LDAP_MOD_REPLACE; mod->sml_desc = slap_schema.si_ad_entryUUID; mod->sml_type = mod->sml_desc->ad_cname; - ber_bvarray_add( &mod->sml_bvalues, &uuid_bv ); + ber_bvarray_add( &mod->sml_values, &uuid_bv ); modtail->sml_next = mod; op->o_tag = LDAP_REQ_MODIFY; @@ -1360,7 +1360,7 @@ syncrepl_del_nonpresent( mod->sml_op = LDAP_MOD_REPLACE; mod->sml_desc = slap_schema.si_ad_objectClass; mod->sml_type = mod->sml_desc->ad_cname; - mod->sml_bvalues = &gcbva[0]; + mod->sml_values = &gcbva[0]; *modtail = mod; modtail = &mod->sml_next; @@ -1368,7 +1368,7 @@ syncrepl_del_nonpresent( mod->sml_op = LDAP_MOD_REPLACE; mod->sml_desc = slap_schema.si_ad_structuralObjectClass; mod->sml_type = mod->sml_desc->ad_cname; - mod->sml_bvalues = &gcbva[1]; + mod->sml_values = &gcbva[1]; *modtail = mod; modtail = &mod->sml_next; @@ -1615,7 +1615,7 @@ syncrepl_updateCookie( mod->sml_op = LDAP_MOD_REPLACE; mod->sml_desc = slap_schema.si_ad_objectClass; mod->sml_type = mod->sml_desc->ad_cname; - mod->sml_bvalues = ocbva; + mod->sml_values = ocbva; *modtail = mod; modtail = &mod->sml_next; @@ -1628,7 +1628,7 @@ syncrepl_updateCookie( mod->sml_op = LDAP_MOD_REPLACE; mod->sml_desc = slap_schema.si_ad_cn; mod->sml_type = mod->sml_desc->ad_cname; - mod->sml_bvalues = cnbva; + mod->sml_values = cnbva; *modtail = mod; modtail = &mod->sml_next; @@ -1638,7 +1638,7 @@ syncrepl_updateCookie( mod->sml_op = LDAP_MOD_REPLACE; mod->sml_desc = slap_schema.si_ad_syncreplCookie; mod->sml_type = mod->sml_desc->ad_cname; - mod->sml_bvalues = scbva; + mod->sml_values = scbva; *modtail = mod; modtail = &mod->sml_next; @@ -1646,7 +1646,7 @@ syncrepl_updateCookie( mod->sml_op = LDAP_MOD_REPLACE; mod->sml_desc = slap_schema.si_ad_subtreeSpecification; mod->sml_type = mod->sml_desc->ad_cname; - mod->sml_bvalues = ssbva; + mod->sml_values = ssbva; *modtail = mod; modtail = &mod->sml_next; -- 2.39.5