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 );
618 AttributeDescription *ad,
622 BackendDB *b0 = op->o_bd;
625 op->o_bd = glue_back_select( b0, dn );
627 if ( op->o_bd->be_fetch ) {
628 rc = op->o_bd->be_fetch( op, dn, oc, ad, rw, e );
630 rc = LDAP_UNWILLING_TO_PERFORM;
637 glue_entry_release_rw (
643 BackendDB *b0 = op->o_bd;
646 op->o_bd = glue_back_select (b0, &e->e_nname);
648 if ( op->o_bd->be_release ) {
649 rc = op->o_bd->be_release( op, e, rw );
652 /* FIXME: mimic be_entry_release_rw
653 * when no be_release() available */
663 glue_tool_entry_first (
667 slap_overinst *on = glue_tool_inst( b0->bd_info );
668 glueinfo *gi = on->on_bi.bi_private;
671 /* If we're starting from scratch, start at the most general */
673 if ( toolDB.be_entry_open && toolDB.be_entry_first ) {
676 for (i = gi->gi_nodes-1; i >= 0; i--) {
677 if (gi->gi_n[i].gn_be->be_entry_open &&
678 gi->gi_n[i].gn_be->be_entry_first) {
679 glueBack = gi->gi_n[i].gn_be;
685 if (!glueBack || !glueBack->be_entry_open || !glueBack->be_entry_first ||
686 glueBack->be_entry_open (glueBack, glueMode) != 0)
689 return glueBack->be_entry_first (glueBack);
693 glue_tool_entry_next (
697 slap_overinst *on = glue_tool_inst( b0->bd_info );
698 glueinfo *gi = on->on_bi.bi_private;
702 if (!glueBack || !glueBack->be_entry_next)
705 rc = glueBack->be_entry_next (glueBack);
707 /* If we ran out of entries in one database, move on to the next */
709 if ( glueBack && glueBack->be_entry_close )
710 glueBack->be_entry_close (glueBack);
711 for (i=0; i<gi->gi_nodes; i++) {
712 if (gi->gi_n[i].gn_be == glueBack)
719 glueBack = gi->gi_n[i-1].gn_be;
720 rc = glue_tool_entry_first (b0);
727 glue_tool_entry_get (
732 if (!glueBack || !glueBack->be_entry_get)
735 return glueBack->be_entry_get (glueBack, id);
739 glue_tool_entry_put (
749 b2.bd_info = (BackendInfo *)glue_tool_inst( b0->bd_info );
750 be = glue_back_select (&b2, &e->e_nname);
751 if ( be == &b2 ) be = &toolDB;
753 if (!be->be_entry_put)
757 if ( be->be_entry_open ) {
758 rc = be->be_entry_open (be, glueMode);
763 } else if (be != glueBack) {
764 /* If this entry belongs in a different branch than the
765 * previous one, close the current database and open the
768 if ( glueBack->be_entry_close ) {
769 glueBack->be_entry_close (glueBack);
771 if ( be->be_entry_open ) {
772 rc = be->be_entry_open (be, glueMode);
779 return be->be_entry_put (be, e, text);
783 glue_tool_entry_reindex (
788 if (!glueBack || !glueBack->be_entry_reindex)
791 return glueBack->be_entry_reindex (glueBack, id);
799 slap_overinst *on = glue_tool_inst( b0->bd_info );
800 glueinfo *gi = on->on_bi.bi_private;
801 BackendInfo *bi = b0->bd_info;
804 /* just sync everyone */
805 for (i = 0; i<gi->gi_nodes; i++)
806 if (gi->gi_n[i].gn_be->be_sync)
807 gi->gi_n[i].gn_be->be_sync (gi->gi_n[i].gn_be);
808 b0->bd_info = on->on_info->oi_orig;
820 slap_overinst *on = (slap_overinst *)be->bd_info;
821 slap_overinfo *oi = on->on_info;
822 BackendInfo *bi = oi->oi_orig;
825 if ( SLAP_GLUE_SUBORDINATE( be )) {
826 Debug( LDAP_DEBUG_ANY, "glue: backend %s is already subordinate, "
827 "cannot have glue overlay!\n",
828 be->be_suffix[0].bv_val, 0, 0 );
832 gi = ch_calloc( 1, sizeof(glueinfo));
833 on->on_bi.bi_private = gi;
834 dnParent( be->be_nsuffix, &gi->gi_pdn );
836 /* Currently the overlay framework doesn't handle these entry points
837 * but we need them....
839 oi->oi_bi.bi_open = glue_open;
840 oi->oi_bi.bi_close = glue_close;
842 /* Only advertise these if the root DB supports them */
843 if ( bi->bi_tool_entry_open )
844 oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
845 if ( bi->bi_tool_entry_close )
846 oi->oi_bi.bi_tool_entry_close = glue_tool_entry_close;
847 if ( bi->bi_tool_entry_first )
848 oi->oi_bi.bi_tool_entry_first = glue_tool_entry_first;
849 if ( bi->bi_tool_entry_next )
850 oi->oi_bi.bi_tool_entry_next = glue_tool_entry_next;
851 if ( bi->bi_tool_entry_get )
852 oi->oi_bi.bi_tool_entry_get = glue_tool_entry_get;
853 if ( bi->bi_tool_entry_put )
854 oi->oi_bi.bi_tool_entry_put = glue_tool_entry_put;
855 if ( bi->bi_tool_entry_reindex )
856 oi->oi_bi.bi_tool_entry_reindex = glue_tool_entry_reindex;
857 if ( bi->bi_tool_sync )
858 oi->oi_bi.bi_tool_sync = glue_tool_sync;
860 /*FIXME : need to add support */
861 oi->oi_bi.bi_tool_dn2id_get = 0;
862 oi->oi_bi.bi_tool_id2entry_get = 0;
863 oi->oi_bi.bi_tool_entry_modify = 0;
865 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE;
875 slap_overinst *on = (slap_overinst *)be->bd_info;
876 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
879 return SLAP_CB_CONTINUE;
887 slap_overinst *on = (slap_overinst *)be->bd_info;
889 on->on_info->oi_bi.bi_db_close = 0;
894 glue_sub_del( BackendDB *b0 )
899 /* Find the top backend for this subordinate */
901 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
907 if ( SLAP_GLUE_SUBORDINATE( be ))
909 if ( !SLAP_GLUE_INSTANCE( be ))
911 if ( !dnIsSuffix( &b0->be_nsuffix[0], &be->be_nsuffix[0] ))
914 /* OK, got the right backend, find the overlay */
915 oi = (slap_overinfo *)be->bd_info;
916 for ( on=oi->oi_list; on; on=on->on_next ) {
917 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
920 assert( on != NULL );
921 gi = on->on_bi.bi_private;
922 for ( i=0; i < gi->gi_nodes; i++ ) {
923 if ( gi->gi_n[i].gn_be == b0 ) {
926 for (j=i+1; j < gi->gi_nodes; j++)
927 gi->gi_n[j-1] = gi->gi_n[j];
934 rc = LDAP_NO_SUCH_OBJECT;
939 typedef struct glue_Addrec {
940 struct glue_Addrec *ga_next;
944 /* List of added subordinates */
945 static glue_Addrec *ga_list;
947 /* Attach all the subordinate backends to their superior */
951 glue_Addrec *ga, *gnext = NULL;
954 /* For all the subordinate backends */
955 for ( ga=ga_list; ga != NULL; ga = gnext ) {
960 /* Find the top backend for this subordinate */
962 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
967 if ( SLAP_GLUE_SUBORDINATE( be ))
969 if ( !dnIsSuffix( &ga->ga_be->be_nsuffix[0], &be->be_nsuffix[0] ))
972 /* If it's not already configured, set up the overlay */
973 if ( !SLAP_GLUE_INSTANCE( be )) {
974 rc = overlay_config( be, glue.on_bi.bi_type );
978 /* Find the overlay instance */
979 oi = (slap_overinfo *)be->bd_info;
980 for ( on=oi->oi_list; on; on=on->on_next ) {
981 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
984 assert( on != NULL );
985 gi = on->on_bi.bi_private;
986 gi = (glueinfo *)ch_realloc( gi, sizeof(glueinfo) +
987 gi->gi_nodes * sizeof(gluenode));
988 gi->gi_n[gi->gi_nodes].gn_be = ga->ga_be;
989 dnParent( &ga->ga_be->be_nsuffix[0],
990 &gi->gi_n[gi->gi_nodes].gn_pdn );
992 on->on_bi.bi_private = gi;
996 Debug( LDAP_DEBUG_ANY, "glue: no superior found for sub %s!\n",
997 ga->ga_be->be_suffix[0].bv_val, 0, 0 );
998 rc = LDAP_NO_SUCH_OBJECT;
1010 glue_sub_add( BackendDB *be, int advert, int online )
1015 if ( overlay_is_inst( be, "glue" )) {
1016 Debug( LDAP_DEBUG_ANY, "glue: backend %s already has glue overlay, "
1017 "cannot be a subordinate!\n",
1018 be->be_suffix[0].bv_val, 0, 0 );
1021 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
1023 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_ADVERTISE;
1025 ga = ch_malloc( sizeof( glue_Addrec ));
1026 ga->ga_next = ga_list;
1031 rc = glue_sub_attach();
1039 glue.on_bi.bi_type = "glue";
1041 glue.on_bi.bi_db_init = glue_db_init;
1042 glue.on_bi.bi_db_close = glue_db_close;
1043 glue.on_bi.bi_db_destroy = glue_db_destroy;
1045 glue.on_bi.bi_op_search = glue_op_search;
1046 glue.on_bi.bi_op_modify = glue_op_func;
1047 glue.on_bi.bi_op_modrdn = glue_op_func;
1048 glue.on_bi.bi_op_add = glue_op_func;
1049 glue.on_bi.bi_op_delete = glue_op_func;
1050 glue.on_bi.bi_extended = glue_op_func;
1052 glue.on_bi.bi_chk_referrals = glue_chk_referrals;
1053 glue.on_bi.bi_chk_controls = glue_chk_controls;
1054 glue.on_bi.bi_entry_get_rw = glue_entry_get_rw;
1055 glue.on_bi.bi_entry_release_rw = glue_entry_release_rw;
1057 glue.on_response = glue_response;
1059 return overlay_register( &glue );