mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
use BerVarray for suffix_massaging stuff
This commit is contained in:
parent
1aa96af216
commit
c1edf76e20
5 changed files with 18 additions and 17 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 ... */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue