]> git.sur5r.net Git - openldap/commitdiff
only works with explicit overlay instantiation
authorPierangelo Masarati <ando@openldap.org>
Wed, 17 Mar 2004 12:21:40 +0000 (12:21 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 17 Mar 2004 12:21:40 +0000 (12:21 +0000)
servers/slapd/back-relay/back-relay.h
servers/slapd/back-relay/config.c
servers/slapd/back-relay/init.c

index d45c4133795a15c8afed48cfc9710b1fb37f7b4b..d62474ea33b17be9b3b541a718793e7be4d95633 100644 (file)
@@ -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
index 2839e14186358182adcc31a87d35e51aed8472aa..f02a85e3a74d2d44f859e904af1c24e7c3e6e2ad 100644 (file)
@@ -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 <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 {
index 2ed870a9f7d58c12cd3eaaf947230d34bd480871..66631c2e6029e70a461430914abeadfc9379cef7 100644 (file)
@@ -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;