if ( strcasecmp( argv[0], "relay" ) == 0 ) {
struct berval dn, ndn, pdn;
int rc;
+ BackendDB *bd;
if ( argc < 2 ) {
fprintf( stderr,
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 "
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 <dn> [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 <dn> [massage]\" line\n",
+ fname, lineno, argv[2] );
return 1;
}
+
+ ri->ri_massage = 1;
}
+#endif
/* anything else */
} else {
}
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;
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;