the patch from ITS#1289 to be ported here.
}
if ( p == NULL ) {
- char *matched_dn;
+ char *matched_dn = NULL;
struct berval **refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
+ ? get_entry_referrals( be, conn, op,
+ matched, e->e_dn, LDAP_SCOPE_DEFAULT )
: NULL;
bdb_entry_return( be, matched );
matched = NULL;
} else {
- matched_dn = NULL;
- refs = default_referral;
+ refs = referral_rewrite( default_referral,
+ NULL, e->e_dn, LDAP_SCOPE_DEFAULT );
}
Debug( LDAP_DEBUG_TRACE, "bdb_add: parent does not exist\n",
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- if( matched != NULL ) {
- ber_bvecfree( refs );
- ch_free( matched_dn );
- }
+ ber_bvecfree( refs );
+ ch_free( matched_dn );
goto done;
}
/* 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 )
+ ? get_entry_referrals( be, conn, op, p,
+ e->e_dn, LDAP_SCOPE_DEFAULT )
: NULL;
Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is referral\n",
/* get entry with reader lock */
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs = NULL;
+ struct berval **refs;
if( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
+ ? get_entry_referrals( be, conn, op, matched,
+ dn, LDAP_SCOPE_DEFAULT )
: NULL;
bdb_entry_return( be, matched );
matched = NULL;
} else {
- refs = default_referral;
+ refs = referral_rewrite( default_referral,
+ NULL, dn, LDAP_SCOPE_DEFAULT );
}
/* allow noauth binds */
NULL, NULL, NULL, NULL );
}
- if ( matched != NULL ) {
- ber_bvecfree( refs );
- free( matched_dn );
- }
+ ber_bvecfree( refs );
+ free( matched_dn );
return rc;
}
if ( is_entry_referral( e ) ) {
/* entry is a referral, don't allow bind */
struct berval **refs = get_entry_referrals( be,
- conn, op, e );
+ conn, op, e, dn, LDAP_SCOPE_DEFAULT );
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
0, 0 );
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs = NULL;
+ struct berval **refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
+ ? get_entry_referrals( be, conn, op, matched,
+ dn, LDAP_SCOPE_DEFAULT )
: NULL;
bdb_entry_return( be, matched );
matched = NULL;
} else {
- refs = default_referral;
+ refs = referral_rewrite( default_referral,
+ NULL, dn, LDAP_SCOPE_DEFAULT );
}
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- if( matched != NULL ) {
- ber_bvecfree( refs );
- free( matched_dn );
- }
+ ber_bvecfree( refs );
+ free( matched_dn );
goto done;
}
if (!manageDSAit && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
struct berval **refs = get_entry_referrals( be,
- conn, op, e );
+ conn, op, e, dn, LDAP_SCOPE_DEFAULT );
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
0, 0 );
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs = NULL;
+ struct berval **refs;
Debug( LDAP_DEBUG_ARGS,
"<=- bdb_delete: no such object %s\n",
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
+ ? get_entry_referrals( be, conn, op, matched,
+ dn, LDAP_SCOPE_DEFAULT )
: NULL;
bdb_entry_return( be, matched );
matched = NULL;
} else {
- refs = default_referral;
+ refs = referral_rewrite( default_referral,
+ NULL, dn, LDAP_SCOPE_DEFAULT );
}
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- if ( matched != NULL ) {
- ber_bvecfree( refs );
- free( matched_dn );
- }
+ ber_bvecfree( refs );
+ free( matched_dn );
rc = -1;
goto done;
/* 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 );
+ conn, op, e, dn, LDAP_SCOPE_DEFAULT );
Debug( LDAP_DEBUG_TRACE,
"bdb_delete: entry is referral\n",
/* acquire and lock entry */
if ( e == NULL ) {
char* matched_dn = NULL;
- struct berval **refs = NULL;
+ struct berval **refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
+ ? get_entry_referrals( be, conn, op, matched,
+ dn, LDAP_SCOPE_DEFAULT )
: NULL;
bdb_entry_return( be, matched );
matched = NULL;
} else {
- refs = default_referral;
+ refs = referral_rewrite( default_referral,
+ NULL, dn, LDAP_SCOPE_DEFAULT );
}
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- if ( matched != NULL ) {
- ber_bvecfree( refs );
- free( matched_dn );
- }
+ ber_bvecfree( refs );
+ free( matched_dn );
return rc;
}
/* 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 );
+ conn, op, e, dn, LDAP_SCOPE_DEFAULT );
Debug( LDAP_DEBUG_TRACE,
"bdb_modify: entry is referral\n",
if ( e == NULL ) {
char* matched_dn = NULL;
- struct berval** refs = NULL;
+ struct berval** refs;
if( matched != NULL ) {
matched_dn = strdup( matched->e_dn );
refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
+ ? get_entry_referrals( be, conn, op, matched,
+ dn, LDAP_SCOPE_DEFAULT )
: NULL;
bdb_entry_return( be, matched );
matched = NULL;
} else {
- refs = default_referral;
+ refs = referral_rewrite( default_referral,
+ NULL, dn, LDAP_SCOPE_DEFAULT );
}
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- if ( matched != NULL ) {
- ber_bvecfree( refs );
- free( matched_dn );
- }
+ ber_bvecfree( refs );
+ free( matched_dn );
goto done;
}
/* 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 );
+ conn, op, e, dn, LDAP_SCOPE_DEFAULT );
- Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is referral\n",
- 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
+ e->e_dn, 0, 0 );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
switch(rc) {
case DB_NOTFOUND:
+ rc = 0;
case 0:
break;
default:
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs = default_referral;
+ struct berval **refs = NULL;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
(long) op->o_tag, dn, matched_dn );
- refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
- : NULL;
+ if( is_entry_referral( matched ) ) {
+ rc = LDAP_OTHER;
+ refs = get_entry_referrals( be, conn, op,
+ matched, dn, LDAP_SCOPE_DEFAULT );
+ }
bdb_entry_return( be, matched );
matched = NULL;
+ } else if ( default_referral != NULL ) {
+ rc = LDAP_OTHER;
+ refs = referral_rewrite( default_referral,
+ NULL, dn, LDAP_SCOPE_DEFAULT );
}
if( refs != NULL ) {
/* send referrals */
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- } else {
- rc = LDAP_SUCCESS;
- }
-
- if( matched != NULL ) {
ber_bvecfree( refs );
- free( matched_dn );
+ } else if ( rc != LDAP_SUCCESS ) {
+ send_ldap_result( conn, op, rc, matched_dn,
+ matched_dn ? "bad referral object" : NULL,
+ NULL, NULL );
}
+ free( matched_dn );
return rc;
}
if ( is_entry_referral( e ) ) {
/* entry is a referral */
struct berval **refs = get_entry_referrals( be,
- conn, op, e );
+ conn, op, e, dn, LDAP_SCOPE_DEFAULT );
+ struct berval **rrefs = referral_rewrite(
+ refs, e->e_dn, dn, LDAP_SCOPE_DEFAULT );
Debug( LDAP_DEBUG_TRACE,
"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
(long) op->o_tag, dn, e->e_dn );
- if( refs != NULL ) {
+ if( rrefs != NULL ) {
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
- e->e_dn, NULL, refs, NULL );
+ e->e_dn, NULL, rrefs, NULL );
+ ber_bvecfree( rrefs );
+ } else {
+ send_ldap_result( conn, op, rc = LDAP_OTHER, e->e_dn,
+ "bad referral object", NULL, NULL );
}
ber_bvecfree( refs );
struct berval **refs = NULL;
if ( matched != NULL ) {
+ struct berval **erefs;
matched_dn = ch_strdup( matched->e_dn );
- refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched )
+ erefs = is_entry_referral( matched )
+ ? get_entry_referrals( be, conn, op, matched,
+ base, scope )
: NULL;
+ bdb_entry_return( be, matched );
+ matched = NULL;
+
+ if( erefs ) {
+ refs = referral_rewrite( erefs, matched_dn,
+ base, scope );
+ ber_bvecfree( erefs );
+ }
+
} else {
- refs = default_referral;
+ refs = referral_rewrite( default_referral,
+ NULL, base, scope );
}
send_ldap_result( conn, op, rc=LDAP_REFERRAL ,
matched_dn, text, refs, NULL );
- if( matched != NULL ) {
- ber_bvecfree( refs );
- free( matched_dn );
- bdb_entry_return( be, matched );
- matched = NULL;
- }
+ ber_bvecfree( refs );
+ free( matched_dn );
return rc;
}
if (!manageDSAit && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
char *matched_dn = ch_strdup( e->e_dn );
- struct berval **refs = get_entry_referrals( be,
- conn, op, e );
+ struct berval **erefs = get_entry_referrals( be,
+ conn, op, e, base, scope );
+ struct berval **refs = NULL;
bdb_entry_return( be, e );
e = NULL;
+ if( erefs ) {
+ refs = referral_rewrite( erefs, matched_dn,
+ base, scope );
+ ber_bvecfree( erefs );
+ }
+
Debug( LDAP_DEBUG_TRACE, "bdb_search: entry is referral\n",
0, 0, 0 );
send_ldap_result( conn, op, LDAP_REFERRAL,
- matched_dn, NULL, refs, NULL );
+ matched_dn, refs ? NULL : "bad referral object",
+ refs, NULL );
ber_bvecfree( refs );
free( matched_dn );
is_entry_referral( e ) )
{
struct berval **refs = get_entry_referrals(
- be, conn, op, e );
+ be, conn, op, e, NULL, scope );
send_search_reference( be, conn, op,
- e, refs, scope, NULL, &v2refs );
+ e, refs, NULL, &v2refs );
ber_bvecfree( refs );