slight improvements; doesn't work yet

This commit is contained in:
Pierangelo Masarati 2004-03-17 09:25:59 +00:00
parent 1d9fa315ac
commit 737f3d8636
3 changed files with 52 additions and 22 deletions

View File

@ -50,6 +50,7 @@ relay_back_db_config(
if ( strcasecmp( argv[0], "relay" ) == 0 ) {
struct berval dn, ndn, pdn;
int rc;
char *cargv[ 4 ];
if (argc != 2) {
fprintf( stderr,
@ -63,7 +64,7 @@ relay_back_db_config(
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: line %d: "
"relay dn '%s' is invalid\n",
"relay dn \"%s\" is invalid\n",
fname, lineno, argv[ 1 ] );
return 1;
}
@ -72,11 +73,17 @@ relay_back_db_config(
if ( ri->ri_bd == NULL ) {
fprintf( stderr, "%s: line %d: "
"cannot find database "
"of relay dn '%s'\n",
"of relay dn \"%s\"\n",
fname, lineno, argv[ 1 ] );
return 1;
}
} else if ( ri->ri_bd == be ) {
fprintf( stderr, "%s: line %d: "
"relay dn \"%s\" would call self\n",
fname, lineno, pdn.bv_val );
return 1;
}
if ( overlay_config( be, "rewrite-remap" ) ) {
fprintf( stderr, "unable to install "
"rewrite-remap overlay "
@ -84,6 +91,16 @@ relay_back_db_config(
be->be_suffix[0].bv_val,
ri->ri_bd->be_suffix[0].bv_val ?
ri->ri_bd->be_suffix[0].bv_val : "<unknown>" );
return 1;
}
cargv[ 0 ] = "suffixmassage";
cargv[ 1 ] = be->be_suffix[0].bv_val;
cargv[ 2 ] = ri->ri_bd->be_suffix[0].bv_val;
cargv[ 3 ] = NULL;
if ( be->be_config( be, "back-relay", 1, 3, cargv ) ) {
return 1;
}
/* anything else */

View File

@ -87,6 +87,8 @@ relay_back_db_init( Backend *be )
{
relay_back_info *ri;
be->be_private = NULL;
ri = (relay_back_info *)ch_calloc( 1, sizeof( relay_back_info ) );
if ( ri == NULL ) {
return -1;
@ -107,8 +109,6 @@ relay_back_db_open( Backend *be )
assert( ri != NULL );
#if 0
be->bd_info = ri->ri_bd->bd_info;
if ( !ri->ri_do_not_massage ) {
char *argv[ 4 ];

View File

@ -36,20 +36,28 @@ relay_back_select_backend( struct slap_op *op, struct slap_rep *rs, int err )
if ( bd == NULL ) {
bd = select_backend( &op->o_req_ndn, 0, 1 );
if ( bd == op->o_bd ) {
if ( err != LDAP_SUCCESS ) {
send_ldap_error( op, rs,
LDAP_UNWILLING_TO_PERFORM,
"would call self" );
}
return NULL;
}
}
if ( bd == NULL ) {
if ( default_referral ) {
rs->sr_ref = referral_rewrite( default_referral,
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) {
if ( !rs->sr_ref ) {
rs->sr_ref = default_referral;
}
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if (rs->sr_ref != default_referral) {
if ( rs->sr_ref != default_referral ) {
ber_bvarray_free( rs->sr_ref );
}
@ -425,16 +433,12 @@ relay_back_entry_get_rw( struct slap_op *op, struct berval *ndn,
int
relay_back_chk_referrals( struct slap_op *op, struct slap_rep *rs )
{
relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
BackendDB *bd;
int rc = 1;
int rc = 0;
bd = ri->ri_bd;
if ( bd == NULL) {
bd = select_backend( &op->o_req_ndn, 0, 1 );
if ( bd == NULL ) {
return 1;
}
bd = relay_back_select_backend( op, rs, LDAP_SUCCESS );
if ( bd == NULL ) {
return 0;
}
if ( bd->be_chk_referrals ) {
@ -509,12 +513,16 @@ relay_back_connection_init( BackendDB *bd, struct slap_conn *c )
{
relay_back_info *ri = (relay_back_info *)bd->be_private;
if ( ri->ri_bd->be_connection_init ) {
return ( ri->ri_bd->be_connection_init )( ri->ri_bd, c );
bd = ri->ri_bd;
if ( bd == NULL ) {
return 0;
}
return 1;
if ( bd->be_connection_init ) {
return ( bd->be_connection_init )( bd, c );
}
return 0;
}
int
@ -522,11 +530,16 @@ relay_back_connection_destroy( BackendDB *bd, struct slap_conn *c )
{
relay_back_info *ri = (relay_back_info *)bd->be_private;
if ( ri->ri_bd->be_connection_destroy ) {
return ( ri->ri_bd->be_connection_destroy )( ri->ri_bd, c );
bd = ri->ri_bd;
if ( bd == NULL) {
return 0;
}
return 1;
if ( bd->be_connection_destroy ) {
return ( bd->be_connection_destroy )( bd, c );
}
return 0;
}