From: Pierangelo Masarati Date: Wed, 17 Mar 2004 12:21:40 +0000 (+0000) Subject: only works with explicit overlay instantiation X-Git-Tag: OPENLDAP_REL_ENG_2_2_BP~244 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3fe2cec561ce0b683e6edd0708b64bed1fe2e870;p=openldap only works with explicit overlay instantiation --- diff --git a/servers/slapd/back-relay/back-relay.h b/servers/slapd/back-relay/back-relay.h index d45c413379..d62474ea33 100644 --- a/servers/slapd/back-relay/back-relay.h +++ b/servers/slapd/back-relay/back-relay.h @@ -29,6 +29,8 @@ LDAP_BEGIN_DECL typedef struct relay_back_info { BackendDB *ri_bd; + struct berval ri_realsuffix; + int ri_massage; } relay_back_info; LDAP_END_DECL diff --git a/servers/slapd/back-relay/config.c b/servers/slapd/back-relay/config.c index 2839e14186..f02a85e3a7 100644 --- a/servers/slapd/back-relay/config.c +++ b/servers/slapd/back-relay/config.c @@ -46,6 +46,7 @@ relay_back_db_config( if ( strcasecmp( argv[0], "relay" ) == 0 ) { struct berval dn, ndn, pdn; int rc; + BackendDB *bd; if ( argc < 2 ) { fprintf( stderr, @@ -70,20 +71,22 @@ relay_back_db_config( return 1; } - ri->ri_bd = select_backend( &ndn, 0, 1 ); - if ( ri->ri_bd == NULL ) { + bd = select_backend( &ndn, 0, 1 ); + if ( bd == NULL ) { fprintf( stderr, "%s: line %d: " "cannot find database " "of relay dn \"%s\"\n", fname, lineno, argv[ 1 ] ); return 1; - } else if ( ri->ri_bd == be ) { + } else if ( bd == be ) { fprintf( stderr, "%s: line %d: " "relay dn \"%s\" would call self\n", fname, lineno, pdn.bv_val ); return 1; - } + } + + ri->ri_realsuffix = ndn; if ( overlay_config( be, "rewrite-remap" ) ) { fprintf( stderr, "%s: line %d: unable to install " @@ -93,33 +96,38 @@ relay_back_db_config( return 1; } - if ( argc == 3 ) { +#if 0 + { char *cargv[ 4 ]; - if ( strcmp( argv[2], "massage" ) ) { - fprintf( stderr, "%s: line %d: " - "unknown directive \"%s\" " - "in \"relay [massage]\" line\n", - fname, lineno, argv[2] ); - return 1; - } + cargv[ 0 ] = "overlay"; + cargv[ 1 ] = "rewrite-remap"; + cargv[ 2 ] = NULL; - if ( be->be_suffix[0].bv_val == NULL ) { - fprintf( stderr, "%s: line %d: " - "relay line must come after \"suffix\"\n", - fname, lineno ); - return 1; - } + be->be_config( be, fname, lineno, 2, cargv ); 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 ) ) { + if ( be->be_config( be, fname, lineno, 3, cargv ) ) { + return 1; + } + } + + if ( argc == 3 ) { + if ( strcmp( argv[2], "massage" ) ) { + fprintf( stderr, "%s: line %d: " + "unknown directive \"%s\" " + "in \"relay [massage]\" line\n", + fname, lineno, argv[2] ); return 1; } + + ri->ri_massage = 1; } +#endif /* anything else */ } else { diff --git a/servers/slapd/back-relay/init.c b/servers/slapd/back-relay/init.c index 2ed870a9f7..66631c2e60 100644 --- a/servers/slapd/back-relay/init.c +++ b/servers/slapd/back-relay/init.c @@ -92,6 +92,9 @@ relay_back_db_init( Backend *be ) } ri->ri_bd = NULL; + ri->ri_realsuffix.bv_val = NULL; + ri->ri_realsuffix.bv_len = 0; + ri->ri_massage = 0; be->be_private = (void *)ri; @@ -105,10 +108,20 @@ relay_back_db_open( Backend *be ) assert( ri != NULL ); + if ( ri->ri_realsuffix.bv_val != NULL ) { + ri->ri_bd = select_backend( &ri->ri_realsuffix, 0, 1 ); + assert( ri->ri_bd ); + } + #if 0 - if ( !ri->ri_do_not_massage ) { + if ( ri->ri_massage ) { char *argv[ 4 ]; + if ( be->be_suffix[0].bv_val == NULL ) { + fprintf( stderr, "suffix must be defined to require suffix massage\n" ); + return 1; + } + argv[ 0 ] = "suffixmassage"; argv[ 1 ] = be->be_suffix[0].bv_val; argv[ 2 ] = ri->ri_bd->be_suffix[0].bv_val;