return rc;
 }
 
-/* Detach all glued subordinates from the superior. Only
- * called in tool mode.
- */
-void
-glue_sub_detach( BackendDB *be )
-{
-       slap_overinfo *oi = (slap_overinfo *)be->bd_info;
-       slap_overinst *on, **oprev;
-
-       /* If glue is the only overlay, just remove the overlay framework */
-       if ( oi->oi_list->on_bi.bi_type == glue.on_bi.bi_type &&
-               oi->oi_list->on_next == NULL ) {
-               /* We don't do any cleanup. Doesn't matter in tool mode. */
-               be->bd_info = oi->oi_orig;
-               return;
-       }
-
-       /* There are multiple overlays, just drop ours from the list */
-       for ( on=oi->oi_list, oprev = &oi->oi_list; on; on=on->on_next ) {
-               if ( on->on_bi.bi_type == glue.on_bi.bi_type ) {
-                       *oprev = on->on_next;
-                       break;
-               }
-               oprev = &on->on_next;
-
-               /* Undo the glue_db_init() changes in oi */
-               oi->oi_bi.bi_open = oi->oi_orig->bi_open;
-               oi->oi_bi.bi_close = oi->oi_orig->bi_close;
-
-               oi->oi_bi.bi_entry_release_rw = oi->oi_orig->bi_entry_release_rw;
-
-               oi->oi_bi.bi_tool_entry_open = oi->oi_orig->bi_tool_entry_open;
-               oi->oi_bi.bi_tool_entry_close = oi->oi_orig->bi_tool_entry_close;
-               oi->oi_bi.bi_tool_entry_first = oi->oi_orig->bi_tool_entry_first;
-               oi->oi_bi.bi_tool_entry_get = oi->oi_orig->bi_tool_entry_get;
-               oi->oi_bi.bi_tool_entry_put = oi->oi_orig->bi_tool_entry_put;
-               oi->oi_bi.bi_tool_entry_reindex = oi->oi_orig->bi_tool_entry_reindex;
-               oi->oi_bi.bi_tool_sync = oi->oi_orig->bi_tool_sync;
-               oi->oi_bi.bi_tool_dn2id_get = oi->oi_orig->bi_tool_dn2id_get;
-               oi->oi_bi.bi_tool_id2entry_get = oi->oi_orig->bi_tool_id2entry_get;
-               oi->oi_bi.bi_tool_entry_modify = oi->oi_orig->bi_tool_entry_modify;
-       }
-       return;
-}
-
 int
 glue_sub_init()
 {
 
 LDAP_SLAPD_F (int) glue_sub_attach( void );
 LDAP_SLAPD_F (int) glue_sub_add( BackendDB *be, int advert, int online );
 LDAP_SLAPD_F (int) glue_sub_del( BackendDB *be );
-LDAP_SLAPD_F (void) glue_sub_detach( BackendDB *be );
 
 /*
  * backover.c
 
                break;
 
        case SLAPADD:
-               options = " [-c]\n\t[-n databasenumber | -b suffix]\n"
+               options = " [-c]\n\t[-g] [-n databasenumber | -b suffix]\n"
                        "\t[-l ldiffile] [-q] [-u] [-w]\n";
                break;
 
                break;
 
        case SLAPCAT:
-               options = " [-c]\n\t[-n databasenumber | -b suffix]"
+               options = " [-c]\n\t[-g] [-n databasenumber | -b suffix]"
                        " [-l ldiffile] [-a filter]\n";
                break;
 
                break;
 
        case SLAPINDEX:
-               options = " [-c]\n\t[-n databasenumber | -b suffix] [-q]\n";
+               options = " [-c]\n\t[-g] [-n databasenumber | -b suffix] [-q]\n";
                break;
 
        case SLAPTEST:
        int rc, i, dbnum;
        int mode = SLAP_TOOL_MODE;
        int truncatemode = 0;
+       int use_glue = 1;
 
 #ifdef CSRIMALLOC
        leakfilename = malloc( strlen( progname ) + STRLENOF( ".leak" ) + 1 );
 
        switch( tool ) {
        case SLAPADD:
-               options = "b:cd:f:F:l:n:qtuvw";
+               options = "b:cd:f:F:gl:n:qtuvw";
                break;
 
        case SLAPCAT:
-               options = "a:b:cd:f:F:l:n:s:v";
+               options = "a:b:cd:f:F:gl:n:s:v";
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
                break;
 
                break;
 
        case SLAPINDEX:
-               options = "b:cd:f:F:n:qv";
+               options = "b:cd:f:F:gn:qv";
                mode |= SLAP_TOOL_READMAIN;
                break;
 
                        confdir = strdup( optarg );
                        break;
 
+               case 'g':       /* disable subordinate glue */
+                       use_glue = 0;
+                       break;
+
                case 'l':       /* LDIF file */
                        ldiffile = strdup( optarg );
                        break;
                break;
        }
 
-       rc = glue_sub_attach();
+       if ( use_glue ) {
+               rc = glue_sub_attach();
 
-       if ( rc != 0 ) {
-               fprintf( stderr, "%s: subordinate configuration error\n", progname );
-               exit( EXIT_FAILURE );
+               if ( rc != 0 ) {
+                       fprintf( stderr,
+                               "%s: subordinate configuration error\n", progname );
+                       exit( EXIT_FAILURE );
+               }
        }
 
        rc = slap_schema_check();
                        if ( dbnum == 0 ) break;
                        dbnum--;
                }
-               /* If a glued database is specified by number, just operate
-                * on the single database.
-                */
-               if ( SLAP_GLUE_INSTANCE( be ) ) {
-                       glue_sub_detach( be );
-               }
        }
 
 startup:;