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>
40 typedef struct gluenode {
45 typedef struct glueinfo {
51 static slap_overinst glue;
54 static BackendDB *glueBack;
56 static slap_response glue_op_response;
58 /* Just like select_backend, but only for our backends */
65 slap_overinst *on = (slap_overinst *)be->bd_info;
66 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
69 for (i = gi->gi_nodes-1; i >= 0; i--) {
70 assert( gi->gi_n[i].gn_be->be_nsuffix != NULL );
72 if (dnIsSuffix(dn, &gi->gi_n[i].gn_be->be_nsuffix[0])) {
73 return gi->gi_n[i].gn_be;
76 be->bd_info = on->on_info->oi_orig;
81 typedef struct glue_state {
92 glue_op_cleanup( Operation *op, SlapReply *rs )
94 /* This is not a final result */
95 if (rs->sr_type == REP_RESULT )
96 rs->sr_type = REP_GLUE_RESULT;
97 return SLAP_CB_CONTINUE;
101 glue_op_response ( Operation *op, SlapReply *rs )
103 glue_state *gs = op->o_callback->sc_private;
105 switch(rs->sr_type) {
108 case REP_INTERMEDIATE:
109 return SLAP_CB_CONTINUE;
112 if (rs->sr_err == LDAP_SUCCESS ||
113 rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ||
114 rs->sr_err == LDAP_TIMELIMIT_EXCEEDED ||
115 rs->sr_err == LDAP_ADMINLIMIT_EXCEEDED ||
116 rs->sr_err == LDAP_NO_SUCH_OBJECT ||
117 gs->err != LDAP_SUCCESS)
118 gs->err = rs->sr_err;
119 if (gs->err == LDAP_SUCCESS && gs->matched) {
120 ch_free (gs->matched);
124 if (gs->err != LDAP_SUCCESS && rs->sr_matched) {
126 len = strlen (rs->sr_matched);
127 if (len > gs->matchlen) {
129 ch_free (gs->matched);
130 gs->matched = ch_strdup (rs->sr_matched);
138 for (i=0; rs->sr_ref[i].bv_val; i++);
142 new = ch_malloc ((i+1)*sizeof(struct berval));
144 new = ch_realloc(gs->refs,
145 (j+i+1)*sizeof(struct berval));
147 for (k=0; k<i; j++,k++) {
148 ber_dupbv( &new[j], &rs->sr_ref[k] );
150 new[j].bv_val = NULL;
156 LDAPControl **newctrls;
158 for (i=0; rs->sr_ctrls[i]; i++);
162 newctrls = ch_malloc((i+1)*sizeof(LDAPControl *));
164 newctrls = ch_realloc(gs->ctrls,
165 (j+i+1)*sizeof(LDAPControl *));
167 for (k=0; k<i; j++,k++) {
168 newctrls[j] = ch_malloc(sizeof(LDAPControl));
169 *newctrls[j] = *rs->sr_ctrls[k];
170 if ( !BER_BVISNULL( &rs->sr_ctrls[k]->ldctl_value ))
171 ber_dupbv( &newctrls[j]->ldctl_value,
172 &rs->sr_ctrls[k]->ldctl_value );
176 gs->ctrls = newctrls;
183 glue_op_func ( Operation *op, SlapReply *rs )
185 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
186 BackendDB *b0 = op->o_bd;
187 BackendInfo *bi0 = op->o_bd->bd_info;
189 slap_operation_t which = op_bind;
192 op->o_bd = glue_back_select (b0, &op->o_req_ndn);
194 /* If we're on the master backend, let overlay framework handle it */
195 if ( op->o_bd == b0 )
196 return SLAP_CB_CONTINUE;
198 b0->bd_info = on->on_info->oi_orig;
201 case LDAP_REQ_ADD: which = op_add; break;
202 case LDAP_REQ_DELETE: which = op_delete; break;
203 case LDAP_REQ_MODIFY: which = op_modify; break;
204 case LDAP_REQ_MODRDN: which = op_modrdn; break;
205 case LDAP_REQ_EXTENDED: which = op_extended; break;
206 default: assert( 0 ); break;
209 func = &op->o_bd->bd_info->bi_op_bind;
211 rc = func[which]( op, rs );
216 op->o_bd->bd_info = bi0;
221 glue_response ( Operation *op, SlapReply *rs )
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 (get_no_subordinate_glue(op) && btmp != b1)
383 if (tlimit0 != SLAP_NO_LIMIT) {
384 op->o_time = slap_get_time();
385 op->ors_tlimit = stoptime - op->o_time;
386 if (op->ors_tlimit <= 0) {
387 rs->sr_err = gs.err = LDAP_TIMELIMIT_EXCEEDED;
400 assert( op->o_bd->be_suffix != NULL );
401 assert( op->o_bd->be_nsuffix != NULL );
403 if (scope0 == LDAP_SCOPE_ONELEVEL &&
406 op->ors_scope = LDAP_SCOPE_BASE;
407 op->o_req_dn = op->o_bd->be_suffix[0];
408 op->o_req_ndn = op->o_bd->be_nsuffix[0];
409 rs->sr_err = op->o_bd->be_search(op, rs);
410 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
411 gs.err = LDAP_SUCCESS;
413 op->ors_scope = LDAP_SCOPE_ONELEVEL;
417 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
418 dn_match(&op->o_bd->be_nsuffix[0], &ndn))
420 rs->sr_err = glue_sub_search( op, rs, b0, on );
422 } else if (scope0 == LDAP_SCOPE_SUBTREE &&
423 dnIsSuffix(&op->o_bd->be_nsuffix[0], &ndn))
425 op->o_req_dn = op->o_bd->be_suffix[0];
426 op->o_req_ndn = op->o_bd->be_nsuffix[0];
427 rs->sr_err = glue_sub_search( op, rs, b0, on );
428 if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
429 gs.err = LDAP_SUCCESS;
434 } else if (dnIsSuffix(&ndn, &op->o_bd->be_nsuffix[0])) {
435 rs->sr_err = glue_sub_search( op, rs, b0, on );
441 * Add errors that should result in dropping
444 case LDAP_SIZELIMIT_EXCEEDED:
445 case LDAP_TIMELIMIT_EXCEEDED:
446 case LDAP_ADMINLIMIT_EXCEEDED:
447 case LDAP_NO_SUCH_OBJECT:
448 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
449 case LDAP_X_CANNOT_CHAIN:
450 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
458 op->ors_scope = scope0;
459 op->ors_tlimit = tlimit0;
460 op->o_time = starttime;
466 if ( op->o_abandon ) {
467 rs->sr_err = SLAPD_ABANDON;
469 op->o_callback = cb.sc_next;
471 rs->sr_matched = gs.matched;
472 rs->sr_ref = gs.refs;
473 rs->sr_ctrls = gs.ctrls;
475 send_ldap_result( op, rs );
479 op->o_bd->bd_info = bi0;
483 ber_bvarray_free(gs.refs);
485 for (i = gs.nctrls; --i >= 0; ) {
486 if (!BER_BVISNULL( &gs.ctrls[i]->ldctl_value ))
487 free(gs.ctrls[i]->ldctl_value.bv_val);
495 static BackendDB toolDB;
498 glue_tool_entry_open (
503 slap_overinfo *oi = (slap_overinfo *)b0->bd_info;
505 /* We don't know which backend to talk to yet, so just
506 * remember the mode and move on...
512 toolDB.bd_info = oi->oi_orig;
518 glue_tool_entry_close (
525 if (!glueBack->be_entry_close)
527 rc = glueBack->be_entry_close (glueBack);
532 static slap_overinst *
537 slap_overinfo *oi = (slap_overinfo *)bi;
540 for ( on = oi->oi_list; on; on=on->on_next ) {
541 if ( !strcmp( on->on_bi.bi_type, glue.on_bi.bi_type ))
547 /* This function will only be called in tool mode */
553 slap_overinst *on = glue_tool_inst( bi );
554 glueinfo *gi = on->on_bi.bi_private;
555 static int glueOpened = 0;
556 int i, j, same, bsame = 0, rc = 0;
558 if (glueOpened) return 0;
562 /* If we were invoked in tool mode, open all the underlying backends */
563 if (slapMode & SLAP_TOOL_MODE) {
564 for (i = 0; i<gi->gi_nodes; i++) {
566 /* Same bi_open as our main backend? */
567 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
568 on->on_info->oi_orig->bi_open )
571 /* Loop thru the bd_info's and make sure we only
572 * invoke their bi_open functions once each.
574 for ( j = 0; j<i; j++ ) {
575 if ( gi->gi_n[i].gn_be->bd_info->bi_open ==
576 gi->gi_n[j].gn_be->bd_info->bi_open ) {
581 /* OK, it's unique and non-NULL, call it. */
582 if ( !same && gi->gi_n[i].gn_be->bd_info->bi_open )
583 rc = gi->gi_n[i].gn_be->bd_info->bi_open(
584 gi->gi_n[i].gn_be->bd_info );
585 /* Let backend.c take care of the rest of startup */
587 rc = backend_startup_one( gi->gi_n[i].gn_be, NULL );
590 if ( !rc && !bsame && on->on_info->oi_orig->bi_open )
591 rc = on->on_info->oi_orig->bi_open( on->on_info->oi_orig );
593 } /* other case is impossible */
597 /* This function will only be called in tool mode */
603 static int glueClosed = 0;
606 if (glueClosed) return 0;
610 if (slapMode & SLAP_TOOL_MODE) {
611 rc = backend_shutdown( NULL );
621 AttributeDescription *ad,
626 BackendDB *b0 = op->o_bd;
627 op->o_bd = glue_back_select( b0, dn );
629 if ( op->o_bd->be_fetch ) {
630 rc = op->o_bd->be_fetch( op, dn, oc, ad, rw, e );
632 rc = LDAP_UNWILLING_TO_PERFORM;
639 glue_entry_release_rw (
645 BackendDB *b0 = op->o_bd;
648 op->o_bd = glue_back_select (b0, &e->e_nname);
650 if ( op->o_bd->be_release ) {
651 rc = op->o_bd->be_release( op, e, rw );
654 /* FIXME: mimic be_entry_release_rw
655 * when no be_release() available */
665 glue_tool_entry_first (
669 slap_overinst *on = glue_tool_inst( b0->bd_info );
670 glueinfo *gi = on->on_bi.bi_private;
673 /* If we're starting from scratch, start at the most general */
675 if ( toolDB.be_entry_open && toolDB.be_entry_first ) {
678 for (i = gi->gi_nodes-1; i >= 0; i--) {
679 if (gi->gi_n[i].gn_be->be_entry_open &&
680 gi->gi_n[i].gn_be->be_entry_first) {
681 glueBack = gi->gi_n[i].gn_be;
687 if (!glueBack || !glueBack->be_entry_open || !glueBack->be_entry_first ||
688 glueBack->be_entry_open (glueBack, glueMode) != 0)
691 return glueBack->be_entry_first (glueBack);
695 glue_tool_entry_next (
699 slap_overinst *on = glue_tool_inst( b0->bd_info );
700 glueinfo *gi = on->on_bi.bi_private;
704 if (!glueBack || !glueBack->be_entry_next)
707 rc = glueBack->be_entry_next (glueBack);
709 /* If we ran out of entries in one database, move on to the next */
711 if ( glueBack && glueBack->be_entry_close )
712 glueBack->be_entry_close (glueBack);
713 for (i=0; i<gi->gi_nodes; i++) {
714 if (gi->gi_n[i].gn_be == glueBack)
721 glueBack = gi->gi_n[i-1].gn_be;
722 rc = glue_tool_entry_first (b0);
729 glue_tool_entry_get (
734 if (!glueBack || !glueBack->be_entry_get)
737 return glueBack->be_entry_get (glueBack, id);
741 glue_tool_entry_put (
751 b2.bd_info = (BackendInfo *)glue_tool_inst( b0->bd_info );
752 be = glue_back_select (&b2, &e->e_nname);
753 if ( be == &b2 ) be = &toolDB;
755 if (!be->be_entry_put)
759 if ( be->be_entry_open ) {
760 rc = be->be_entry_open (be, glueMode);
765 } else if (be != glueBack) {
766 /* If this entry belongs in a different branch than the
767 * previous one, close the current database and open the
770 if ( glueBack->be_entry_close ) {
771 glueBack->be_entry_close (glueBack);
773 if ( be->be_entry_open ) {
774 rc = be->be_entry_open (be, glueMode);
781 return be->be_entry_put (be, e, text);
785 glue_tool_entry_reindex (
788 AttributeDescription **adv
791 if (!glueBack || !glueBack->be_entry_reindex)
794 return glueBack->be_entry_reindex (glueBack, id, adv);
802 slap_overinst *on = glue_tool_inst( b0->bd_info );
803 glueinfo *gi = on->on_bi.bi_private;
804 BackendInfo *bi = b0->bd_info;
807 /* just sync everyone */
808 for (i = 0; i<gi->gi_nodes; i++)
809 if (gi->gi_n[i].gn_be->be_sync)
810 gi->gi_n[i].gn_be->be_sync (gi->gi_n[i].gn_be);
811 b0->bd_info = on->on_info->oi_orig;
824 slap_overinst *on = (slap_overinst *)be->bd_info;
825 slap_overinfo *oi = on->on_info;
826 BackendInfo *bi = oi->oi_orig;
829 if ( SLAP_GLUE_SUBORDINATE( be )) {
830 Debug( LDAP_DEBUG_ANY, "glue: backend %s is already subordinate, "
831 "cannot have glue overlay!\n",
832 be->be_suffix[0].bv_val, 0, 0 );
836 gi = ch_calloc( 1, sizeof(glueinfo));
837 on->on_bi.bi_private = gi;
838 dnParent( be->be_nsuffix, &gi->gi_pdn );
840 /* Currently the overlay framework doesn't handle these entry points
841 * but we need them....
843 oi->oi_bi.bi_open = glue_open;
844 oi->oi_bi.bi_close = glue_close;
846 /* Only advertise these if the root DB supports them */
847 if ( bi->bi_tool_entry_open )
848 oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
849 if ( bi->bi_tool_entry_close )
850 oi->oi_bi.bi_tool_entry_close = glue_tool_entry_close;
851 if ( bi->bi_tool_entry_first )
852 oi->oi_bi.bi_tool_entry_first = glue_tool_entry_first;
853 if ( bi->bi_tool_entry_next )
854 oi->oi_bi.bi_tool_entry_next = glue_tool_entry_next;
855 if ( bi->bi_tool_entry_get )
856 oi->oi_bi.bi_tool_entry_get = glue_tool_entry_get;
857 if ( bi->bi_tool_entry_put )
858 oi->oi_bi.bi_tool_entry_put = glue_tool_entry_put;
859 if ( bi->bi_tool_entry_reindex )
860 oi->oi_bi.bi_tool_entry_reindex = glue_tool_entry_reindex;
861 if ( bi->bi_tool_sync )
862 oi->oi_bi.bi_tool_sync = glue_tool_sync;
864 /*FIXME : need to add support */
865 oi->oi_bi.bi_tool_dn2id_get = 0;
866 oi->oi_bi.bi_tool_entry_modify = 0;
868 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE;
879 slap_overinst *on = (slap_overinst *)be->bd_info;
880 glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
883 return SLAP_CB_CONTINUE;
892 slap_overinst *on = (slap_overinst *)be->bd_info;
894 on->on_info->oi_bi.bi_db_close = 0;
899 glue_sub_del( BackendDB *b0 )
904 /* Find the top backend for this subordinate */
906 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
912 if ( SLAP_GLUE_SUBORDINATE( be ))
914 if ( !SLAP_GLUE_INSTANCE( be ))
916 if ( !dnIsSuffix( &b0->be_nsuffix[0], &be->be_nsuffix[0] ))
919 /* OK, got the right backend, find the overlay */
920 oi = (slap_overinfo *)be->bd_info;
921 for ( on=oi->oi_list; on; on=on->on_next ) {
922 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
925 assert( on != NULL );
926 gi = on->on_bi.bi_private;
927 for ( i=0; i < gi->gi_nodes; i++ ) {
928 if ( gi->gi_n[i].gn_be == b0 ) {
931 for (j=i+1; j < gi->gi_nodes; j++)
932 gi->gi_n[j-1] = gi->gi_n[j];
939 rc = LDAP_NO_SUCH_OBJECT;
944 typedef struct glue_Addrec {
945 struct glue_Addrec *ga_next;
949 /* List of added subordinates */
950 static glue_Addrec *ga_list;
952 /* Attach all the subordinate backends to their superior */
956 glue_Addrec *ga, *gnext = NULL;
959 /* For all the subordinate backends */
960 for ( ga=ga_list; ga != NULL; ga = gnext ) {
965 /* Find the top backend for this subordinate */
967 while ( (be=LDAP_STAILQ_NEXT( be, be_next )) != NULL ) {
972 if ( SLAP_GLUE_SUBORDINATE( be ))
974 if ( !dnIsSuffix( &ga->ga_be->be_nsuffix[0], &be->be_nsuffix[0] ))
977 /* If it's not already configured, set up the overlay */
978 if ( !SLAP_GLUE_INSTANCE( be )) {
979 rc = overlay_config( be, glue.on_bi.bi_type, -1, NULL );
983 /* Find the overlay instance */
984 oi = (slap_overinfo *)be->bd_info;
985 for ( on=oi->oi_list; on; on=on->on_next ) {
986 if ( on->on_bi.bi_type == glue.on_bi.bi_type )
989 assert( on != NULL );
990 gi = on->on_bi.bi_private;
991 gi = (glueinfo *)ch_realloc( gi, sizeof(glueinfo) +
992 gi->gi_nodes * sizeof(gluenode));
993 gi->gi_n[gi->gi_nodes].gn_be = ga->ga_be;
994 dnParent( &ga->ga_be->be_nsuffix[0],
995 &gi->gi_n[gi->gi_nodes].gn_pdn );
997 on->on_bi.bi_private = gi;
1001 Debug( LDAP_DEBUG_ANY, "glue: no superior found for sub %s!\n",
1002 ga->ga_be->be_suffix[0].bv_val, 0, 0 );
1003 rc = LDAP_NO_SUCH_OBJECT;
1015 glue_sub_add( BackendDB *be, int advert, int online )
1020 if ( overlay_is_inst( be, "glue" )) {
1021 Debug( LDAP_DEBUG_ANY, "glue: backend %s already has glue overlay, "
1022 "cannot be a subordinate!\n",
1023 be->be_suffix[0].bv_val, 0, 0 );
1026 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
1028 SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_ADVERTISE;
1030 ga = ch_malloc( sizeof( glue_Addrec ));
1031 ga->ga_next = ga_list;
1036 rc = glue_sub_attach();
1044 glue.on_bi.bi_type = "glue";
1046 glue.on_bi.bi_db_init = glue_db_init;
1047 glue.on_bi.bi_db_close = glue_db_close;
1048 glue.on_bi.bi_db_destroy = glue_db_destroy;
1050 glue.on_bi.bi_op_search = glue_op_search;
1051 glue.on_bi.bi_op_modify = glue_op_func;
1052 glue.on_bi.bi_op_modrdn = glue_op_func;
1053 glue.on_bi.bi_op_add = glue_op_func;
1054 glue.on_bi.bi_op_delete = glue_op_func;
1055 glue.on_bi.bi_extended = glue_op_func;
1057 glue.on_bi.bi_chk_referrals = glue_chk_referrals;
1058 glue.on_bi.bi_chk_controls = glue_chk_controls;
1059 glue.on_bi.bi_entry_get_rw = glue_entry_get_rw;
1060 glue.on_bi.bi_entry_release_rw = glue_entry_release_rw;
1062 glue.on_response = glue_response;
1064 return overlay_register( &glue );