From c1edf76e2046c52da6b74324446352973e22cb06 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 1 May 2002 17:45:03 +0000 Subject: [PATCH] use BerVarray for suffix_massaging stuff --- servers/slapd/back-ldap/back-ldap.h | 2 +- servers/slapd/back-ldap/config.c | 10 ++++++---- servers/slapd/back-ldap/init.c | 2 +- servers/slapd/back-ldap/search.c | 11 +++++------ servers/slapd/back-ldap/suffixmassage.c | 10 +++++----- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h index 81f8b0c871..3145ddd881 100644 --- a/servers/slapd/back-ldap/back-ldap.h +++ b/servers/slapd/back-ldap/back-ldap.h @@ -80,7 +80,7 @@ struct ldapinfo { #ifdef ENABLE_REWRITE struct rewrite_info *rwinfo; #else /* !ENABLE_REWRITE */ - struct berval **suffix_massage; + BerVarray suffix_massage; #endif /* !ENABLE_REWRITE */ struct ldapmap oc_map; diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index 3343dc594a..6df5ff97e2 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -126,7 +126,9 @@ ldap_back_db_config( BackendDB *tmp_be; struct berval bvnc, *nvnc = NULL, *pvnc = NULL, brnc, *nrnc = NULL, *prnc = NULL; +#ifdef ENABLE_REWRITE int rc; +#endif /* ENABLE_REWRITE */ /* * syntax: @@ -211,11 +213,11 @@ ldap_back_db_config( return( rc ); #else /* !ENABLE_REWRITE */ - ber_bvecadd( &li->suffix_massage, pvnc ); - ber_bvecadd( &li->suffix_massage, nvnc ); + ber_bvarray_add( &li->suffix_massage, pvnc ); + ber_bvarray_add( &li->suffix_massage, nvnc ); - ber_bvecadd( &li->suffix_massage, prnc ); - ber_bvecadd( &li->suffix_massage, nrnc ); + ber_bvarray_add( &li->suffix_massage, prnc ); + ber_bvarray_add( &li->suffix_massage, nrnc ); #endif /* !ENABLE_REWRITE */ /* rewrite stuff ... */ diff --git a/servers/slapd/back-ldap/init.c b/servers/slapd/back-ldap/init.c index d744a97681..2b4a1c81f9 100644 --- a/servers/slapd/back-ldap/init.c +++ b/servers/slapd/back-ldap/init.c @@ -183,7 +183,7 @@ ldap_back_db_destroy( } #else /* !ENABLE_REWRITE */ if (li->suffix_massage) { - ber_bvecfree( li->suffix_massage ); + ber_bvarray_free( li->suffix_massage ); } #endif /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index d85babb9cd..a3de170009 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -479,18 +479,19 @@ ldap_send_entry( * It is necessary to try to rewrite attributes with * dn syntax because they might be used in ACLs as * members of groups; since ACLs are applied to the - * rewritten stuff, no dn-based subecj clause could + * rewritten stuff, no dn-based subject clause could * be used at the ldap backend side (see * http://www.OpenLDAP.org/faq/data/cache/452.html) * The problem can be overcome by moving the dn-based * ACLs to the target directory server, and letting * everything pass thru the ldap backend. */ + /* FIXME: #ifndef ENABLE_REWRITE should we massage these? */ } else if ( strcmp( attr->a_desc->ad_type->sat_syntax->ssyn_oid, SLAPD_DN_SYNTAX ) == 0 ) { int i; for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++, i++ ) { - char *newval; + char *newval = NULL; switch ( rewrite_session( li->rwinfo, "searchResult", @@ -516,9 +517,7 @@ ldap_send_entry( bv->bv_val, newval ); #endif /* !NEW_LOGGING */ free( bv->bv_val ); - bv->bv_val = newval; - bv->bv_len = strlen( newval ); - + ber_str2bv( newval, 0, 0, bv ); break; case REWRITE_REGEXEC_UNWILLING: @@ -547,7 +546,7 @@ ldap_send_entry( ch_free(attr); } - if ( ent.e_dn && ent.e_dn != bdn.bv_val ) + if ( ent.e_dn && ( ent.e_dn != bdn.bv_val ) ) free( ent.e_dn ); if ( ent.e_ndn ) free( ent.e_ndn ); diff --git a/servers/slapd/back-ldap/suffixmassage.c b/servers/slapd/back-ldap/suffixmassage.c index 0847740f02..9f0311e6e7 100644 --- a/servers/slapd/back-ldap/suffixmassage.c +++ b/servers/slapd/back-ldap/suffixmassage.c @@ -74,9 +74,9 @@ ldap_back_dn_massage( } for ( i = 0; - li->suffix_massage[i] != NULL; + li->suffix_massage[i].bv_val != NULL; i += 4 ) { - int aliasLength = li->suffix_massage[i+src]->bv_len; + int aliasLength = li->suffix_massage[i+src].bv_len; int diff = dn->bv_len - aliasLength; if ( diff < 0 ) { @@ -91,11 +91,11 @@ ldap_back_dn_massage( /* XXX or an escaped separator... oh well */ } - if ( !strcmp( li->suffix_massage[i+src]->bv_val, &dn->bv_val[diff] ) ) { - res->bv_len = diff + li->suffix_massage[i+dst]->bv_len; + if ( !strcmp( li->suffix_massage[i+src].bv_val, &dn->bv_val[diff] ) ) { + res->bv_len = diff + li->suffix_massage[i+dst].bv_len; res->bv_val = ch_malloc( res->bv_len + 1 ); strncpy( res->bv_val, dn->bv_val, diff ); - strcpy( &res->bv_val[diff], li->suffix_massage[i+dst]->bv_val ); + strcpy( &res->bv_val[diff], li->suffix_massage[i+dst].bv_val ); #ifdef NEW_LOGGING LDAP_LOG (( "suffixmassage", LDAP_LEVEL_ARGS, "ldap_back_dn_massage: converted \"%s\" to \"%s\"\n", -- 2.39.5