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 BackendDB *be = op->o_bd;
223 be = glue_back_select (op->o_bd, &op->o_req_ndn);
225 /* If we're on the master backend, let overlay framework handle it.
226 * Otherwise, bail out.
228 return ( op->o_bd == be ) ? SLAP_CB_CONTINUE : SLAP_CB_BYPASS;
232 glue_chk_referrals ( Operation *op, SlapReply *rs )
234 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
235 BackendDB *b0 = op->o_bd;
236 BackendInfo *bi0 = op->o_bd->bd_info;
239 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
240 if ( op->o_bd == b0 )
241 return SLAP_CB_CONTINUE;
243 b0->bd_info = on->on_info->oi_orig;
245 if ( op->o_bd->bd_info->bi_chk_referrals )
246 rc = ( *op->o_bd->bd_info->bi_chk_referrals )( op, rs );
248 rc = SLAP_CB_CONTINUE;
251 op->o_bd->bd_info = bi0;
256 glue_chk_controls ( Operation *op, SlapReply *rs )
258 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
259 BackendDB *b0 = op->o_bd;
260 BackendInfo *bi0 = op->o_bd->bd_info;
261 int rc = SLAP_CB_CONTINUE;
263 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
264 if ( op->o_bd == b0 )
265 return SLAP_CB_CONTINUE;
267 b0->bd_info = on->on_info->oi_orig;
269 /* if the subordinate database has overlays, the bi_chk_controls()
270 * hook is actually over_aux_chk_controls(); in case it actually
271 * wraps a missing hok, we need to mimic the behavior
272 * of the frontend applied to that database */
273 if ( op->o_bd->bd_info->bi_chk_controls ) {
274 rc = ( *op->o_bd->bd_info->bi_chk_controls )( op, rs );
278 if ( rc == SLAP_CB_CONTINUE ) {
279 rc = backend_check_controls( op, rs );
283 op->o_bd->bd_info = bi0;
287 /* ITS#4615 - overlays configured above the glue overlay should be
288 * invoked for the entire glued tree. Overlays configured below the
289 * glue overlay should only be invoked on the master backend.
290 * So, if we're searching on any subordinates, we need to force the
291 * current overlay chain to stop processing, without stopping the
292 * overall callback flow.
295 glue_sub_search( Operation *op, SlapReply *rs, BackendDB *b0,
298 /* Process any overlays on the master backend */
299 if ( op->o_bd == b0 && on->on_next ) {
300 BackendInfo *bi = op->o_bd->bd_info;
301 int rc = SLAP_CB_CONTINUE;
302 for ( on=on->on_next; on; on=on->on_next ) {
303 op->o_bd->bd_info = (BackendInfo *)on;
304 if ( on->on_bi.bi_op_search ) {
305 rc = on->on_bi.bi_op_search( op, rs );
306 if ( rc != SLAP_CB_CONTINUE )
310 op->o_bd->bd_info = bi;
311 if ( rc != SLAP_CB_CONTINUE )
314 return op->o_bd->be_search( op, rs );
318 glue_op_search ( Operation *op, SlapReply *rs )
320 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
321 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
322 BackendDB *b0 = op->o_bd;
323 BackendDB *b1 = NULL, *btmp;
324 BackendInfo *bi0 = op->o_bd->bd_info;
326 long stoptime = 0, starttime;
327 glue_state gs = {NULL, NULL, NULL, 0, 0, 0, 0};
328 slap_callback cb = { NULL, glue_op_response, glue_op_cleanup, NULL };
330 struct berval dn, ndn, *pdn;
334 cb.sc_next = op->o_callback;
336 starttime = op->o_time;
337 stoptime = slap_get_time () + op->ors_tlimit;
339 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
340 b0->bd_info = on->on_info->oi_orig;
342 switch (op->ors_scope) {
343 case LDAP_SCOPE_BASE:
344 if ( op->o_bd == b0 )
345 return SLAP_CB_CONTINUE;
347 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
348 if (op->o_bd && op->o_bd->be_search) {
349 rs->sr_err = op->o_bd->be_search( op, rs );
353 case LDAP_SCOPE_ONELEVEL:
354 case LDAP_SCOPE_SUBTREE:
355 case LDAP_SCOPE_SUBORDINATE: /* FIXME */
356 op->o_callback = &cb;
357 rs->sr_err = gs.err = LDAP_UNWILLING_TO_PERFORM;
358 scope0 = op->ors_scope;
359 tlimit0 = op->ors_tlimit;
365 * Execute in reverse order, most specific first
367 for (i = gi->gi_nodes; i >= 0; i--) {
368 if ( i == gi->gi_nodes ) {
372 btmp = gi->gi_n[i].gn_be;
373 pdn = &gi->gi_n[i].gn_pdn;
375 if (!btmp || !btmp->be_search)
377 if (!dnIsSuffix(&btmp->be_nsuffix[0], &b1->be_nsuffix[0]))
379 if (get_no_subordinate_glue(op) && btmp != b1)
382 if (tlimit0 != SLAP_NO_LIMIT) {
383 op->o_time = slap_get_time();
384 op->ors_tlimit = stoptime - op->o_time;
385 if (op->ors_tlimit <= 0) {
386 rs->sr_err = gs.err = LDAP_TIMELIMIT_EXCEEDED;
399 assert( op->o_bd->be_suffix != NULL );
400 assert( op->o_bd->be_nsuffix != NULL );
402 if (scope0 == LDAP_SCOPE_ONELEVEL &&
405 op->ors_scope = LDAP_SCOPE_BASE;
406 op->o_req_dn = op->o_bd->be_suffix[0];
407 op->o_req_ndn = op->o_bd->be_nsuffix[0];
408 rs->sr_err = op->o_bd->be_search(op, rs);
409 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
410 gs.err = LDAP_SUCCESS;
412 op->ors_scope = LDAP_SCOPE_ONELEVEL;
416 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
417 dn_match(&op->o_bd->be_nsuffix[0], &ndn))
419 rs->sr_err = glue_sub_search( op, rs, b0, on );
421 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
422 dnIsSuffix(&op->o_bd->be_nsuffix[0], &ndn))
424 op->o_req_dn = op->o_bd->be_suffix[0];
425 op->o_req_ndn = op->o_bd->be_nsuffix[0];
426 rs->sr_err = glue_sub_search( op, rs, b0, on );
427 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
428 gs.err = LDAP_SUCCESS;
433 } else if (dnIsSuffix(&ndn, &op->o_bd->be_nsuffix[0])) {
434 rs->sr_err = glue_sub_search( op, rs, b0, on );
440 * Add errors that should result in dropping
443 case LDAP_SIZELIMIT_EXCEEDED:
444 case LDAP_TIMELIMIT_EXCEEDED:
445 case LDAP_ADMINLIMIT_EXCEEDED:
446 case LDAP_NO_SUCH_OBJECT:
447 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
448 case LDAP_X_CANNOT_CHAIN:
449 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
457 op->ors_scope = scope0;
458 op->ors_tlimit = tlimit0;
459 op->o_time = starttime;
465 if ( op->o_abandon ) {
466 rs->sr_err = SLAPD_ABANDON;
468 op->o_callback = cb.sc_next;
470 rs->sr_matched = gs.matched;
471 rs->sr_ref = gs.refs;
472 rs->sr_ctrls = gs.ctrls;
474 send_ldap_result( op, rs );
478 op->o_bd->bd_info = bi0;
482 ber_bvarray_free(gs.refs);
484 for (i = gs.nctrls; --i >= 0; ) {
485 if (!BER_BVISNULL( &gs.ctrls[i]->ldctl_value ))
486 free(gs.ctrls[i]->ldctl_value.bv_val);
494 static BackendDB toolDB;
497 glue_tool_entry_open (
502 slap_overinfo *oi = (slap_overinfo *)b0->bd_info;
504 /* We don't know which backend to talk to yet, so just
505 * remember the mode and move on...
511 toolDB.bd_info = oi->oi_orig;
517 glue_tool_entry_close (
524 if (!glueBack->be_entry_close)
526 rc = glueBack->be_entry_close (glueBack);
531 static slap_overinst *
536 slap_overinfo *oi = (slap_overinfo *)bi;
539 for ( on = oi->oi_list; on; on=on->on_next ) {
540 if ( !strcmp( on->on_bi.bi_type, glue.on_bi.bi_type ))
546 /* This function will only be called in tool mode */
552 slap_overinst *on = glue_tool_inst( bi );
553 glueinfo *gi = on->on_bi.bi_private;
554 static int glueOpened = 0;
555 int i, j, same, bsame = 0, rc = 0;
557 if (glueOpened) return 0;
561 /* If we were invoked in tool mode, open all the underlying backends */
562 if (slapMode & SLAP_TOOL_MODE) {
563 for (i = 0; i<gi->gi_nodes; i++) {
565 /* Same bi_open as our main backend? */
566 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
567 on->on_info->oi_orig->bi_open )
570 /* Loop thru the bd_info's and make sure we only
571 * invoke their bi_open functions once each.
573 for ( j = 0; j<i; j++ ) {
574 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
575 gi->gi_n[j].gn_be->bd_info->bi_open ) {
580 /* OK, it's unique and non-NULL, call it. */
581 if ( !same && gi->gi_n[i].gn_be->bd_info->bi_open )
582 rc = gi->gi_n[i].gn_be->bd_info->bi_open(
583 gi->gi_n[i].gn_be->bd_info );
584 /* Let backend.c take care of the rest of startup */
586 rc = backend_startup_one( gi->gi_n[i].gn_be );
589 if ( !rc && !bsame && on->on_info->oi_orig->bi_open )
590 rc = on->on_info->oi_orig->bi_open( on->on_info->oi_orig );
592 } /* other case is impossible */
596 /* This function will only be called in tool mode */
602 static int glueClosed = 0;
605 if (glueClosed) return 0;
609 if (slapMode & SLAP_TOOL_MODE) {
610 rc = backend_shutdown( NULL );
620 AttributeDescription *ad,
625 BackendDB *b0 = op->o_bd;
626 op->o_bd = glue_back_select( b0, dn );
628 if ( op->o_bd->be_fetch ) {
629 rc = op->o_bd->be_fetch( op, dn, oc, ad, rw, e );
631 rc = LDAP_UNWILLING_TO_PERFORM;
638 glue_entry_release_rw (
644 BackendDB *b0 = op->o_bd;
647 op->o_bd = glue_back_select (b0, &e->e_nname);
649 if ( op->o_bd->be_release ) {
650 rc = op->o_bd->be_release( op, e, rw );
653 /* FIXME: mimic be_entry_release_rw
654 * when no be_release() available */
664 glue_tool_entry_first (
668 slap_overinst *on = glue_tool_inst( b0->bd_info );
669 glueinfo *gi = on->on_bi.bi_private;
672 /* If we're starting from scratch, start at the most general */
674 if ( toolDB.be_entry_open && toolDB.be_entry_first ) {
677 for (i = gi->gi_nodes-1; i >= 0; i--) {
678 if (gi->gi_n[i].gn_be->be_entry_open &&
679 gi->gi_n[i].gn_be->be_entry_first) {
680 glueBack = gi->gi_n[i].gn_be;
686 if (!glueBack || !glueBack->be_entry_open || !glueBack->be_entry_first ||
687 glueBack->be_entry_open (glueBack, glueMode) != 0)
690 return glueBack->be_entry_first (glueBack);
694 glue_tool_entry_next (
698 slap_overinst *on = glue_tool_inst( b0->bd_info );
699 glueinfo *gi = on->on_bi.bi_private;
703 if (!glueBack || !glueBack->be_entry_next)
706 rc = glueBack->be_entry_next (glueBack);
708 /* If we ran out of entries in one database, move on to the next */
710 if ( glueBack && glueBack->be_entry_close )
711 glueBack->be_entry_close (glueBack);
712 for (i=0; i<gi->gi_nodes; i++) {
713 if (gi->gi_n[i].gn_be == glueBack)
720 glueBack = gi->gi_n[i-1].gn_be;
721 rc = glue_tool_entry_first (b0);
728 glue_tool_entry_get (
733 if (!glueBack || !glueBack->be_entry_get)
736 return glueBack->be_entry_get (glueBack, id);
740 glue_tool_entry_put (
750 b2.bd_info = (BackendInfo *)glue_tool_inst( b0->bd_info );
751 be = glue_back_select (&b2, &e->e_nname);
752 if ( be == &b2 ) be = &toolDB;
754 if (!be->be_entry_put)
758 if ( be->be_entry_open ) {
759 rc = be->be_entry_open (be, glueMode);
764 } else if (be != glueBack) {
765 /* If this entry belongs in a different branch than the
766 * previous one, close the current database and open the
769 if ( glueBack->be_entry_close ) {
770 glueBack->be_entry_close (glueBack);
772 if ( be->be_entry_open ) {
773 rc = be->be_entry_open (be, glueMode);
780 return be->be_entry_put (be, e, text);
784 glue_tool_entry_reindex (
787 AttributeDescription **adv
790 if (!glueBack || !glueBack->be_entry_reindex)
793 return glueBack->be_entry_reindex (glueBack, id, adv);
801 slap_overinst *on = glue_tool_inst( b0->bd_info );
802 glueinfo *gi = on->on_bi.bi_private;
803 BackendInfo *bi = b0->bd_info;
806 /* just sync everyone */
807 for (i = 0; i<gi->gi_nodes; i++)
808 if (gi->gi_n[i].gn_be->be_sync)
809 gi->gi_n[i].gn_be->be_sync (gi->gi_n[i].gn_be);
810 b0->bd_info = on->on_info->oi_orig;
822 slap_overinst *on = (slap_overinst *)be->bd_info;
823 slap_overinfo *oi = on->on_info;
824 BackendInfo *bi = oi->oi_orig;
827 if ( SLAP_GLUE_SUBORDINATE( be )) {
828 Debug( LDAP_DEBUG_ANY, "glue: backend %s is already subordinate, "
829 "cannot have glue overlay!\n",
830 be->be_suffix[0].bv_val, 0, 0 );
834 gi = ch_calloc( 1, sizeof(glueinfo));
835 on->on_bi.bi_private = gi;
836 dnParent( be->be_nsuffix, &gi->gi_pdn );
838 /* Currently the overlay framework doesn't handle these entry points
839 * but we need them....
841 oi->oi_bi.bi_open = glue_open;
842 oi->oi_bi.bi_close = glue_close;
844 /* Only advertise these if the root DB supports them */
845 if ( bi->bi_tool_entry_open )
846 oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
847 if ( bi->bi_tool_entry_close )
848 oi->oi_bi.bi_tool_entry_close = glue_tool_entry_close;
849 if ( bi->bi_tool_entry_first )
850 oi->oi_bi.bi_tool_entry_first = glue_tool_entry_first;
851 if ( bi->bi_tool_entry_next )
852 oi->oi_bi.bi_tool_entry_next = glue_tool_entry_next;
853 if ( bi->bi_tool_entry_get )
854 oi->oi_bi.bi_tool_entry_get = glue_tool_entry_get;
855 if ( bi->bi_tool_entry_put )
856 oi->oi_bi.bi_tool_entry_put = glue_tool_entry_put;
857 if ( bi->bi_tool_entry_reindex )
858 oi->oi_bi.bi_tool_entry_reindex = glue_tool_entry_reindex;
859 if ( bi->bi_tool_sync )
860 oi->oi_bi.bi_tool_sync = glue_tool_sync;
862 /*FIXME : need to add support */
863 oi->oi_bi.bi_tool_dn2id_get = 0;
864 oi->oi_bi.bi_tool_id2entry_get = 0;
865 oi->oi_bi.bi_tool_entry_modify = 0;
867 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE;
877 slap_overinst *on = (slap_overinst *)be->bd_info;
878 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
881 return SLAP_CB_CONTINUE;
889 slap_overinst *on = (slap_overinst *)be->bd_info;
891 on->on_info->oi_bi.bi_db_close = 0;
896 glue_sub_del( BackendDB *b0 )
901 /* Find the top backend for this subordinate */
903 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
909 if ( SLAP_GLUE_SUBORDINATE( be ))
911 if ( !SLAP_GLUE_INSTANCE( be ))
913 if ( !dnIsSuffix( &b0->be_nsuffix[0], &be->be_nsuffix[0] ))
916 /* OK, got the right backend, find the overlay */
917 oi = (slap_overinfo *)be->bd_info;
918 for ( on=oi->oi_list; on; on=on->on_next ) {
919 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
922 assert( on != NULL );
923 gi = on->on_bi.bi_private;
924 for ( i=0; i < gi->gi_nodes; i++ ) {
925 if ( gi->gi_n[i].gn_be == b0 ) {
928 for (j=i+1; j < gi->gi_nodes; j++)
929 gi->gi_n[j-1] = gi->gi_n[j];
936 rc = LDAP_NO_SUCH_OBJECT;
941 typedef struct glue_Addrec {
942 struct glue_Addrec *ga_next;
946 /* List of added subordinates */
947 static glue_Addrec *ga_list;
949 /* Attach all the subordinate backends to their superior */
953 glue_Addrec *ga, *gnext = NULL;
956 /* For all the subordinate backends */
957 for ( ga=ga_list; ga != NULL; ga = gnext ) {
962 /* Find the top backend for this subordinate */
964 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
969 if ( SLAP_GLUE_SUBORDINATE( be ))
971 if ( !dnIsSuffix( &ga->ga_be->be_nsuffix[0], &be->be_nsuffix[0] ))
974 /* If it's not already configured, set up the overlay */
975 if ( !SLAP_GLUE_INSTANCE( be )) {
976 rc = overlay_config( be, glue.on_bi.bi_type, -1, NULL );
980 /* Find the overlay instance */
981 oi = (slap_overinfo *)be->bd_info;
982 for ( on=oi->oi_list; on; on=on->on_next ) {
983 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
986 assert( on != NULL );
987 gi = on->on_bi.bi_private;
988 gi = (glueinfo *)ch_realloc( gi, sizeof(glueinfo) +
989 gi->gi_nodes * sizeof(gluenode));
990 gi->gi_n[gi->gi_nodes].gn_be = ga->ga_be;
991 dnParent( &ga->ga_be->be_nsuffix[0],
992 &gi->gi_n[gi->gi_nodes].gn_pdn );
994 on->on_bi.bi_private = gi;
998 Debug( LDAP_DEBUG_ANY, "glue: no superior found for sub %s!\n",
999 ga->ga_be->be_suffix[0].bv_val, 0, 0 );
1000 rc = LDAP_NO_SUCH_OBJECT;
1012 glue_sub_add( BackendDB *be, int advert, int online )
1017 if ( overlay_is_inst( be, "glue" )) {
1018 Debug( LDAP_DEBUG_ANY, "glue: backend %s already has glue overlay, "
1019 "cannot be a subordinate!\n",
1020 be->be_suffix[0].bv_val, 0, 0 );
1023 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
1025 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_ADVERTISE;
1027 ga = ch_malloc( sizeof( glue_Addrec ));
1028 ga->ga_next = ga_list;
1033 rc = glue_sub_attach();
1041 glue.on_bi.bi_type = "glue";
1043 glue.on_bi.bi_db_init = glue_db_init;
1044 glue.on_bi.bi_db_close = glue_db_close;
1045 glue.on_bi.bi_db_destroy = glue_db_destroy;
1047 glue.on_bi.bi_op_search = glue_op_search;
1048 glue.on_bi.bi_op_modify = glue_op_func;
1049 glue.on_bi.bi_op_modrdn = glue_op_func;
1050 glue.on_bi.bi_op_add = glue_op_func;
1051 glue.on_bi.bi_op_delete = glue_op_func;
1052 glue.on_bi.bi_extended = glue_op_func;
1054 glue.on_bi.bi_chk_referrals = glue_chk_referrals;
1055 glue.on_bi.bi_chk_controls = glue_chk_controls;
1056 glue.on_bi.bi_entry_get_rw = glue_entry_get_rw;
1057 glue.on_bi.bi_entry_release_rw = glue_entry_release_rw;
1059 glue.on_response = glue_response;
1061 return overlay_register( &glue );