1 /* backglue.c - backend glue */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2007 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_cleanup( Operation *op, SlapReply *rs )
93 /* This is not a final result */
94 if (rs->sr_type == REP_RESULT )
95 rs->sr_type = REP_GLUE_RESULT;
96 return SLAP_CB_CONTINUE;
100 glue_op_response ( Operation *op, SlapReply *rs )
102 glue_state *gs = op->o_callback->sc_private;
104 switch(rs->sr_type) {
107 case REP_INTERMEDIATE:
108 return SLAP_CB_CONTINUE;
111 if (rs->sr_err == LDAP_SUCCESS ||
112 rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ||
113 rs->sr_err == LDAP_TIMELIMIT_EXCEEDED ||
114 rs->sr_err == LDAP_ADMINLIMIT_EXCEEDED ||
115 rs->sr_err == LDAP_NO_SUCH_OBJECT ||
116 gs->err != LDAP_SUCCESS)
117 gs->err = rs->sr_err;
118 if (gs->err == LDAP_SUCCESS && gs->matched) {
119 ch_free (gs->matched);
123 if (gs->err != LDAP_SUCCESS && rs->sr_matched) {
125 len = strlen (rs->sr_matched);
126 if (len > gs->matchlen) {
128 ch_free (gs->matched);
129 gs->matched = ch_strdup (rs->sr_matched);
137 for (i=0; rs->sr_ref[i].bv_val; i++);
141 new = ch_malloc ((i+1)*sizeof(struct berval));
143 new = ch_realloc(gs->refs,
144 (j+i+1)*sizeof(struct berval));
146 for (k=0; k<i; j++,k++) {
147 ber_dupbv( &new[j], &rs->sr_ref[k] );
149 new[j].bv_val = NULL;
155 LDAPControl **newctrls;
157 for (i=0; rs->sr_ctrls[i]; i++);
161 newctrls = ch_malloc((i+1)*sizeof(LDAPControl *));
163 newctrls = ch_realloc(gs->ctrls,
164 (j+i+1)*sizeof(LDAPControl *));
166 for (k=0; k<i; j++,k++) {
167 newctrls[j] = ch_malloc(sizeof(LDAPControl));
168 *newctrls[j] = *rs->sr_ctrls[k];
169 if ( !BER_BVISNULL( &rs->sr_ctrls[k]->ldctl_value ))
170 ber_dupbv( &newctrls[j]->ldctl_value,
171 &rs->sr_ctrls[k]->ldctl_value );
175 gs->ctrls = newctrls;
182 glue_op_func ( Operation *op, SlapReply *rs )
184 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
185 BackendDB *b0 = op->o_bd;
186 BackendInfo *bi0 = op->o_bd->bd_info;
188 slap_operation_t which = op_bind;
191 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
193 /* If we're on the master backend, let overlay framework handle it */
194 if ( op->o_bd == b0 )
195 return SLAP_CB_CONTINUE;
197 b0->bd_info = on->on_info->oi_orig;
200 case LDAP_REQ_ADD: which = op_add; break;
201 case LDAP_REQ_DELETE: which = op_delete; break;
202 case LDAP_REQ_MODIFY: which = op_modify; break;
203 case LDAP_REQ_MODRDN: which = op_modrdn; break;
204 case LDAP_REQ_EXTENDED: which = op_extended; break;
205 default: assert( 0 ); break;
208 func = &op->o_bd->bd_info->bi_op_bind;
210 rc = func[which]( op, rs );
215 op->o_bd->bd_info = bi0;
220 glue_response ( Operation *op, SlapReply *rs )
222 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
223 BackendDB *be = op->o_bd;
224 be = glue_back_select (op->o_bd, &op->o_req_ndn);
226 /* If we're on the master backend, let overlay framework handle it.
227 * Otherwise, bail out.
229 return ( op->o_bd == be ) ? SLAP_CB_CONTINUE : SLAP_CB_BYPASS;
233 glue_chk_referrals ( Operation *op, SlapReply *rs )
235 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
236 BackendDB *b0 = op->o_bd;
237 BackendInfo *bi0 = op->o_bd->bd_info;
240 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
241 if ( op->o_bd == b0 )
242 return SLAP_CB_CONTINUE;
244 b0->bd_info = on->on_info->oi_orig;
246 if ( op->o_bd->bd_info->bi_chk_referrals )
247 rc = ( *op->o_bd->bd_info->bi_chk_referrals )( op, rs );
249 rc = SLAP_CB_CONTINUE;
252 op->o_bd->bd_info = bi0;
257 glue_chk_controls ( Operation *op, SlapReply *rs )
259 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
260 BackendDB *b0 = op->o_bd;
261 BackendInfo *bi0 = op->o_bd->bd_info;
262 int rc = SLAP_CB_CONTINUE;
264 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
265 if ( op->o_bd == b0 )
266 return SLAP_CB_CONTINUE;
268 b0->bd_info = on->on_info->oi_orig;
270 /* if the subordinate database has overlays, the bi_chk_controls()
271 * hook is actually over_aux_chk_controls(); in case it actually
272 * wraps a missing hok, we need to mimic the behavior
273 * of the frontend applied to that database */
274 if ( op->o_bd->bd_info->bi_chk_controls ) {
275 rc = ( *op->o_bd->bd_info->bi_chk_controls )( op, rs );
279 if ( rc == SLAP_CB_CONTINUE ) {
280 rc = backend_check_controls( op, rs );
284 op->o_bd->bd_info = bi0;
288 /* ITS#4615 - overlays configured above the glue overlay should be
289 * invoked for the entire glued tree. Overlays configured below the
290 * glue overlay should only be invoked on the master backend.
291 * So, if we're searching on any subordinates, we need to force the
292 * current overlay chain to stop processing, without stopping the
293 * overall callback flow.
296 glue_sub_search( Operation *op, SlapReply *rs, BackendDB *b0,
299 /* Process any overlays on the master backend */
300 if ( op->o_bd == b0 && on->on_next ) {
301 BackendInfo *bi = op->o_bd->bd_info;
302 int rc = SLAP_CB_CONTINUE;
303 for ( on=on->on_next; on; on=on->on_next ) {
304 op->o_bd->bd_info = (BackendInfo *)on;
305 if ( on->on_bi.bi_op_search ) {
306 rc = on->on_bi.bi_op_search( op, rs );
307 if ( rc != SLAP_CB_CONTINUE )
311 op->o_bd->bd_info = bi;
312 if ( rc != SLAP_CB_CONTINUE )
315 return op->o_bd->be_search( op, rs );
319 glue_op_search ( Operation *op, SlapReply *rs )
321 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
322 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
323 BackendDB *b0 = op->o_bd;
324 BackendDB *b1 = NULL, *btmp;
325 BackendInfo *bi0 = op->o_bd->bd_info;
327 long stoptime = 0, starttime;
328 glue_state gs = {NULL, NULL, NULL, 0, 0, 0, 0};
329 slap_callback cb = { NULL, glue_op_response, glue_op_cleanup, NULL };
331 struct berval dn, ndn, *pdn;
335 cb.sc_next = op->o_callback;
337 starttime = op->o_time;
338 stoptime = slap_get_time () + op->ors_tlimit;
340 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
341 b0->bd_info = on->on_info->oi_orig;
343 switch (op->ors_scope) {
344 case LDAP_SCOPE_BASE:
345 if ( op->o_bd == b0 )
346 return SLAP_CB_CONTINUE;
348 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
349 if (op->o_bd && op->o_bd->be_search) {
350 rs->sr_err = op->o_bd->be_search( op, rs );
354 case LDAP_SCOPE_ONELEVEL:
355 case LDAP_SCOPE_SUBTREE:
356 case LDAP_SCOPE_SUBORDINATE: /* FIXME */
357 op->o_callback = &cb;
358 rs->sr_err = gs.err = LDAP_UNWILLING_TO_PERFORM;
359 scope0 = op->ors_scope;
360 tlimit0 = op->ors_tlimit;
366 * Execute in reverse order, most specific first
368 for (i = gi->gi_nodes; i >= 0; i--) {
369 if ( i == gi->gi_nodes ) {
373 btmp = gi->gi_n[i].gn_be;
374 pdn = &gi->gi_n[i].gn_pdn;
376 if (!btmp || !btmp->be_search)
378 if (!dnIsSuffix(&btmp->be_nsuffix[0], &b1->be_nsuffix[0]))
380 if (tlimit0 != SLAP_NO_LIMIT) {
381 op->o_time = slap_get_time();
382 op->ors_tlimit = stoptime - op->o_time;
383 if (op->ors_tlimit <= 0) {
384 rs->sr_err = gs.err = LDAP_TIMELIMIT_EXCEEDED;
397 assert( op->o_bd->be_suffix != NULL );
398 assert( op->o_bd->be_nsuffix != NULL );
400 if (scope0 == LDAP_SCOPE_ONELEVEL &&
403 op->ors_scope = LDAP_SCOPE_BASE;
404 op->o_req_dn = op->o_bd->be_suffix[0];
405 op->o_req_ndn = op->o_bd->be_nsuffix[0];
406 rs->sr_err = op->o_bd->be_search(op, rs);
407 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
408 gs.err = LDAP_SUCCESS;
410 op->ors_scope = LDAP_SCOPE_ONELEVEL;
414 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
415 dn_match(&op->o_bd->be_nsuffix[0], &ndn))
417 rs->sr_err = glue_sub_search( op, rs, b0, on );
419 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
420 dnIsSuffix(&op->o_bd->be_nsuffix[0], &ndn))
422 op->o_req_dn = op->o_bd->be_suffix[0];
423 op->o_req_ndn = op->o_bd->be_nsuffix[0];
424 rs->sr_err = glue_sub_search( op, rs, b0, on );
425 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
426 gs.err = LDAP_SUCCESS;
431 } else if (dnIsSuffix(&ndn, &op->o_bd->be_nsuffix[0])) {
432 rs->sr_err = glue_sub_search( op, rs, b0, on );
438 * Add errors that should result in dropping
441 case LDAP_SIZELIMIT_EXCEEDED:
442 case LDAP_TIMELIMIT_EXCEEDED:
443 case LDAP_ADMINLIMIT_EXCEEDED:
444 case LDAP_NO_SUCH_OBJECT:
445 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
446 case LDAP_X_CANNOT_CHAIN:
447 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
455 op->ors_scope = scope0;
456 op->ors_tlimit = tlimit0;
457 op->o_time = starttime;
463 if ( op->o_abandon ) {
464 rs->sr_err = SLAPD_ABANDON;
466 op->o_callback = cb.sc_next;
468 rs->sr_matched = gs.matched;
469 rs->sr_ref = gs.refs;
470 rs->sr_ctrls = gs.ctrls;
472 send_ldap_result( op, rs );
476 op->o_bd->bd_info = bi0;
480 ber_bvarray_free(gs.refs);
482 for (i = gs.nctrls; --i >= 0; ) {
483 if (!BER_BVISNULL( &gs.ctrls[i]->ldctl_value ))
484 free(gs.ctrls[i]->ldctl_value.bv_val);
492 static BackendDB toolDB;
495 glue_tool_entry_open (
500 slap_overinfo *oi = (slap_overinfo *)b0->bd_info;
502 /* We don't know which backend to talk to yet, so just
503 * remember the mode and move on...
509 toolDB.bd_info = oi->oi_orig;
515 glue_tool_entry_close (
522 if (!glueBack->be_entry_close)
524 rc = glueBack->be_entry_close (glueBack);
529 static slap_overinst *
534 slap_overinfo *oi = (slap_overinfo *)bi;
537 for ( on = oi->oi_list; on; on=on->on_next ) {
538 if ( !strcmp( on->on_bi.bi_type, glue.on_bi.bi_type ))
544 /* This function will only be called in tool mode */
550 slap_overinst *on = glue_tool_inst( bi );
551 glueinfo *gi = on->on_bi.bi_private;
552 static int glueOpened = 0;
553 int i, j, same, bsame = 0, rc = 0;
555 if (glueOpened) return 0;
559 /* If we were invoked in tool mode, open all the underlying backends */
560 if (slapMode & SLAP_TOOL_MODE) {
561 for (i = 0; i<gi->gi_nodes; i++) {
563 /* Same bi_open as our main backend? */
564 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
565 on->on_info->oi_orig->bi_open )
568 /* Loop thru the bd_info's and make sure we only
569 * invoke their bi_open functions once each.
571 for ( j = 0; j<i; j++ ) {
572 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
573 gi->gi_n[j].gn_be->bd_info->bi_open ) {
578 /* OK, it's unique and non-NULL, call it. */
579 if ( !same && gi->gi_n[i].gn_be->bd_info->bi_open )
580 rc = gi->gi_n[i].gn_be->bd_info->bi_open(
581 gi->gi_n[i].gn_be->bd_info );
582 /* Let backend.c take care of the rest of startup */
584 rc = backend_startup_one( gi->gi_n[i].gn_be );
587 if ( !rc && !bsame && on->on_info->oi_orig->bi_open )
588 rc = on->on_info->oi_orig->bi_open( on->on_info->oi_orig );
590 } /* other case is impossible */
594 /* This function will only be called in tool mode */
600 static int glueClosed = 0;
603 if (glueClosed) return 0;
607 if (slapMode & SLAP_TOOL_MODE) {
608 rc = backend_shutdown( NULL );
614 glue_entry_release_rw (
625 b2.bd_info = (BackendInfo *)glue_tool_inst( op->o_bd->bd_info );
626 op->o_bd = glue_back_select (&b2, &e->e_nname);
628 if ( op->o_bd->be_release ) {
629 rc = op->o_bd->be_release( op, e, rw );
632 /* FIXME: mimic be_entry_release_rw
633 * when no be_release() available */
643 glue_tool_entry_first (
647 slap_overinst *on = glue_tool_inst( b0->bd_info );
648 glueinfo *gi = on->on_bi.bi_private;
651 /* If we're starting from scratch, start at the most general */
653 if ( toolDB.be_entry_open && toolDB.be_entry_first ) {
656 for (i = gi->gi_nodes-1; i >= 0; i--) {
657 if (gi->gi_n[i].gn_be->be_entry_open &&
658 gi->gi_n[i].gn_be->be_entry_first) {
659 glueBack = gi->gi_n[i].gn_be;
665 if (!glueBack || !glueBack->be_entry_open || !glueBack->be_entry_first ||
666 glueBack->be_entry_open (glueBack, glueMode) != 0)
669 return glueBack->be_entry_first (glueBack);
673 glue_tool_entry_next (
677 slap_overinst *on = glue_tool_inst( b0->bd_info );
678 glueinfo *gi = on->on_bi.bi_private;
682 if (!glueBack || !glueBack->be_entry_next)
685 rc = glueBack->be_entry_next (glueBack);
687 /* If we ran out of entries in one database, move on to the next */
689 if ( glueBack && glueBack->be_entry_close )
690 glueBack->be_entry_close (glueBack);
691 for (i=0; i<gi->gi_nodes; i++) {
692 if (gi->gi_n[i].gn_be == glueBack)
699 glueBack = gi->gi_n[i-1].gn_be;
700 rc = glue_tool_entry_first (b0);
707 glue_tool_entry_get (
712 if (!glueBack || !glueBack->be_entry_get)
715 return glueBack->be_entry_get (glueBack, id);
719 glue_tool_entry_put (
729 b2.bd_info = (BackendInfo *)glue_tool_inst( b0->bd_info );
730 be = glue_back_select (&b2, &e->e_nname);
731 if ( be == &b2 ) be = &toolDB;
733 if (!be->be_entry_put)
737 if ( be->be_entry_open ) {
738 rc = be->be_entry_open (be, glueMode);
743 } else if (be != glueBack) {
744 /* If this entry belongs in a different branch than the
745 * previous one, close the current database and open the
748 if ( glueBack->be_entry_close ) {
749 glueBack->be_entry_close (glueBack);
751 if ( be->be_entry_open ) {
752 rc = be->be_entry_open (be, glueMode);
759 return be->be_entry_put (be, e, text);
763 glue_tool_entry_reindex (
768 if (!glueBack || !glueBack->be_entry_reindex)
771 return glueBack->be_entry_reindex (glueBack, id);
779 slap_overinst *on = glue_tool_inst( b0->bd_info );
780 glueinfo *gi = on->on_bi.bi_private;
781 BackendInfo *bi = b0->bd_info;
784 /* just sync everyone */
785 for (i = 0; i<gi->gi_nodes; i++)
786 if (gi->gi_n[i].gn_be->be_sync)
787 gi->gi_n[i].gn_be->be_sync (gi->gi_n[i].gn_be);
788 b0->bd_info = on->on_info->oi_orig;
800 slap_overinst *on = (slap_overinst *)be->bd_info;
801 slap_overinfo *oi = on->on_info;
802 BackendInfo *bi = oi->oi_orig;
805 if ( SLAP_GLUE_SUBORDINATE( be )) {
806 Debug( LDAP_DEBUG_ANY, "glue: backend %s is already subordinate, "
807 "cannot have glue overlay!\n",
808 be->be_suffix[0].bv_val, 0, 0 );
812 gi = ch_calloc( 1, sizeof(glueinfo));
813 on->on_bi.bi_private = gi;
814 dnParent( be->be_nsuffix, &gi->gi_pdn );
816 /* Currently the overlay framework doesn't handle these entry points
817 * but we need them....
819 oi->oi_bi.bi_open = glue_open;
820 oi->oi_bi.bi_close = glue_close;
822 oi->oi_bi.bi_entry_release_rw = glue_entry_release_rw;
824 /* Only advertise these if the root DB supports them */
825 if ( bi->bi_tool_entry_open )
826 oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
827 if ( bi->bi_tool_entry_close )
828 oi->oi_bi.bi_tool_entry_close = glue_tool_entry_close;
829 if ( bi->bi_tool_entry_first )
830 oi->oi_bi.bi_tool_entry_first = glue_tool_entry_first;
831 if ( bi->bi_tool_entry_next )
832 oi->oi_bi.bi_tool_entry_next = glue_tool_entry_next;
833 if ( bi->bi_tool_entry_get )
834 oi->oi_bi.bi_tool_entry_get = glue_tool_entry_get;
835 if ( bi->bi_tool_entry_put )
836 oi->oi_bi.bi_tool_entry_put = glue_tool_entry_put;
837 if ( bi->bi_tool_entry_reindex )
838 oi->oi_bi.bi_tool_entry_reindex = glue_tool_entry_reindex;
839 if ( bi->bi_tool_sync )
840 oi->oi_bi.bi_tool_sync = glue_tool_sync;
842 /*FIXME : need to add support */
843 oi->oi_bi.bi_tool_dn2id_get = 0;
844 oi->oi_bi.bi_tool_id2entry_get = 0;
845 oi->oi_bi.bi_tool_entry_modify = 0;
847 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE;
857 slap_overinst *on = (slap_overinst *)be->bd_info;
858 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
861 return SLAP_CB_CONTINUE;
869 slap_overinst *on = (slap_overinst *)be->bd_info;
871 on->on_info->oi_bi.bi_db_close = 0;
876 glue_sub_del( BackendDB *b0 )
881 /* Find the top backend for this subordinate */
883 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
889 if ( SLAP_GLUE_SUBORDINATE( be ))
891 if ( !SLAP_GLUE_INSTANCE( be ))
893 if ( !dnIsSuffix( &b0->be_nsuffix[0], &be->be_nsuffix[0] ))
896 /* OK, got the right backend, find the overlay */
897 oi = (slap_overinfo *)be->bd_info;
898 for ( on=oi->oi_list; on; on=on->on_next ) {
899 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
902 assert( on != NULL );
903 gi = on->on_bi.bi_private;
904 for ( i=0; i < gi->gi_nodes; i++ ) {
905 if ( gi->gi_n[i].gn_be == b0 ) {
908 for (j=i+1; j < gi->gi_nodes; j++)
909 gi->gi_n[j-1] = gi->gi_n[j];
916 rc = LDAP_NO_SUCH_OBJECT;
921 typedef struct glue_Addrec {
922 struct glue_Addrec *ga_next;
926 /* List of added subordinates */
927 static glue_Addrec *ga_list;
929 /* Attach all the subordinate backends to their superior */
933 glue_Addrec *ga, *gnext = NULL;
936 /* For all the subordinate backends */
937 for ( ga=ga_list; ga != NULL; ga = gnext ) {
942 /* Find the top backend for this subordinate */
944 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
949 if ( SLAP_GLUE_SUBORDINATE( be ))
951 if ( !dnIsSuffix( &ga->ga_be->be_nsuffix[0], &be->be_nsuffix[0] ))
954 /* If it's not already configured, set up the overlay */
955 if ( !SLAP_GLUE_INSTANCE( be )) {
956 rc = overlay_config( be, glue.on_bi.bi_type );
960 /* Find the overlay instance */
961 oi = (slap_overinfo *)be->bd_info;
962 for ( on=oi->oi_list; on; on=on->on_next ) {
963 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
966 assert( on != NULL );
967 gi = on->on_bi.bi_private;
968 gi = (glueinfo *)ch_realloc( gi, sizeof(glueinfo) +
969 gi->gi_nodes * sizeof(gluenode));
970 gi->gi_n[gi->gi_nodes].gn_be = ga->ga_be;
971 dnParent( &ga->ga_be->be_nsuffix[0],
972 &gi->gi_n[gi->gi_nodes].gn_pdn );
974 on->on_bi.bi_private = gi;
978 Debug( LDAP_DEBUG_ANY, "glue: no superior found for sub %s!\n",
979 ga->ga_be->be_suffix[0].bv_val, 0, 0 );
980 rc = LDAP_NO_SUCH_OBJECT;
992 glue_sub_add( BackendDB *be, int advert, int online )
997 if ( overlay_is_inst( be, "glue" )) {
998 Debug( LDAP_DEBUG_ANY, "glue: backend %s already has glue overlay, "
999 "cannot be a subordinate!\n",
1000 be->be_suffix[0].bv_val, 0, 0 );
1003 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
1005 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_ADVERTISE;
1007 ga = ch_malloc( sizeof( glue_Addrec ));
1008 ga->ga_next = ga_list;
1013 rc = glue_sub_attach();
1021 glue.on_bi.bi_type = "glue";
1023 glue.on_bi.bi_db_init = glue_db_init;
1024 glue.on_bi.bi_db_close = glue_db_close;
1025 glue.on_bi.bi_db_destroy = glue_db_destroy;
1027 glue.on_bi.bi_op_search = glue_op_search;
1028 glue.on_bi.bi_op_modify = glue_op_func;
1029 glue.on_bi.bi_op_modrdn = glue_op_func;
1030 glue.on_bi.bi_op_add = glue_op_func;
1031 glue.on_bi.bi_op_delete = glue_op_func;
1032 glue.on_bi.bi_extended = glue_op_func;
1034 glue.on_bi.bi_chk_referrals = glue_chk_referrals;
1035 glue.on_bi.bi_chk_controls = glue_chk_controls;
1036 glue.on_response = glue_response;
1038 return overlay_register( &glue );