1 /* backglue.c - backend glue */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2006 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
18 * Functions to glue a bunch of other backends into a single tree.
19 * All of the glued backends must share a common suffix. E.g., you
20 * can glue o=foo and ou=bar,o=foo but you can't glue o=foo and o=bar.
22 * The purpose of these functions is to allow you to split a single database
23 * into pieces (for load balancing purposes, whatever) but still be able
24 * to treat it as a single database after it's been split. As such, each
25 * of the glued backends should have identical rootdn.
33 #include <ac/string.h>
34 #include <ac/socket.h>
39 typedef struct gluenode {
44 typedef struct glueinfo {
50 static slap_overinst glue;
53 static BackendDB *glueBack;
55 static slap_response glue_op_response;
57 /* Just like select_backend, but only for our backends */
64 slap_overinst *on = (slap_overinst *)be->bd_info;
65 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
68 for (i = gi->gi_nodes-1; i >= 0; i--) {
69 assert( gi->gi_n[i].gn_be->be_nsuffix != NULL );
71 if (dnIsSuffix(dn, &gi->gi_n[i].gn_be->be_nsuffix[0])) {
72 return gi->gi_n[i].gn_be;
75 be->bd_info = on->on_info->oi_orig;
80 typedef struct glue_state {
91 glue_op_response ( Operation *op, SlapReply *rs )
93 glue_state *gs = op->o_callback->sc_private;
98 case REP_INTERMEDIATE:
99 return SLAP_CB_CONTINUE;
102 if (rs->sr_err == LDAP_SUCCESS ||
103 rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ||
104 rs->sr_err == LDAP_TIMELIMIT_EXCEEDED ||
105 rs->sr_err == LDAP_ADMINLIMIT_EXCEEDED ||
106 rs->sr_err == LDAP_NO_SUCH_OBJECT ||
107 gs->err != LDAP_SUCCESS)
108 gs->err = rs->sr_err;
109 if (gs->err == LDAP_SUCCESS && gs->matched) {
110 ch_free (gs->matched);
114 if (gs->err != LDAP_SUCCESS && rs->sr_matched) {
116 len = strlen (rs->sr_matched);
117 if (len > gs->matchlen) {
119 ch_free (gs->matched);
120 gs->matched = ch_strdup (rs->sr_matched);
128 for (i=0; rs->sr_ref[i].bv_val; i++);
132 new = ch_malloc ((i+1)*sizeof(struct berval));
134 new = ch_realloc(gs->refs,
135 (j+i+1)*sizeof(struct berval));
137 for (k=0; k<i; j++,k++) {
138 ber_dupbv( &new[j], &rs->sr_ref[k] );
140 new[j].bv_val = NULL;
146 LDAPControl **newctrls;
148 for (i=0; rs->sr_ctrls[i]; i++);
152 newctrls = ch_malloc((i+1)*sizeof(LDAPControl *));
154 newctrls = ch_realloc(gs->ctrls,
155 (j+i+1)*sizeof(LDAPControl *));
157 for (k=0; k<i; j++,k++) {
158 newctrls[j] = ch_malloc(sizeof(LDAPControl));
159 *newctrls[j] = *rs->sr_ctrls[k];
160 if ( !BER_BVISNULL( &rs->sr_ctrls[k]->ldctl_value ))
161 ber_dupbv( &newctrls[j]->ldctl_value,
162 &rs->sr_ctrls[k]->ldctl_value );
166 gs->ctrls = newctrls;
173 glue_op_func ( Operation *op, SlapReply *rs )
175 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
176 BackendDB *b0 = op->o_bd;
177 BackendInfo *bi0 = op->o_bd->bd_info;
179 slap_operation_t which = op_bind;
182 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
184 /* If we're on the master backend, let overlay framework handle it */
185 if ( op->o_bd == b0 )
186 return SLAP_CB_CONTINUE;
188 b0->bd_info = on->on_info->oi_orig;
191 case LDAP_REQ_ADD: which = op_add; break;
192 case LDAP_REQ_DELETE: which = op_delete; break;
193 case LDAP_REQ_MODIFY: which = op_modify; break;
194 case LDAP_REQ_MODRDN: which = op_modrdn; break;
195 default: assert( 0 ); break;
198 func = &op->o_bd->bd_info->bi_op_bind;
200 rc = func[which]( op, rs );
205 op->o_bd->bd_info = bi0;
210 glue_response ( Operation *op, SlapReply *rs )
212 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
213 BackendDB *be = op->o_bd;
214 be = glue_back_select (op->o_bd, &op->o_req_ndn);
216 /* If we're on the master backend, let overlay framework handle it.
217 * Otherwise, bail out.
219 return ( op->o_bd == be ) ? SLAP_CB_CONTINUE : SLAP_CB_BYPASS;
223 glue_chk_referrals ( Operation *op, SlapReply *rs )
225 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
226 BackendDB *b0 = op->o_bd;
227 BackendInfo *bi0 = op->o_bd->bd_info;
230 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
231 if ( op->o_bd == b0 )
232 return SLAP_CB_CONTINUE;
234 b0->bd_info = on->on_info->oi_orig;
236 if ( op->o_bd->bd_info->bi_chk_referrals )
237 rc = ( *op->o_bd->bd_info->bi_chk_referrals )( op, rs );
239 rc = SLAP_CB_CONTINUE;
242 op->o_bd->bd_info = bi0;
247 glue_chk_controls ( Operation *op, SlapReply *rs )
249 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
250 BackendDB *b0 = op->o_bd;
251 BackendInfo *bi0 = op->o_bd->bd_info;
252 int rc = SLAP_CB_CONTINUE;
254 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
255 if ( op->o_bd == b0 )
256 return SLAP_CB_CONTINUE;
258 b0->bd_info = on->on_info->oi_orig;
260 /* if the subordinate database has overlays, the bi_chk_controls()
261 * hook is actually over_aux_chk_controls(); in case it actually
262 * wraps a missing hok, we need to mimic the behavior
263 * of the frontend applied to that database */
264 if ( op->o_bd->bd_info->bi_chk_controls ) {
265 rc = ( *op->o_bd->bd_info->bi_chk_controls )( op, rs );
269 if ( rc == SLAP_CB_CONTINUE ) {
270 rc = backend_check_controls( op, rs );
274 op->o_bd->bd_info = bi0;
278 /* ITS#4615 - overlays configured above the glue overlay should be
279 * invoked for the entire glued tree. Overlays configured below the
280 * glue overlay should only be invoked on the master backend.
281 * So, if we're searching on any subordinates, we need to force the
282 * current overlay chain to stop processing, without stopping the
283 * overall callback flow.
286 glue_sub_search( Operation *op, SlapReply *rs, BackendDB *b0,
289 /* Process any overlays on the master backend */
290 if ( op->o_bd == b0 && on->on_next ) {
291 BackendInfo *bi = op->o_bd->bd_info;
292 int rc = SLAP_CB_CONTINUE;
293 for ( on=on->on_next; on; on=on->on_next ) {
294 op->o_bd->bd_info = (BackendInfo *)on;
295 if ( on->on_bi.bi_op_search ) {
296 rc = on->on_bi.bi_op_search( op, rs );
297 if ( rc != SLAP_CB_CONTINUE )
301 op->o_bd->bd_info = bi;
302 if ( rc != SLAP_CB_CONTINUE )
305 return op->o_bd->be_search( op, rs );
309 glue_op_search ( Operation *op, SlapReply *rs )
311 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
312 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
313 BackendDB *b0 = op->o_bd;
314 BackendDB *b1 = NULL, *btmp;
315 BackendInfo *bi0 = op->o_bd->bd_info;
317 long stoptime = 0, starttime;
318 glue_state gs = {NULL, NULL, NULL, 0, 0, 0, 0};
319 slap_callback cb = { NULL, glue_op_response, NULL, NULL };
321 struct berval dn, ndn, *pdn;
325 cb.sc_next = op->o_callback;
327 starttime = op->o_time;
328 stoptime = slap_get_time () + op->ors_tlimit;
330 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
331 b0->bd_info = on->on_info->oi_orig;
333 switch (op->ors_scope) {
334 case LDAP_SCOPE_BASE:
335 if ( op->o_bd == b0 )
336 return SLAP_CB_CONTINUE;
338 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
339 if (op->o_bd && op->o_bd->be_search) {
340 rs->sr_err = op->o_bd->be_search( op, rs );
344 case LDAP_SCOPE_ONELEVEL:
345 case LDAP_SCOPE_SUBTREE:
346 case LDAP_SCOPE_SUBORDINATE: /* FIXME */
347 op->o_callback = &cb;
348 rs->sr_err = gs.err = LDAP_UNWILLING_TO_PERFORM;
349 scope0 = op->ors_scope;
350 tlimit0 = op->ors_tlimit;
356 * Execute in reverse order, most specific first
358 for (i = gi->gi_nodes; i >= 0; i--) {
359 if ( i == gi->gi_nodes ) {
363 btmp = gi->gi_n[i].gn_be;
364 pdn = &gi->gi_n[i].gn_pdn;
366 if (!btmp || !btmp->be_search)
368 if (!dnIsSuffix(&btmp->be_nsuffix[0], &b1->be_nsuffix[0]))
370 if (get_no_subordinate_glue(op) && btmp != b1)
373 if (tlimit0 != SLAP_NO_LIMIT) {
374 op->o_time = slap_get_time();
375 op->ors_tlimit = stoptime - op->o_time;
376 if (op->ors_tlimit <= 0) {
377 rs->sr_err = gs.err = LDAP_TIMELIMIT_EXCEEDED;
390 assert( op->o_bd->be_suffix != NULL );
391 assert( op->o_bd->be_nsuffix != NULL );
393 if (scope0 == LDAP_SCOPE_ONELEVEL &&
396 op->ors_scope = LDAP_SCOPE_BASE;
397 op->o_req_dn = op->o_bd->be_suffix[0];
398 op->o_req_ndn = op->o_bd->be_nsuffix[0];
399 rs->sr_err = op->o_bd->be_search(op, rs);
400 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
401 gs.err = LDAP_SUCCESS;
403 op->ors_scope = LDAP_SCOPE_ONELEVEL;
407 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
408 dn_match(&op->o_bd->be_nsuffix[0], &ndn))
410 rs->sr_err = glue_sub_search( op, rs, b0, on );
412 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
413 dnIsSuffix(&op->o_bd->be_nsuffix[0], &ndn))
415 op->o_req_dn = op->o_bd->be_suffix[0];
416 op->o_req_ndn = op->o_bd->be_nsuffix[0];
417 rs->sr_err = glue_sub_search( op, rs, b0, on );
418 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
419 gs.err = LDAP_SUCCESS;
424 } else if (dnIsSuffix(&ndn, &op->o_bd->be_nsuffix[0])) {
425 rs->sr_err = glue_sub_search( op, rs, b0, on );
431 * Add errors that should result in dropping
434 case LDAP_SIZELIMIT_EXCEEDED:
435 case LDAP_TIMELIMIT_EXCEEDED:
436 case LDAP_ADMINLIMIT_EXCEEDED:
437 case LDAP_NO_SUCH_OBJECT:
438 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
439 case LDAP_X_CANNOT_CHAIN:
440 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
448 op->ors_scope = scope0;
449 op->ors_tlimit = tlimit0;
450 op->o_time = starttime;
456 if ( op->o_abandon ) {
457 rs->sr_err = SLAPD_ABANDON;
459 op->o_callback = cb.sc_next;
461 rs->sr_matched = gs.matched;
462 rs->sr_ref = gs.refs;
463 rs->sr_ctrls = gs.ctrls;
465 send_ldap_result( op, rs );
469 op->o_bd->bd_info = bi0;
473 ber_bvarray_free(gs.refs);
475 for (i = gs.nctrls; --i >= 0; ) {
476 if (!BER_BVISNULL( &gs.ctrls[i]->ldctl_value ))
477 free(gs.ctrls[i]->ldctl_value.bv_val);
485 static BackendDB toolDB;
488 glue_tool_entry_open (
493 slap_overinfo *oi = (slap_overinfo *)b0->bd_info;
495 /* We don't know which backend to talk to yet, so just
496 * remember the mode and move on...
502 toolDB.bd_info = oi->oi_orig;
508 glue_tool_entry_close (
515 if (!glueBack->be_entry_close)
517 rc = glueBack->be_entry_close (glueBack);
522 static slap_overinst *
527 slap_overinfo *oi = (slap_overinfo *)bi;
530 for ( on = oi->oi_list; on; on=on->on_next ) {
531 if ( !strcmp( on->on_bi.bi_type, glue.on_bi.bi_type ))
537 /* This function will only be called in tool mode */
543 slap_overinst *on = glue_tool_inst( bi );
544 glueinfo *gi = on->on_bi.bi_private;
545 static int glueOpened = 0;
546 int i, j, same, bsame = 0, rc = 0;
548 if (glueOpened) return 0;
552 /* If we were invoked in tool mode, open all the underlying backends */
553 if (slapMode & SLAP_TOOL_MODE) {
554 for (i = 0; i<gi->gi_nodes; i++) {
556 /* Same bi_open as our main backend? */
557 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
558 on->on_info->oi_orig->bi_open )
561 /* Loop thru the bd_info's and make sure we only
562 * invoke their bi_open functions once each.
564 for ( j = 0; j<i; j++ ) {
565 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
566 gi->gi_n[j].gn_be->bd_info->bi_open ) {
571 /* OK, it's unique and non-NULL, call it. */
572 if ( !same && gi->gi_n[i].gn_be->bd_info->bi_open )
573 rc = gi->gi_n[i].gn_be->bd_info->bi_open(
574 gi->gi_n[i].gn_be->bd_info );
575 /* Let backend.c take care of the rest of startup */
577 rc = backend_startup_one( gi->gi_n[i].gn_be );
580 if ( !rc && !bsame && on->on_info->oi_orig->bi_open )
581 rc = on->on_info->oi_orig->bi_open( on->on_info->oi_orig );
583 } /* other case is impossible */
587 /* This function will only be called in tool mode */
593 static int glueClosed = 0;
596 if (glueClosed) return 0;
600 if (slapMode & SLAP_TOOL_MODE) {
601 rc = backend_shutdown( NULL );
607 glue_entry_release_rw (
618 b2.bd_info = (BackendInfo *)glue_tool_inst( op->o_bd->bd_info );
619 op->o_bd = glue_back_select (&b2, &e->e_nname);
621 if ( op->o_bd->be_release ) {
622 rc = op->o_bd->be_release( op, e, rw );
625 /* FIXME: mimic be_entry_release_rw
626 * when no be_release() available */
636 glue_tool_entry_first (
640 slap_overinst *on = glue_tool_inst( b0->bd_info );
641 glueinfo *gi = on->on_bi.bi_private;
644 /* If we're starting from scratch, start at the most general */
646 if ( toolDB.be_entry_open && toolDB.be_entry_first ) {
649 for (i = gi->gi_nodes-1; i >= 0; i--) {
650 if (gi->gi_n[i].gn_be->be_entry_open &&
651 gi->gi_n[i].gn_be->be_entry_first) {
652 glueBack = gi->gi_n[i].gn_be;
658 if (!glueBack || !glueBack->be_entry_open || !glueBack->be_entry_first ||
659 glueBack->be_entry_open (glueBack, glueMode) != 0)
662 return glueBack->be_entry_first (glueBack);
666 glue_tool_entry_next (
670 slap_overinst *on = glue_tool_inst( b0->bd_info );
671 glueinfo *gi = on->on_bi.bi_private;
675 if (!glueBack || !glueBack->be_entry_next)
678 rc = glueBack->be_entry_next (glueBack);
680 /* If we ran out of entries in one database, move on to the next */
682 if ( glueBack && glueBack->be_entry_close )
683 glueBack->be_entry_close (glueBack);
684 for (i=0; i<gi->gi_nodes; i++) {
685 if (gi->gi_n[i].gn_be == glueBack)
692 glueBack = gi->gi_n[i-1].gn_be;
693 rc = glue_tool_entry_first (b0);
700 glue_tool_entry_get (
705 if (!glueBack || !glueBack->be_entry_get)
708 return glueBack->be_entry_get (glueBack, id);
712 glue_tool_entry_put (
722 b2.bd_info = (BackendInfo *)glue_tool_inst( b0->bd_info );
723 be = glue_back_select (&b2, &e->e_nname);
724 if ( be == &b2 ) be = &toolDB;
726 if (!be->be_entry_put)
730 if ( be->be_entry_open ) {
731 rc = be->be_entry_open (be, glueMode);
736 } else if (be != glueBack) {
737 /* If this entry belongs in a different branch than the
738 * previous one, close the current database and open the
741 if ( glueBack->be_entry_close ) {
742 glueBack->be_entry_close (glueBack);
744 if ( be->be_entry_open ) {
745 rc = be->be_entry_open (be, glueMode);
752 return be->be_entry_put (be, e, text);
756 glue_tool_entry_reindex (
761 if (!glueBack || !glueBack->be_entry_reindex)
764 return glueBack->be_entry_reindex (glueBack, id);
772 slap_overinst *on = glue_tool_inst( b0->bd_info );
773 glueinfo *gi = on->on_bi.bi_private;
774 BackendInfo *bi = b0->bd_info;
777 /* just sync everyone */
778 for (i = 0; i<gi->gi_nodes; i++)
779 if (gi->gi_n[i].gn_be->be_sync)
780 gi->gi_n[i].gn_be->be_sync (gi->gi_n[i].gn_be);
781 b0->bd_info = on->on_info->oi_orig;
793 slap_overinst *on = (slap_overinst *)be->bd_info;
794 slap_overinfo *oi = on->on_info;
795 BackendInfo *bi = oi->oi_orig;
798 if ( SLAP_GLUE_SUBORDINATE( be )) {
799 Debug( LDAP_DEBUG_ANY, "glue: backend %s is already subordinate, "
800 "cannot have glue overlay!\n",
801 be->be_suffix[0].bv_val, 0, 0 );
805 gi = ch_calloc( 1, sizeof(glueinfo));
806 on->on_bi.bi_private = gi;
807 dnParent( be->be_nsuffix, &gi->gi_pdn );
809 /* Currently the overlay framework doesn't handle these entry points
810 * but we need them....
812 oi->oi_bi.bi_open = glue_open;
813 oi->oi_bi.bi_close = glue_close;
815 oi->oi_bi.bi_entry_release_rw = glue_entry_release_rw;
817 /* Only advertise these if the root DB supports them */
818 if ( bi->bi_tool_entry_open )
819 oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
820 if ( bi->bi_tool_entry_close )
821 oi->oi_bi.bi_tool_entry_close = glue_tool_entry_close;
822 if ( bi->bi_tool_entry_first )
823 oi->oi_bi.bi_tool_entry_first = glue_tool_entry_first;
824 if ( bi->bi_tool_entry_next )
825 oi->oi_bi.bi_tool_entry_next = glue_tool_entry_next;
826 if ( bi->bi_tool_entry_get )
827 oi->oi_bi.bi_tool_entry_get = glue_tool_entry_get;
828 if ( bi->bi_tool_entry_put )
829 oi->oi_bi.bi_tool_entry_put = glue_tool_entry_put;
830 if ( bi->bi_tool_entry_reindex )
831 oi->oi_bi.bi_tool_entry_reindex = glue_tool_entry_reindex;
832 if ( bi->bi_tool_sync )
833 oi->oi_bi.bi_tool_sync = glue_tool_sync;
835 /*FIXME : need to add support */
836 oi->oi_bi.bi_tool_dn2id_get = 0;
837 oi->oi_bi.bi_tool_id2entry_get = 0;
838 oi->oi_bi.bi_tool_entry_modify = 0;
840 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE;
850 slap_overinst *on = (slap_overinst *)be->bd_info;
851 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
854 return SLAP_CB_CONTINUE;
862 slap_overinst *on = (slap_overinst *)be->bd_info;
864 on->on_info->oi_bi.bi_db_close = 0;
869 glue_sub_del( BackendDB *b0 )
874 /* Find the top backend for this subordinate */
876 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
882 if ( SLAP_GLUE_SUBORDINATE( be ))
884 if ( !SLAP_GLUE_INSTANCE( be ))
886 if ( !dnIsSuffix( &b0->be_nsuffix[0], &be->be_nsuffix[0] ))
889 /* OK, got the right backend, find the overlay */
890 oi = (slap_overinfo *)be->bd_info;
891 for ( on=oi->oi_list; on; on=on->on_next ) {
892 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
895 assert( on != NULL );
896 gi = on->on_bi.bi_private;
897 for ( i=0; i < gi->gi_nodes; i++ ) {
898 if ( gi->gi_n[i].gn_be == b0 ) {
901 for (j=i+1; j < gi->gi_nodes; j++)
902 gi->gi_n[j-1] = gi->gi_n[j];
909 rc = LDAP_NO_SUCH_OBJECT;
914 typedef struct glue_Addrec {
915 struct glue_Addrec *ga_next;
919 /* List of added subordinates */
920 static glue_Addrec *ga_list;
922 /* Attach all the subordinate backends to their superior */
926 glue_Addrec *ga, *gnext = NULL;
929 /* For all the subordinate backends */
930 for ( ga=ga_list; ga != NULL; ga = gnext ) {
935 /* Find the top backend for this subordinate */
937 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
942 if ( SLAP_GLUE_SUBORDINATE( be ))
944 if ( !dnIsSuffix( &ga->ga_be->be_nsuffix[0], &be->be_nsuffix[0] ))
947 /* If it's not already configured, set up the overlay */
948 if ( !SLAP_GLUE_INSTANCE( be )) {
949 rc = overlay_config( be, glue.on_bi.bi_type );
953 /* Find the overlay instance */
954 oi = (slap_overinfo *)be->bd_info;
955 for ( on=oi->oi_list; on; on=on->on_next ) {
956 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
959 assert( on != NULL );
960 gi = on->on_bi.bi_private;
961 gi = (glueinfo *)ch_realloc( gi, sizeof(glueinfo) +
962 gi->gi_nodes * sizeof(gluenode));
963 gi->gi_n[gi->gi_nodes].gn_be = ga->ga_be;
964 dnParent( &ga->ga_be->be_nsuffix[0],
965 &gi->gi_n[gi->gi_nodes].gn_pdn );
967 on->on_bi.bi_private = gi;
971 Debug( LDAP_DEBUG_ANY, "glue: no superior found for sub %s!\n",
972 ga->ga_be->be_suffix[0].bv_val, 0, 0 );
973 rc = LDAP_NO_SUCH_OBJECT;
985 glue_sub_add( BackendDB *be, int advert, int online )
990 if ( overlay_is_inst( be, "glue" )) {
991 Debug( LDAP_DEBUG_ANY, "glue: backend %s already has glue overlay, "
992 "cannot be a subordinate!\n",
993 be->be_suffix[0].bv_val, 0, 0 );
996 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
998 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_ADVERTISE;
1000 ga = ch_malloc( sizeof( glue_Addrec ));
1001 ga->ga_next = ga_list;
1006 rc = glue_sub_attach();
1014 glue.on_bi.bi_type = "glue";
1016 glue.on_bi.bi_db_init = glue_db_init;
1017 glue.on_bi.bi_db_close = glue_db_close;
1018 glue.on_bi.bi_db_destroy = glue_db_destroy;
1020 glue.on_bi.bi_op_search = glue_op_search;
1021 glue.on_bi.bi_op_modify = glue_op_func;
1022 glue.on_bi.bi_op_modrdn = glue_op_func;
1023 glue.on_bi.bi_op_add = glue_op_func;
1024 glue.on_bi.bi_op_delete = glue_op_func;
1026 glue.on_bi.bi_chk_referrals = glue_chk_referrals;
1027 glue.on_bi.bi_chk_controls = glue_chk_controls;
1028 glue.on_response = glue_response;
1030 return overlay_register( &glue );