From: Kurt Zeilenga Date: Wed, 26 Dec 2001 20:59:24 +0000 (+0000) Subject: Update referral handling to use struct berval DNs. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~483 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=21cecb3831e5caa7f9ad5a00e1167a87df81e8b2;p=openldap Update referral handling to use struct berval DNs. --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 5bd01be842..fe8cfed67a 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -237,7 +237,7 @@ do_add( Connection *conn, Operation *op ) be = select_backend( &e->e_nname, manageDSAit, 0 ); if ( be == NULL ) { struct berval **ref = referral_rewrite( default_referral, - NULL, e->e_dn, LDAP_SCOPE_DEFAULT ); + NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : default_referral, NULL ); @@ -329,7 +329,7 @@ do_add( Connection *conn, Operation *op ) struct berval **defref = be->be_update_refs ? be->be_update_refs : default_referral; struct berval **ref = referral_rewrite( defref, - NULL, e->e_dn, LDAP_SCOPE_DEFAULT ); + NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : defref, NULL ); diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 905a856a28..33a2e2f08e 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -121,15 +121,14 @@ retry: rc = txn_abort( ltid ); if ( matched != NULL ) { matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, - matched, e->e_dn, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); matched = NULL; } else { refs = referral_rewrite( default_referral, - NULL, e->e_dn, LDAP_SCOPE_DEFAULT ); + NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); } Debug( LDAP_DEBUG_TRACE, "bdb_add: parent does not exist\n", @@ -167,8 +166,7 @@ retry: rc = txn_abort( ltid ); /* parent is a referral, don't allow add */ char *matched_dn = ch_strdup( p->e_dn ); struct berval **refs = is_entry_referral( p ) - ? get_entry_referrals( be, conn, op, p, - e->e_dn, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, p ) : NULL; Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is referral\n", diff --git a/servers/slapd/back-bdb/bind.c b/servers/slapd/back-bdb/bind.c index 371bc15fb4..04be2e37e4 100644 --- a/servers/slapd/back-bdb/bind.c +++ b/servers/slapd/back-bdb/bind.c @@ -64,8 +64,7 @@ bdb_bind( matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); @@ -73,7 +72,7 @@ bdb_bind( } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } /* allow noauth binds */ @@ -125,7 +124,7 @@ bdb_bind( if ( is_entry_referral( e ) ) { /* entry is a referral, don't allow bind */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 ); diff --git a/servers/slapd/back-bdb/compare.c b/servers/slapd/back-bdb/compare.c index 71b072ae3b..ce394d387b 100644 --- a/servers/slapd/back-bdb/compare.c +++ b/servers/slapd/back-bdb/compare.c @@ -51,15 +51,14 @@ bdb_compare( if ( matched != NULL ) { matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); matched = NULL; } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, rc = LDAP_REFERRAL, @@ -74,7 +73,7 @@ bdb_compare( if (!manageDSAit && is_entry_referral( e ) ) { /* entry is a referral, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 ); diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 30e2bc6350..442a992a69 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -97,15 +97,14 @@ retry: /* transaction retry */ if ( matched != NULL ) { matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); matched = NULL; } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, LDAP_REFERRAL, @@ -194,7 +193,7 @@ retry: /* transaction retry */ /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); Debug( LDAP_DEBUG_TRACE, "bdb_delete: entry is referral\n", diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index d475840d56..47ee9f247e 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -235,15 +235,14 @@ retry: /* transaction retry */ if ( matched != NULL ) { matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); matched = NULL; } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, rc = LDAP_REFERRAL, @@ -259,7 +258,7 @@ retry: /* transaction retry */ /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); Debug( LDAP_DEBUG_TRACE, "bdb_modify: entry is referral\n", diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index a356ba437b..91b6a00cb3 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -127,15 +127,14 @@ retry: /* transaction retry */ if( matched != NULL ) { matched_dn = strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); matched = NULL; } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, rc = LDAP_REFERRAL, @@ -151,7 +150,7 @@ retry: /* transaction retry */ /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n", e->e_dn, 0, 0 ); diff --git a/servers/slapd/back-bdb/referral.c b/servers/slapd/back-bdb/referral.c index c02b78b1a7..7a827ed2b6 100644 --- a/servers/slapd/back-bdb/referral.c +++ b/servers/slapd/back-bdb/referral.c @@ -65,8 +65,7 @@ bdb_referrals( if( is_entry_referral( matched ) ) { rc = LDAP_OTHER; - refs = get_entry_referrals( be, conn, op, - matched, dn->bv_val, LDAP_SCOPE_DEFAULT ); + refs = get_entry_referrals( be, conn, op, matched ); } bdb_entry_return( be, matched ); @@ -74,7 +73,7 @@ bdb_referrals( } else if ( default_referral != NULL ) { rc = LDAP_OTHER; refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } if( refs != NULL ) { @@ -95,9 +94,9 @@ bdb_referrals( if ( is_entry_referral( e ) ) { /* entry is a referral */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); struct berval **rrefs = referral_rewrite( - refs, e->e_dn, dn->bv_val, LDAP_SCOPE_DEFAULT ); + refs, &e->e_name, dn, LDAP_SCOPE_DEFAULT ); Debug( LDAP_DEBUG_TRACE, "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n", diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index d3a5bb0213..d930f9d09c 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -92,16 +92,15 @@ bdb_search( } if ( e == NULL ) { - char *matched_dn = NULL; + struct berval *matched_dn = NULL; struct berval **refs = NULL; if ( matched != NULL ) { struct berval **erefs; - matched_dn = ch_strdup( matched->e_dn ); + matched_dn = ber_bvdup( &matched->e_name ); erefs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - base->bv_val, scope ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); @@ -109,29 +108,28 @@ bdb_search( if( erefs ) { refs = referral_rewrite( erefs, matched_dn, - base->bv_val, scope ); + base, scope ); ber_bvecfree( erefs ); } } else { refs = referral_rewrite( default_referral, - NULL, base->bv_val, scope ); + NULL, base, scope ); } send_ldap_result( conn, op, rc=LDAP_REFERRAL , - matched_dn, text, refs, NULL ); + matched_dn->bv_val, text, refs, NULL ); ber_bvecfree( refs ); - free( matched_dn ); - + ber_bvfree( matched_dn ); return rc; } if (!manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) { /* entry is a referral, don't allow add */ - char *matched_dn = ch_strdup( e->e_dn ); + struct berval *matched_dn = ber_bvdup( &e->e_name ); struct berval **erefs = get_entry_referrals( be, - conn, op, e, base->bv_val, scope ); + conn, op, e ); struct berval **refs = NULL; bdb_entry_return( be, e ); @@ -139,7 +137,7 @@ bdb_search( if( erefs ) { refs = referral_rewrite( erefs, matched_dn, - base->bv_val, scope ); + base, scope ); ber_bvecfree( erefs ); } @@ -147,12 +145,12 @@ bdb_search( 0, 0, 0 ); send_ldap_result( conn, op, LDAP_REFERRAL, - matched_dn, refs ? NULL : "bad referral object", + matched_dn->bv_val, + refs ? NULL : "bad referral object", refs, NULL ); ber_bvecfree( refs ); - free( matched_dn ); - + ber_bvfree( matched_dn ); return 1; } @@ -356,8 +354,9 @@ bdb_search( is_entry_referral( e ) ) { struct berval **erefs = get_entry_referrals( - be, conn, op, e, NULL, scope ); - struct berval **refs = referral_rewrite( erefs, e->e_dn, NULL, + be, conn, op, e ); + struct berval **refs = referral_rewrite( erefs, + &e->e_name, NULL, scope == LDAP_SCOPE_SUBTREE ? LDAP_SCOPE_SUBTREE : LDAP_SCOPE_BASE ); diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 1b86663a23..059abb0311 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -97,14 +97,13 @@ ldbm_back_add( if ( matched != NULL ) { matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - e->e_dn, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { refs = referral_rewrite( default_referral, - NULL, e->e_dn, LDAP_SCOPE_DEFAULT ); + NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); } #ifdef NEW_LOGGING @@ -176,8 +175,7 @@ ldbm_back_add( /* parent is a referral, don't allow add */ char *matched_dn = ch_strdup( p->e_dn ); struct berval **refs = is_entry_referral( p ) - ? get_entry_referrals( be, conn, op, p, - e->e_dn, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, p ) : NULL; /* free parent and writer lock */ diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index b76fc0c8dc..38bb9cfa86 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -62,15 +62,14 @@ ldbm_back_bind( matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } /* allow noauth binds */ @@ -128,7 +127,7 @@ ldbm_back_bind( if ( is_entry_referral( e ) ) { /* entry is a referral, don't allow bind */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index a1b49111a6..574c32d8fa 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -41,13 +41,12 @@ ldbm_back_compare( if ( matched != NULL ) { matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, LDAP_REFERRAL, @@ -62,7 +61,7 @@ ldbm_back_compare( if (!manageDSAit && is_entry_referral( e ) ) { /* entry is a referral, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index c1d619841d..d1a53967bc 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -57,14 +57,13 @@ ldbm_back_delete( if ( matched != NULL ) { matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, LDAP_REFERRAL, @@ -80,7 +79,7 @@ ldbm_back_delete( /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, @@ -91,7 +90,6 @@ ldbm_back_delete( 0, 0 ); #endif - send_ldap_result( conn, op, LDAP_REFERRAL, e->e_dn, NULL, refs, NULL ); diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 5cda33e37c..7ff5926457 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -275,13 +275,12 @@ ldbm_back_modify( if ( matched != NULL ) { matched_dn = ch_strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, LDAP_REFERRAL, @@ -297,7 +296,7 @@ ldbm_back_modify( /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index d7ab87d506..c2be3c73e9 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -98,13 +98,12 @@ ldbm_back_modrdn( if( matched != NULL ) { matched_dn = strdup( matched->e_dn ); refs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } send_ldap_result( conn, op, LDAP_REFERRAL, @@ -120,7 +119,7 @@ ldbm_back_modrdn( /* parent is a referral, don't allow add */ /* parent is an alias, don't allow add */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, diff --git a/servers/slapd/back-ldbm/referral.c b/servers/slapd/back-ldbm/referral.c index 468d79b870..ed47d6b8b9 100644 --- a/servers/slapd/back-ldbm/referral.c +++ b/servers/slapd/back-ldbm/referral.c @@ -59,8 +59,7 @@ ldbm_back_referrals( if( is_entry_referral( matched ) ) { rc = LDAP_OTHER; - refs = get_entry_referrals( be, conn, op, matched, - dn->bv_val, LDAP_SCOPE_DEFAULT ); + refs = get_entry_referrals( be, conn, op, matched ); } cache_return_entry_r( &li->li_cache, matched ); @@ -68,7 +67,7 @@ ldbm_back_referrals( } else if ( default_referral != NULL ) { rc = LDAP_OTHER; refs = referral_rewrite( default_referral, - NULL, dn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, dn, LDAP_SCOPE_DEFAULT ); } if( refs != NULL ) { @@ -90,9 +89,9 @@ ldbm_back_referrals( if ( is_entry_referral( e ) ) { /* entry is a referral */ struct berval **refs = get_entry_referrals( be, - conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT ); + conn, op, e ); struct berval **rrefs = referral_rewrite( - refs, e->e_dn, dn->bv_val, LDAP_SCOPE_DEFAULT ); + refs, &e->e_name, dn, LDAP_SCOPE_DEFAULT ); #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 753477a8e1..89caf85928 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -91,45 +91,44 @@ ldbm_back_search( } if ( e == NULL ) { - char *matched_dn = NULL; + struct berval *matched_dn = NULL; struct berval **refs = NULL; if ( matched != NULL ) { struct berval **erefs; - matched_dn = ch_strdup( matched->e_dn ); + matched_dn = ber_bvdup( &matched->e_name ); erefs = is_entry_referral( matched ) - ? get_entry_referrals( be, conn, op, matched, - base->bv_val, scope ) + ? get_entry_referrals( be, conn, op, matched ) : NULL; cache_return_entry_r( &li->li_cache, matched ); if( erefs ) { refs = referral_rewrite( erefs, matched_dn, - base->bv_val, scope ); + base, scope ); ber_bvecfree( erefs ); } } else { refs = referral_rewrite( default_referral, - NULL, base->bv_val, scope ); + NULL, base, scope ); } send_ldap_result( conn, op, err, - matched_dn, text, refs, NULL ); + matched_dn->bv_val, text, refs, NULL ); ber_bvecfree( refs ); - free( matched_dn ); + ber_bvfree( matched_dn ); return 1; } if (!manageDSAit && is_entry_referral( e ) ) { /* entry is a referral, don't allow add */ - char *matched_dn = ch_strdup( e->e_dn ); + struct berval *matched_dn = ber_bvdup( &e->e_name ); struct berval **erefs = get_entry_referrals( be, - conn, op, e, base->bv_val, scope ); + conn, op, e ); struct berval **refs = NULL; cache_return_entry_r( &li->li_cache, e ); @@ -146,22 +145,23 @@ ldbm_back_search( if( erefs ) { refs = referral_rewrite( erefs, matched_dn, - base->bv_val, scope ); + base, scope ); ber_bvecfree( erefs ); } if( refs ) { send_ldap_result( conn, op, LDAP_REFERRAL, - matched_dn, NULL, refs, NULL ); + matched_dn->bv_val, NULL, refs, NULL ); ber_bvecfree( refs ); } else { - send_ldap_result( conn, op, LDAP_OTHER, matched_dn, - "bad referral object", NULL, NULL ); + send_ldap_result( conn, op, LDAP_OTHER, + matched_dn->bv_val, + "bad referral object", NULL, NULL ); } - free( matched_dn ); + ber_bvfree( matched_dn ); return 1; } @@ -396,8 +396,9 @@ searchit: if( scopeok ) { struct berval **erefs = get_entry_referrals( - be, conn, op, e, NULL, cscope ); - struct berval **refs = referral_rewrite( erefs, e->e_dn, NULL, + be, conn, op, e ); + struct berval **refs = referral_rewrite( erefs, + &e->e_name, NULL, scope == LDAP_SCOPE_SUBTREE ? LDAP_SCOPE_SUBTREE : LDAP_SCOPE_BASE ); diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index aed512bd07..d980c36bb0 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -459,7 +459,7 @@ do_bind( if ( (be = select_backend( ndn, 0, 0 )) == NULL ) { if ( default_referral ) { struct berval **ref = referral_rewrite( default_referral, - NULL, pdn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, pdn, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : default_referral, NULL ); diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index fafdd815b1..77b1c4cd64 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -241,7 +241,7 @@ do_compare( */ if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) { struct berval **ref = referral_rewrite( default_referral, - NULL, pdn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, pdn, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : default_referral, NULL ); diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index dc5393c596..035ed74455 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -145,7 +145,7 @@ do_delete( */ if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) { struct berval **ref = referral_rewrite( default_referral, - NULL, pdn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, pdn, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : default_referral, NULL ); @@ -197,7 +197,7 @@ do_delete( struct berval **defref = be->be_update_refs ? be->be_update_refs : default_referral; struct berval **ref = referral_rewrite( default_referral, - NULL, pdn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, pdn, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : defref, NULL ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 1f283932e0..7b337c8894 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -299,7 +299,7 @@ do_modify( */ if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) { struct berval **ref = referral_rewrite( default_referral, - NULL, pdn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, pdn, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : default_referral, NULL ); @@ -391,7 +391,7 @@ do_modify( struct berval **defref = be->be_update_refs ? be->be_update_refs : default_referral; struct berval **ref = referral_rewrite( defref, - NULL, pdn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, pdn, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : defref, NULL ); diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index d07242eb40..e3b0264d5c 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -325,7 +325,7 @@ do_modrdn( */ if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) { struct berval **ref = referral_rewrite( default_referral, - NULL, dn.bv_val, LDAP_SCOPE_DEFAULT ); + NULL, pdn, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : default_referral, NULL ); @@ -403,7 +403,7 @@ do_modrdn( struct berval **defref = be->be_update_refs ? be->be_update_refs : default_referral; struct berval **ref = referral_rewrite( defref, - NULL, pdn->bv_val, LDAP_SCOPE_DEFAULT ); + NULL, pdn, LDAP_SCOPE_DEFAULT ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : defref, NULL ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 547e5e92d5..b23655286b 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -581,13 +581,12 @@ LDAP_SLAPD_F (int) validate_global_referral LDAP_P(( const char *url )); LDAP_SLAPD_F (struct berval **) get_entry_referrals LDAP_P(( - Backend *be, Connection *conn, Operation *op, - Entry *e, const char *target, int scope )); + Backend *be, Connection *conn, Operation *op, Entry *e )); LDAP_SLAPD_F (struct berval **) referral_rewrite LDAP_P(( struct berval **refs, - const char *base, - const char *target, + struct berval *base, + struct berval *target, int scope )); /* diff --git a/servers/slapd/referral.c b/servers/slapd/referral.c index 272f945080..147a1c899c 100644 --- a/servers/slapd/referral.c +++ b/servers/slapd/referral.c @@ -215,8 +215,8 @@ int validate_global_referral( const char *url ) struct berval ** referral_rewrite( struct berval **in, - const char *base, - const char *target, + struct berval *base, + struct berval *target, int scope ) { int i, j; @@ -247,7 +247,9 @@ struct berval ** referral_rewrite( { char *dn = url->lud_dn; url->lud_dn = referral_dn_muck( - ( dn && *dn ) ? dn : NULL, base, target ); + ( dn && *dn ) ? dn : NULL, + base ? base->bv_val : NULL, + target ? target->bv_val : NULL ); ldap_memfree( dn ); } @@ -281,9 +283,7 @@ struct berval **get_entry_referrals( Backend *be, Connection *conn, Operation *op, - Entry *e, - const char *dn, - int scope ) + Entry *e ) { Attribute *attr; struct berval **refs; diff --git a/servers/slapd/search.c b/servers/slapd/search.c index c365d4131e..f8de23a687 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -299,7 +299,7 @@ do_search( */ if ( (be = select_backend( nbase, manageDSAit, 1 )) == NULL ) { struct berval **ref = referral_rewrite( default_referral, - NULL, pbase->bv_val, scope ); + NULL, pbase, scope ); send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL, ref ? ref : default_referral, NULL );