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;
168 /* This is not a final result */
169 rs->sr_type = REP_GLUE_RESULT;
175 glue_op_func ( Operation *op, SlapReply *rs )
177 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
178 BackendDB *b0 = op->o_bd;
179 BackendInfo *bi0 = op->o_bd->bd_info;
181 slap_operation_t which = op_bind;
184 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
186 /* If we're on the master backend, let overlay framework handle it */
187 if ( op->o_bd == b0 )
188 return SLAP_CB_CONTINUE;
190 b0->bd_info = on->on_info->oi_orig;
193 case LDAP_REQ_ADD: which = op_add; break;
194 case LDAP_REQ_DELETE: which = op_delete; break;
195 case LDAP_REQ_MODIFY: which = op_modify; break;
196 case LDAP_REQ_MODRDN: which = op_modrdn; break;
197 default: assert( 0 ); break;
200 func = &op->o_bd->bd_info->bi_op_bind;
202 rc = func[which]( op, rs );
207 op->o_bd->bd_info = bi0;
212 glue_response ( Operation *op, SlapReply *rs )
214 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
215 BackendDB *be = op->o_bd;
216 be = glue_back_select (op->o_bd, &op->o_req_ndn);
218 /* If we're on the master backend, let overlay framework handle it.
219 * Otherwise, bail out.
221 return ( op->o_bd == be ) ? SLAP_CB_CONTINUE : SLAP_CB_BYPASS;
225 glue_chk_referrals ( Operation *op, SlapReply *rs )
227 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
228 BackendDB *b0 = op->o_bd;
229 BackendInfo *bi0 = op->o_bd->bd_info;
232 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
233 if ( op->o_bd == b0 )
234 return SLAP_CB_CONTINUE;
236 b0->bd_info = on->on_info->oi_orig;
238 if ( op->o_bd->bd_info->bi_chk_referrals )
239 rc = ( *op->o_bd->bd_info->bi_chk_referrals )( op, rs );
241 rc = SLAP_CB_CONTINUE;
244 op->o_bd->bd_info = bi0;
249 glue_chk_controls ( Operation *op, SlapReply *rs )
251 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
252 BackendDB *b0 = op->o_bd;
253 BackendInfo *bi0 = op->o_bd->bd_info;
254 int rc = SLAP_CB_CONTINUE;
256 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
257 if ( op->o_bd == b0 )
258 return SLAP_CB_CONTINUE;
260 b0->bd_info = on->on_info->oi_orig;
262 /* if the subordinate database has overlays, the bi_chk_controls()
263 * hook is actually over_aux_chk_controls(); in case it actually
264 * wraps a missing hok, we need to mimic the behavior
265 * of the frontend applied to that database */
266 if ( op->o_bd->bd_info->bi_chk_controls ) {
267 rc = ( *op->o_bd->bd_info->bi_chk_controls )( op, rs );
271 if ( rc == SLAP_CB_CONTINUE ) {
272 rc = backend_check_controls( op, rs );
276 op->o_bd->bd_info = bi0;
280 /* ITS#4615 - overlays configured above the glue overlay should be
281 * invoked for the entire glued tree. Overlays configured below the
282 * glue overlay should only be invoked on the master backend.
283 * So, if we're searching on any subordinates, we need to force the
284 * current overlay chain to stop processing, without stopping the
285 * overall callback flow.
288 glue_sub_search( Operation *op, SlapReply *rs, BackendDB *b0,
291 /* Process any overlays on the master backend */
292 if ( op->o_bd == b0 && on->on_next ) {
293 BackendInfo *bi = op->o_bd->bd_info;
294 int rc = SLAP_CB_CONTINUE;
295 for ( on=on->on_next; on; on=on->on_next ) {
296 op->o_bd->bd_info = (BackendInfo *)on;
297 if ( on->on_bi.bi_op_search ) {
298 rc = on->on_bi.bi_op_search( op, rs );
299 if ( rc != SLAP_CB_CONTINUE )
303 op->o_bd->bd_info = bi;
304 if ( rc != SLAP_CB_CONTINUE )
307 return op->o_bd->be_search( op, rs );
311 glue_op_search ( Operation *op, SlapReply *rs )
313 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
314 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
315 BackendDB *b0 = op->o_bd;
316 BackendDB *b1 = NULL, *btmp;
317 BackendInfo *bi0 = op->o_bd->bd_info;
319 long stoptime = 0, starttime;
320 glue_state gs = {NULL, NULL, NULL, 0, 0, 0, 0};
321 slap_callback cb = { NULL, glue_op_response, NULL, NULL };
323 struct berval dn, ndn, *pdn;
327 cb.sc_next = op->o_callback;
329 starttime = op->o_time;
330 stoptime = slap_get_time () + op->ors_tlimit;
332 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
333 b0->bd_info = on->on_info->oi_orig;
335 switch (op->ors_scope) {
336 case LDAP_SCOPE_BASE:
337 if ( op->o_bd == b0 )
338 return SLAP_CB_CONTINUE;
340 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
341 if (op->o_bd && op->o_bd->be_search) {
342 rs->sr_err = op->o_bd->be_search( op, rs );
346 case LDAP_SCOPE_ONELEVEL:
347 case LDAP_SCOPE_SUBTREE:
348 case LDAP_SCOPE_SUBORDINATE: /* FIXME */
349 op->o_callback = &cb;
350 rs->sr_err = gs.err = LDAP_UNWILLING_TO_PERFORM;
351 scope0 = op->ors_scope;
352 tlimit0 = op->ors_tlimit;
358 * Execute in reverse order, most specific first
360 for (i = gi->gi_nodes; i >= 0; i--) {
361 if ( i == gi->gi_nodes ) {
365 btmp = gi->gi_n[i].gn_be;
366 pdn = &gi->gi_n[i].gn_pdn;
368 if (!btmp || !btmp->be_search)
370 if (!dnIsSuffix(&btmp->be_nsuffix[0], &b1->be_nsuffix[0]))
372 if (get_no_subordinate_glue(op) && btmp != b1)
375 if (tlimit0 != SLAP_NO_LIMIT) {
376 op->o_time = slap_get_time();
377 op->ors_tlimit = stoptime - op->o_time;
378 if (op->ors_tlimit <= 0) {
379 rs->sr_err = gs.err = LDAP_TIMELIMIT_EXCEEDED;
392 assert( op->o_bd->be_suffix != NULL );
393 assert( op->o_bd->be_nsuffix != NULL );
395 if (scope0 == LDAP_SCOPE_ONELEVEL &&
398 op->ors_scope = LDAP_SCOPE_BASE;
399 op->o_req_dn = op->o_bd->be_suffix[0];
400 op->o_req_ndn = op->o_bd->be_nsuffix[0];
401 rs->sr_err = op->o_bd->be_search(op, rs);
402 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
403 gs.err = LDAP_SUCCESS;
405 op->ors_scope = LDAP_SCOPE_ONELEVEL;
409 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
410 dn_match(&op->o_bd->be_nsuffix[0], &ndn))
412 rs->sr_err = glue_sub_search( op, rs, b0, on );
414 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
415 dnIsSuffix(&op->o_bd->be_nsuffix[0], &ndn))
417 op->o_req_dn = op->o_bd->be_suffix[0];
418 op->o_req_ndn = op->o_bd->be_nsuffix[0];
419 rs->sr_err = glue_sub_search( op, rs, b0, on );
420 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
421 gs.err = LDAP_SUCCESS;
426 } else if (dnIsSuffix(&ndn, &op->o_bd->be_nsuffix[0])) {
427 rs->sr_err = glue_sub_search( op, rs, b0, on );
433 * Add errors that should result in dropping
436 case LDAP_SIZELIMIT_EXCEEDED:
437 case LDAP_TIMELIMIT_EXCEEDED:
438 case LDAP_ADMINLIMIT_EXCEEDED:
439 case LDAP_NO_SUCH_OBJECT:
440 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
441 case LDAP_X_CANNOT_CHAIN:
442 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
450 op->ors_scope = scope0;
451 op->ors_tlimit = tlimit0;
452 op->o_time = starttime;
458 if ( op->o_abandon ) {
459 rs->sr_err = SLAPD_ABANDON;
461 op->o_callback = cb.sc_next;
463 rs->sr_matched = gs.matched;
464 rs->sr_ref = gs.refs;
465 rs->sr_ctrls = gs.ctrls;
467 send_ldap_result( op, rs );
471 op->o_bd->bd_info = bi0;
475 ber_bvarray_free(gs.refs);
477 for (i = gs.nctrls; --i >= 0; ) {
478 if (!BER_BVISNULL( &gs.ctrls[i]->ldctl_value ))
479 free(gs.ctrls[i]->ldctl_value.bv_val);
487 static BackendDB toolDB;
490 glue_tool_entry_open (
495 slap_overinfo *oi = (slap_overinfo *)b0->bd_info;
497 /* We don't know which backend to talk to yet, so just
498 * remember the mode and move on...
504 toolDB.bd_info = oi->oi_orig;
510 glue_tool_entry_close (
517 if (!glueBack->be_entry_close)
519 rc = glueBack->be_entry_close (glueBack);
524 static slap_overinst *
529 slap_overinfo *oi = (slap_overinfo *)bi;
532 for ( on = oi->oi_list; on; on=on->on_next ) {
533 if ( !strcmp( on->on_bi.bi_type, glue.on_bi.bi_type ))
539 /* This function will only be called in tool mode */
545 slap_overinst *on = glue_tool_inst( bi );
546 glueinfo *gi = on->on_bi.bi_private;
547 static int glueOpened = 0;
548 int i, j, same, bsame = 0, rc = 0;
550 if (glueOpened) return 0;
554 /* If we were invoked in tool mode, open all the underlying backends */
555 if (slapMode & SLAP_TOOL_MODE) {
556 for (i = 0; i<gi->gi_nodes; i++) {
558 /* Same bi_open as our main backend? */
559 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
560 on->on_info->oi_orig->bi_open )
563 /* Loop thru the bd_info's and make sure we only
564 * invoke their bi_open functions once each.
566 for ( j = 0; j<i; j++ ) {
567 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
568 gi->gi_n[j].gn_be->bd_info->bi_open ) {
573 /* OK, it's unique and non-NULL, call it. */
574 if ( !same && gi->gi_n[i].gn_be->bd_info->bi_open )
575 rc = gi->gi_n[i].gn_be->bd_info->bi_open(
576 gi->gi_n[i].gn_be->bd_info );
577 /* Let backend.c take care of the rest of startup */
579 rc = backend_startup_one( gi->gi_n[i].gn_be );
582 if ( !rc && !bsame && on->on_info->oi_orig->bi_open )
583 rc = on->on_info->oi_orig->bi_open( on->on_info->oi_orig );
585 } /* other case is impossible */
589 /* This function will only be called in tool mode */
595 static int glueClosed = 0;
598 if (glueClosed) return 0;
602 if (slapMode & SLAP_TOOL_MODE) {
603 rc = backend_shutdown( NULL );
609 glue_entry_release_rw (
620 b2.bd_info = (BackendInfo *)glue_tool_inst( op->o_bd->bd_info );
621 op->o_bd = glue_back_select (&b2, &e->e_nname);
623 if ( op->o_bd->be_release ) {
624 rc = op->o_bd->be_release( op, e, rw );
627 /* FIXME: mimic be_entry_release_rw
628 * when no be_release() available */
638 glue_tool_entry_first (
642 slap_overinst *on = glue_tool_inst( b0->bd_info );
643 glueinfo *gi = on->on_bi.bi_private;
646 /* If we're starting from scratch, start at the most general */
648 if ( toolDB.be_entry_open && toolDB.be_entry_first ) {
651 for (i = gi->gi_nodes-1; i >= 0; i--) {
652 if (gi->gi_n[i].gn_be->be_entry_open &&
653 gi->gi_n[i].gn_be->be_entry_first) {
654 glueBack = gi->gi_n[i].gn_be;
660 if (!glueBack || !glueBack->be_entry_open || !glueBack->be_entry_first ||
661 glueBack->be_entry_open (glueBack, glueMode) != 0)
664 return glueBack->be_entry_first (glueBack);
668 glue_tool_entry_next (
672 slap_overinst *on = glue_tool_inst( b0->bd_info );
673 glueinfo *gi = on->on_bi.bi_private;
677 if (!glueBack || !glueBack->be_entry_next)
680 rc = glueBack->be_entry_next (glueBack);
682 /* If we ran out of entries in one database, move on to the next */
684 if ( glueBack && glueBack->be_entry_close )
685 glueBack->be_entry_close (glueBack);
686 for (i=0; i<gi->gi_nodes; i++) {
687 if (gi->gi_n[i].gn_be == glueBack)
694 glueBack = gi->gi_n[i-1].gn_be;
695 rc = glue_tool_entry_first (b0);
702 glue_tool_entry_get (
707 if (!glueBack || !glueBack->be_entry_get)
710 return glueBack->be_entry_get (glueBack, id);
714 glue_tool_entry_put (
724 b2.bd_info = (BackendInfo *)glue_tool_inst( b0->bd_info );
725 be = glue_back_select (&b2, &e->e_nname);
726 if ( be == &b2 ) be = &toolDB;
728 if (!be->be_entry_put)
732 if ( be->be_entry_open ) {
733 rc = be->be_entry_open (be, glueMode);
738 } else if (be != glueBack) {
739 /* If this entry belongs in a different branch than the
740 * previous one, close the current database and open the
743 if ( glueBack->be_entry_close ) {
744 glueBack->be_entry_close (glueBack);
746 if ( be->be_entry_open ) {
747 rc = be->be_entry_open (be, glueMode);
754 return be->be_entry_put (be, e, text);
758 glue_tool_entry_reindex (
763 if (!glueBack || !glueBack->be_entry_reindex)
766 return glueBack->be_entry_reindex (glueBack, id);
774 slap_overinst *on = glue_tool_inst( b0->bd_info );
775 glueinfo *gi = on->on_bi.bi_private;
776 BackendInfo *bi = b0->bd_info;
779 /* just sync everyone */
780 for (i = 0; i<gi->gi_nodes; i++)
781 if (gi->gi_n[i].gn_be->be_sync)
782 gi->gi_n[i].gn_be->be_sync (gi->gi_n[i].gn_be);
783 b0->bd_info = on->on_info->oi_orig;
795 slap_overinst *on = (slap_overinst *)be->bd_info;
796 slap_overinfo *oi = on->on_info;
797 BackendInfo *bi = oi->oi_orig;
800 if ( SLAP_GLUE_SUBORDINATE( be )) {
801 Debug( LDAP_DEBUG_ANY, "glue: backend %s is already subordinate, "
802 "cannot have glue overlay!\n",
803 be->be_suffix[0].bv_val, 0, 0 );
807 gi = ch_calloc( 1, sizeof(glueinfo));
808 on->on_bi.bi_private = gi;
809 dnParent( be->be_nsuffix, &gi->gi_pdn );
811 /* Currently the overlay framework doesn't handle these entry points
812 * but we need them....
814 oi->oi_bi.bi_open = glue_open;
815 oi->oi_bi.bi_close = glue_close;
817 oi->oi_bi.bi_entry_release_rw = glue_entry_release_rw;
819 /* Only advertise these if the root DB supports them */
820 if ( bi->bi_tool_entry_open )
821 oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
822 if ( bi->bi_tool_entry_close )
823 oi->oi_bi.bi_tool_entry_close = glue_tool_entry_close;
824 if ( bi->bi_tool_entry_first )
825 oi->oi_bi.bi_tool_entry_first = glue_tool_entry_first;
826 if ( bi->bi_tool_entry_next )
827 oi->oi_bi.bi_tool_entry_next = glue_tool_entry_next;
828 if ( bi->bi_tool_entry_get )
829 oi->oi_bi.bi_tool_entry_get = glue_tool_entry_get;
830 if ( bi->bi_tool_entry_put )
831 oi->oi_bi.bi_tool_entry_put = glue_tool_entry_put;
832 if ( bi->bi_tool_entry_reindex )
833 oi->oi_bi.bi_tool_entry_reindex = glue_tool_entry_reindex;
834 if ( bi->bi_tool_sync )
835 oi->oi_bi.bi_tool_sync = glue_tool_sync;
837 /*FIXME : need to add support */
838 oi->oi_bi.bi_tool_dn2id_get = 0;
839 oi->oi_bi.bi_tool_id2entry_get = 0;
840 oi->oi_bi.bi_tool_entry_modify = 0;
842 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE;
852 slap_overinst *on = (slap_overinst *)be->bd_info;
853 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
856 return SLAP_CB_CONTINUE;
864 slap_overinst *on = (slap_overinst *)be->bd_info;
866 on->on_info->oi_bi.bi_db_close = 0;
871 glue_sub_del( BackendDB *b0 )
876 /* Find the top backend for this subordinate */
878 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
884 if ( SLAP_GLUE_SUBORDINATE( be ))
886 if ( !SLAP_GLUE_INSTANCE( be ))
888 if ( !dnIsSuffix( &b0->be_nsuffix[0], &be->be_nsuffix[0] ))
891 /* OK, got the right backend, find the overlay */
892 oi = (slap_overinfo *)be->bd_info;
893 for ( on=oi->oi_list; on; on=on->on_next ) {
894 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
897 assert( on != NULL );
898 gi = on->on_bi.bi_private;
899 for ( i=0; i < gi->gi_nodes; i++ ) {
900 if ( gi->gi_n[i].gn_be == b0 ) {
903 for (j=i+1; j < gi->gi_nodes; j++)
904 gi->gi_n[j-1] = gi->gi_n[j];
911 rc = LDAP_NO_SUCH_OBJECT;
916 typedef struct glue_Addrec {
917 struct glue_Addrec *ga_next;
921 /* List of added subordinates */
922 static glue_Addrec *ga_list;
924 /* Attach all the subordinate backends to their superior */
928 glue_Addrec *ga, *gnext = NULL;
931 /* For all the subordinate backends */
932 for ( ga=ga_list; ga != NULL; ga = gnext ) {
937 /* Find the top backend for this subordinate */
939 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
944 if ( SLAP_GLUE_SUBORDINATE( be ))
946 if ( !dnIsSuffix( &ga->ga_be->be_nsuffix[0], &be->be_nsuffix[0] ))
949 /* If it's not already configured, set up the overlay */
950 if ( !SLAP_GLUE_INSTANCE( be )) {
951 rc = overlay_config( be, glue.on_bi.bi_type );
955 /* Find the overlay instance */
956 oi = (slap_overinfo *)be->bd_info;
957 for ( on=oi->oi_list; on; on=on->on_next ) {
958 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
961 assert( on != NULL );
962 gi = on->on_bi.bi_private;
963 gi = (glueinfo *)ch_realloc( gi, sizeof(glueinfo) +
964 gi->gi_nodes * sizeof(gluenode));
965 gi->gi_n[gi->gi_nodes].gn_be = ga->ga_be;
966 dnParent( &ga->ga_be->be_nsuffix[0],
967 &gi->gi_n[gi->gi_nodes].gn_pdn );
969 on->on_bi.bi_private = gi;
973 Debug( LDAP_DEBUG_ANY, "glue: no superior found for sub %s!\n",
974 ga->ga_be->be_suffix[0].bv_val, 0, 0 );
975 rc = LDAP_NO_SUCH_OBJECT;
987 glue_sub_add( BackendDB *be, int advert, int online )
992 if ( overlay_is_inst( be, "glue" )) {
993 Debug( LDAP_DEBUG_ANY, "glue: backend %s already has glue overlay, "
994 "cannot be a subordinate!\n",
995 be->be_suffix[0].bv_val, 0, 0 );
998 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
1000 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_ADVERTISE;
1002 ga = ch_malloc( sizeof( glue_Addrec ));
1003 ga->ga_next = ga_list;
1008 rc = glue_sub_attach();
1016 glue.on_bi.bi_type = "glue";
1018 glue.on_bi.bi_db_init = glue_db_init;
1019 glue.on_bi.bi_db_close = glue_db_close;
1020 glue.on_bi.bi_db_destroy = glue_db_destroy;
1022 glue.on_bi.bi_op_search = glue_op_search;
1023 glue.on_bi.bi_op_modify = glue_op_func;
1024 glue.on_bi.bi_op_modrdn = glue_op_func;
1025 glue.on_bi.bi_op_add = glue_op_func;
1026 glue.on_bi.bi_op_delete = glue_op_func;
1028 glue.on_bi.bi_chk_referrals = glue_chk_referrals;
1029 glue.on_bi.bi_chk_controls = glue_chk_controls;
1030 glue.on_response = glue_response;
1032 return overlay_register( &glue );