]> git.sur5r.net Git - openldap/blob - servers/slapd/backglue.c
696ed48bb4e5bb54f0efe85665b8d84b3dd95553
[openldap] / servers / slapd / backglue.c
1 /* backglue.c - backend glue routines */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 /*
9  * Functions to glue a bunch of other backends into a single tree.
10  * All of the glued backends must share a common suffix. E.g., you
11  * can glue o=foo and ou=bar,o=foo but you can't glue o=foo and o=bar.
12  *
13  * This uses the backend structures and routines extensively, but is
14  * not an actual backend of its own. To use it you must add a "subordinate"
15  * keyword to the configuration of other backends. Subordinates will
16  * automatically be connected to their parent backend.
17  *
18  * The purpose of these functions is to allow you to split a single database
19  * into pieces (for load balancing purposes, whatever) but still be able
20  * to treat it as a single database after it's been split. As such, each
21  * of the glued backends should have identical rootdn and rootpw.
22  *
23  * If you need more elaborate configuration, you probably should be using
24  * back-meta instead.
25  *  -- Howard Chu
26  */
27
28 #include "portable.h"
29
30 #include <stdio.h>
31
32 #include <ac/socket.h>
33
34 #define SLAPD_TOOLS
35 #include "slap.h"
36
37 typedef struct gluenode {
38         BackendDB *be;
39         char *pdn;
40 } gluenode;
41
42 typedef struct glueinfo {
43         BackendDB *be;
44         int nodes;
45         gluenode n[1];
46 } glueinfo;
47
48 static int glueMode;
49 static BackendDB *glueBack;
50
51 /* Just like select_backend, but only for our backends */
52 static BackendDB *
53 glue_back_select (
54         BackendDB *be,
55         const char *dn
56 )
57 {
58         glueinfo *gi = (glueinfo *) be->be_private;
59         struct berval bv;
60         int i;
61
62         bv.bv_len = strlen(dn);
63         bv.bv_val = (char *) dn;
64
65         for (i = 0; i<gi->nodes; i++) {
66                 if (dnIsSuffix(&bv, gi->n[i].be->be_nsuffix[0])) {
67                         return gi->n[i].be;
68                 }
69         }
70         return NULL;
71 }
72
73 /* This function will only be called in tool mode */
74 static int
75 glue_back_open (
76         BackendInfo *bi
77 )
78 {
79         int rc = 0;
80         static int glueOpened = 0;
81
82         if (glueOpened) return 0;
83
84         glueOpened = 1;
85
86         /* If we were invoked in tool mode, open all the underlying backends */
87         if (slapMode & SLAP_TOOL_MODE) {
88                 rc = backend_startup (NULL);
89         } /* other case is impossible */
90         return rc;
91 }
92
93 /* This function will only be called in tool mode */
94 static int
95 glue_back_close (
96         BackendInfo *bi
97 )
98 {
99         static int glueClosed = 0;
100         int rc;
101
102         if (glueClosed) return 0;
103
104         glueClosed = 1;
105
106         if (slapMode & SLAP_TOOL_MODE) {
107                 rc = backend_shutdown (NULL);
108         }
109         return rc;
110 }
111
112 static int
113 glue_back_db_open (
114         BackendDB *be
115 )
116 {
117         glueinfo *gi = (glueinfo *)be->be_private;
118         static int glueOpened = 0;
119         int rc = 0;
120
121         if (glueOpened) return 0;
122
123         glueOpened = 1;
124
125         gi->be->be_acl = be->be_acl;
126
127         if (gi->be->bd_info->bi_db_open)
128                 rc = gi->be->bd_info->bi_db_open(gi->be);
129
130         return rc;
131 }
132
133 static int
134 glue_back_db_close (
135         BackendDB *be
136 )
137 {
138         glueinfo *gi = (glueinfo *)be->be_private;
139         static int glueClosed = 0;
140
141         if (glueClosed) return 0;
142
143         glueClosed = 1;
144
145         /* Close the master */
146         if (gi->be->bd_info->bi_db_close)
147                 gi->be->bd_info->bi_db_close( gi->be );
148
149         return 0;
150 }
151
152 static int
153 glue_back_db_destroy (
154         BackendDB *be
155 )
156 {
157         glueinfo *gi = (glueinfo *)be->be_private;
158
159         if (gi->be->bd_info->bi_db_destroy)
160                 gi->be->bd_info->bi_db_destroy( gi->be );
161         free (gi->be);
162         free (gi);
163         return 0;
164 }
165
166 typedef struct glue_state {
167         int err;
168         int nentries;
169         int matchlen;
170         char *matched;
171         int nrefs;
172         struct berval **refs;
173 } glue_state;
174
175 static void
176 glue_back_response (
177         Connection *conn,
178         Operation *op,
179         ber_tag_t tag,
180         ber_int_t msgid,
181         ber_int_t err,
182         const char *matched,
183         const char *text,
184         struct berval **ref,
185         const char *resoid,
186         struct berval *resdata,
187         struct berval *sasldata,
188         LDAPControl **ctrls
189 )
190 {
191         glue_state *gs = op->o_glue;
192
193         if (err == LDAP_SUCCESS || gs->err != LDAP_SUCCESS)
194                 gs->err = err;
195         if (gs->err == LDAP_SUCCESS && gs->matched) {
196                 free (gs->matched);
197                 gs->matchlen = 0;
198         }
199         if (gs->err != LDAP_SUCCESS && matched) {
200                 int len;
201                 len = strlen (matched);
202                 if (len > gs->matchlen) {
203                         if (gs->matched)
204                                 free (gs->matched);
205                         gs->matched = ch_strdup (matched);
206                         gs->matchlen = len;
207                 }
208         }
209         if (ref) {
210                 int i, j, k;
211                 struct berval **new;
212
213                 for (i=0; ref[i]; i++);
214
215                 j = gs->nrefs;
216                 if (!j) {
217                         new = ch_malloc ((i+1)*sizeof(struct berval *));
218                 } else {
219                         new = ch_realloc(gs->refs,
220                                 (j+i+1)*sizeof(struct berval *));
221                 }
222                 for (k=0; k<i; j++,k++) {
223                         new[j] = ber_bvdup(ref[k]);
224                 }
225                 new[j] = NULL;
226                 gs->nrefs = j;
227                 gs->refs = new;
228         }
229 }
230
231 static void
232 glue_back_sresult (
233         Connection *c,
234         Operation *op,
235         ber_int_t err,
236         const char *matched,
237         const char *text,
238         struct berval **refs,
239         LDAPControl **ctrls,
240         int nentries
241 )
242 {
243         glue_state *gs = op->o_glue;
244
245         gs->nentries += nentries;
246         glue_back_response (c, op, 0, 0, err, matched, text, refs,
247                             NULL, NULL, NULL, ctrls);
248 }
249
250 static int
251 glue_back_search (
252         BackendDB *b0,
253         Connection *conn,
254         Operation *op,
255         const char *dn,
256         const char *ndn,
257         int scope,
258         int deref,
259         int slimit,
260         int tlimit,
261         Filter *filter,
262         const char *filterstr,
263         char **attrs,
264         int attrsonly
265 )
266 {
267         glueinfo *gi = (glueinfo *)b0->be_private;
268         BackendDB *be;
269         int i, rc, t2limit = 0, s2limit = 0;
270         long stoptime = 0;
271         glue_state gs = {0};
272         struct berval bv;
273
274
275         if (tlimit)
276                 stoptime = slap_get_time () + tlimit;
277
278         switch (scope) {
279         case LDAP_SCOPE_BASE:
280                 be = glue_back_select (b0, ndn);
281
282                 if (be && be->be_search) {
283                         rc = be->be_search (be, conn, op, dn, ndn, scope,
284                                    deref, slimit, tlimit, filter, filterstr,
285                                             attrs, attrsonly);
286                 } else {
287                         rc = LDAP_UNWILLING_TO_PERFORM;
288                         send_ldap_result (conn, op, rc, NULL,
289                                       "No search target found", NULL, NULL);
290                 }
291                 return rc;
292
293         case LDAP_SCOPE_ONELEVEL:
294         case LDAP_SCOPE_SUBTREE:
295                 op->o_glue = &gs;
296                 op->o_sresult = glue_back_sresult;
297                 op->o_response = glue_back_response;
298                 bv.bv_len = strlen(ndn);
299                 bv.bv_val = (char *) ndn;
300
301                 /*
302                  * Execute in reverse order, most general first 
303                  */
304                 for (i = gi->nodes-1; i >= 0; i--) {
305                         if (!gi->n[i].be || !gi->n[i].be->be_search)
306                                 continue;
307                         if (tlimit) {
308                                 t2limit = stoptime - slap_get_time ();
309                                 if (t2limit <= 0)
310                                         break;
311                         }
312                         if (slimit) {
313                                 s2limit = slimit - gs.nentries;
314                                 if (s2limit <= 0)
315                                         break;
316                         }
317                         /*
318                          * check for abandon 
319                          */
320                         ldap_pvt_thread_mutex_lock (&op->o_abandonmutex);
321                         rc = op->o_abandon;
322                         ldap_pvt_thread_mutex_unlock (&op->o_abandonmutex);
323                         if (rc) {
324                                 rc = 0;
325                                 goto done;
326                         }
327                         be = gi->n[i].be;
328                         if (scope == LDAP_SCOPE_ONELEVEL && 
329                                 !strcmp (gi->n[i].pdn, ndn)) {
330                                 rc = be->be_search (be, conn, op,
331                                                     be->be_suffix[0],
332                                                     be->be_nsuffix[0]->bv_val,
333                                                     LDAP_SCOPE_BASE, deref,
334                                         s2limit, t2limit, filter, filterstr,
335                                                     attrs, attrsonly);
336                         } else if (scope == LDAP_SCOPE_SUBTREE &&
337                                 dnIsSuffix(be->be_nsuffix[0], &bv)) {
338                                 rc = be->be_search (be, conn, op,
339                                                     be->be_suffix[0],
340                                                     be->be_nsuffix[0]->bv_val,
341                                                     scope, deref,
342                                         s2limit, t2limit, filter, filterstr,
343                                                     attrs, attrsonly);
344                         } else if (dnIsSuffix(&bv, be->be_nsuffix[0])) {
345                                 rc = be->be_search (be, conn, op,
346                                                     dn, ndn, scope, deref,
347                                         s2limit, t2limit, filter, filterstr,
348                                                     attrs, attrsonly);
349                         }
350                 }
351                 break;
352         }
353         op->o_sresult = NULL;
354         op->o_response = NULL;
355         op->o_glue = NULL;
356
357         send_search_result (conn, op, gs.err, gs.matched, NULL, gs.refs,
358                             NULL, gs.nentries);
359 done:
360         if (gs.matched)
361                 free (gs.matched);
362         if (gs.refs)
363                 ber_bvecfree(gs.refs);
364         return rc;
365 }
366
367 static int
368 glue_back_bind (
369         BackendDB *b0,
370         Connection *conn,
371         Operation *op,
372         const char *dn,
373         const char *ndn,
374         int method,
375         struct berval *cred,
376         char **edn
377 )
378 {
379         BackendDB *be;
380         int rc;
381  
382         be = glue_back_select (b0, ndn);
383
384         if (be && be->be_bind) {
385                 conn->c_authz_backend = be;
386                 rc = be->be_bind (be, conn, op, dn, ndn, method, cred, edn);
387         } else {
388                 rc = LDAP_UNWILLING_TO_PERFORM;
389                 send_ldap_result (conn, op, rc, NULL, "No bind target found",
390                                   NULL, NULL);
391         }
392         return rc;
393 }
394
395 static int
396 glue_back_compare (
397         BackendDB *b0,
398         Connection *conn,
399         Operation *op,
400         const char *dn,
401         const char *ndn,
402         AttributeAssertion *ava
403 )
404 {
405         BackendDB *be;
406         int rc;
407
408         be = glue_back_select (b0, ndn);
409
410         if (be && be->be_compare) {
411                 rc = be->be_compare (be, conn, op, dn, ndn, ava);
412         } else {
413                 rc = LDAP_UNWILLING_TO_PERFORM;
414                 send_ldap_result (conn, op, rc, NULL, "No compare target found",
415                                   NULL, NULL);
416         }
417         return rc;
418 }
419
420 static int
421 glue_back_modify (
422         BackendDB *b0,
423         Connection *conn,
424         Operation *op,
425         const char *dn,
426         const char *ndn,
427         Modifications *mod
428 )
429 {
430         BackendDB *be;
431         int rc;
432
433         be = glue_back_select (b0, ndn);
434
435         if (be && be->be_modify) {
436                 rc = be->be_modify (be, conn, op, dn, ndn, mod);
437         } else {
438                 rc = LDAP_UNWILLING_TO_PERFORM;
439                 send_ldap_result (conn, op, rc, NULL, "No modify target found",
440                                   NULL, NULL);
441         }
442         return rc;
443 }
444
445 static int
446 glue_back_modrdn (
447         BackendDB *b0,
448         Connection *conn,
449         Operation *op,
450         const char *dn,
451         const char *ndn,
452         const char *newrdn,
453         int del,
454         const char *newsup
455 )
456 {
457         BackendDB *be;
458         int rc;
459
460         be = glue_back_select (b0, ndn);
461
462         if (be && be->be_modrdn) {
463                 rc = be->be_modrdn (be, conn, op, dn, ndn, newrdn, del, newsup);
464         } else {
465                 rc = LDAP_UNWILLING_TO_PERFORM;
466                 send_ldap_result (conn, op, rc, NULL, "No modrdn target found",
467                                   NULL, NULL);
468         }
469         return rc;
470 }
471
472 static int
473 glue_back_add (
474         BackendDB *b0,
475         Connection *conn,
476         Operation *op,
477         Entry *e
478 )
479 {
480         BackendDB *be;
481         int rc;
482
483         be = glue_back_select (b0, e->e_ndn);
484
485         if (be && be->be_add) {
486                 rc = be->be_add (be, conn, op, e);
487         } else {
488                 rc = LDAP_UNWILLING_TO_PERFORM;
489                 send_ldap_result (conn, op, rc, NULL, "No add target found",
490                                   NULL, NULL);
491         }
492         return rc;
493 }
494
495 static int
496 glue_back_delete (
497         BackendDB *b0,
498         Connection *conn,
499         Operation *op,
500         const char *dn,
501         const char *ndn
502 )
503 {
504         BackendDB *be;
505         int rc;
506
507         be = glue_back_select (b0, ndn);
508
509         if (be && be->be_delete) {
510                 rc = be->be_delete (be, conn, op, dn, ndn);
511         } else {
512                 rc = LDAP_UNWILLING_TO_PERFORM;
513                 send_ldap_result (conn, op, rc, NULL, "No delete target found",
514                                   NULL, NULL);
515         }
516         return rc;
517 }
518
519 static int
520 glue_back_release_rw (
521         BackendDB *b0,
522         Connection *conn,
523         Operation *op,
524         Entry *e,
525         int rw
526 )
527 {
528         BackendDB *be;
529         int rc;
530
531         be = glue_back_select (b0, e->e_ndn);
532
533         if (be && be->be_release) {
534                 rc = be->be_release (be, conn, op, e, rw);
535         } else {
536                 entry_free (e);
537                 rc = 0;
538         }
539         return rc;
540 }
541
542 static int
543 glue_back_group (
544         BackendDB *b0,
545         Connection *conn,
546         Operation *op,
547         Entry *target,
548         const char *ndn,
549         const char *ondn,
550         ObjectClass *oc,
551         AttributeDescription * ad
552 )
553 {
554         BackendDB *be;
555         int rc;
556
557         be = glue_back_select (b0, ndn);
558
559         if (be && be->be_group) {
560                 rc = be->be_group (be, conn, op, target, ndn, ondn, oc, ad);
561         } else {
562                 rc = LDAP_UNWILLING_TO_PERFORM;
563         }
564         return rc;
565 }
566
567 static int
568 glue_back_attribute (
569         BackendDB *b0,
570         Connection *conn,
571         Operation *op,
572         Entry *target,
573         const char *ndn,
574         AttributeDescription *ad,
575         struct berval ***vals
576 )
577 {
578         BackendDB *be;
579         int rc;
580
581         be = glue_back_select (b0, ndn);
582
583         if (be && be->be_attribute) {
584                 rc = be->be_attribute (be, conn, op, target, ndn, ad, vals);
585         } else {
586                 rc = LDAP_UNWILLING_TO_PERFORM;
587         }
588         return rc;
589 }
590
591 static int
592 glue_back_referrals (
593         BackendDB *b0,
594         Connection *conn,
595         Operation *op,
596         const char *dn,
597         const char *ndn,
598         const char **text
599 )
600 {
601         BackendDB *be;
602         int rc;
603
604         be = glue_back_select (b0, ndn);
605
606         if (be && be->be_chk_referrals) {
607                 rc = be->be_chk_referrals (be, conn, op, dn, ndn, text);
608         } else {
609                 rc = LDAP_SUCCESS;;
610         }
611         return rc;
612 }
613
614 static int
615 glue_tool_entry_open (
616         BackendDB *b0,
617         int mode
618 )
619 {
620         /* We don't know which backend to talk to yet, so just
621          * remember the mode and move on...
622          */
623
624         glueMode = mode;
625         glueBack = NULL;
626
627         return 0;
628 }
629
630 static int
631 glue_tool_entry_close (
632         BackendDB *b0
633 )
634 {
635         int rc = 0;
636
637         if (glueBack) {
638                 if (!glueBack->be_entry_close)
639                         return 0;
640                 rc = glueBack->be_entry_close (glueBack);
641         }
642         return rc;
643 }
644
645 static ID
646 glue_tool_entry_first (
647         BackendDB *b0
648 )
649 {
650         glueinfo *gi = (glueinfo *) b0->be_private;
651         int i;
652
653         /* If we're starting from scratch, start at the most general */
654         if (!glueBack) {
655                 for (i = gi->nodes-1; i >= 0; i--) {
656                         if (gi->n[i].be->be_entry_open &&
657                             gi->n[i].be->be_entry_first) {
658                                 glueBack = gi->n[i].be;
659                                 break;
660                         }
661                 }
662
663         }
664         if (!glueBack || glueBack->be_entry_open (glueBack, glueMode) != 0)
665                 return NOID;
666
667         return glueBack->be_entry_first (glueBack);
668 }
669
670 static ID
671 glue_tool_entry_next (
672         BackendDB *b0
673 )
674 {
675         glueinfo *gi = (glueinfo *) b0->be_private;
676         int i;
677         ID rc;
678
679         if (!glueBack || !glueBack->be_entry_next)
680                 return NOID;
681
682         rc = glueBack->be_entry_next (glueBack);
683
684         /* If we ran out of entries in one database, move on to the next */
685         if (rc == NOID) {
686                 glueBack->be_entry_close (glueBack);
687                 for (i=0; i<gi->nodes; i++) {
688                         if (gi->n[i].be == glueBack)
689                                 break;
690                 }
691                 if (i == 0) {
692                         glueBack = NULL;
693                         rc = NOID;
694                 } else {
695                         glueBack = gi->n[i-1].be;
696                         rc = glue_tool_entry_first (b0);
697                 }
698         }
699         return rc;
700 }
701
702 static Entry *
703 glue_tool_entry_get (
704         BackendDB *b0,
705         ID id
706 )
707 {
708         if (!glueBack || !glueBack->be_entry_get)
709                 return NULL;
710
711         return glueBack->be_entry_get (glueBack, id);
712 }
713
714 static ID
715 glue_tool_entry_put (
716         BackendDB *b0,
717         Entry *e
718 )
719 {
720         BackendDB *be;
721         int rc;
722
723         be = glue_back_select (b0, e->e_ndn);
724         if (!be->be_entry_put)
725                 return NOID;
726
727         if (!glueBack) {
728                 rc = be->be_entry_open (be, glueMode);
729                 if (rc != 0)
730                         return NOID;
731         } else if (be != glueBack) {
732                 /* If this entry belongs in a different branch than the
733                  * previous one, close the current database and open the
734                  * new one.
735                  */
736                 glueBack->be_entry_close (glueBack);
737                 rc = be->be_entry_open (be, glueMode);
738                 if (rc != 0)
739                         return NOID;
740         }
741         glueBack = be;
742         return be->be_entry_put (be, e);
743 }
744
745 static int
746 glue_tool_entry_reindex (
747         BackendDB *b0,
748         ID id
749 )
750 {
751         if (!glueBack || !glueBack->be_entry_reindex)
752                 return -1;
753
754         return glueBack->be_entry_reindex (glueBack, id);
755 }
756
757 static int
758 glue_tool_sync (
759         BackendDB *b0
760 )
761 {
762         glueinfo *gi = (glueinfo *) b0->be_private;
763         int i;
764
765         /* just sync everyone */
766         for (i = 0; b0->be_nsuffix[i]; i++)
767                 if (gi->n[i].be->be_sync)
768                         gi->n[i].be->be_sync (gi->n[i].be);
769         return 0;
770 }
771
772 int
773 glue_sub_init( )
774 {
775         int i, j;
776         int cont = num_subs;
777         BackendDB *b1, *be;
778         BackendInfo *bi;
779         glueinfo *gi;
780
781         /* While there are subordinate backends, search backwards through the
782          * backends and connect them to their superior.
783          */
784         for (i = nBackendDB - 1, b1=&backendDB[i]; cont && i>=0; b1--,i--) {
785                 if (b1->be_glueflags & SLAP_GLUE_SUBORDINATE) {
786                         /* The last database cannot be a subordinate of noone */
787                         if (i == nBackendDB - 1)
788                                 b1->be_glueflags ^= SLAP_GLUE_SUBORDINATE;
789                         continue;
790                 }
791                 gi = NULL;
792                 for (j = i-1, be=&backendDB[j]; j>=0; be--,j--) {
793                         if (!(be->be_glueflags & SLAP_GLUE_SUBORDINATE))
794                                 continue;
795                         /* We will only link it once */
796                         if (be->be_glueflags & SLAP_GLUE_LINKED)
797                                 continue;
798                         if (!dnIsSuffix(be->be_nsuffix[0],
799                                 b1->be_nsuffix[0]))
800                                 continue;
801                         cont--;
802                         be->be_glueflags |= SLAP_GLUE_LINKED;
803                         if (gi == NULL) {
804                                 /* We create a copy of the superior's be
805                                  * structure, pointing to all of its original
806                                  * information. Then we replace elements of
807                                  * the superior's info with our own. The copy
808                                  * is used whenever we have operations to pass
809                                  * down to the real database.
810                                  */
811                                 b1->be_glueflags |= SLAP_GLUE_INSTANCE;
812                                 gi = (glueinfo *)ch_malloc(sizeof(glueinfo));
813                                 gi->be = (BackendDB *)ch_malloc(sizeof(BackendDB) + sizeof(BackendInfo));
814                                 bi = (BackendInfo *)(gi->be+1);
815                                 *gi->be = *b1;
816                                 gi->nodes = 0;
817                                 *bi = *b1->bd_info;
818                                 bi->bi_open = glue_back_open;
819                                 bi->bi_close = glue_back_close;
820                                 bi->bi_db_open = glue_back_db_open;
821                                 bi->bi_db_close = glue_back_db_close;
822                                 bi->bi_db_destroy = glue_back_db_destroy;
823
824                                 bi->bi_op_bind = glue_back_bind;
825                                 bi->bi_op_search = glue_back_search;
826                                 bi->bi_op_compare = glue_back_compare;
827                                 bi->bi_op_modify = glue_back_modify;
828                                 bi->bi_op_modrdn = glue_back_modrdn;
829                                 bi->bi_op_add = glue_back_add;
830                                 bi->bi_op_delete = glue_back_delete;
831
832                                 bi->bi_entry_release_rw = glue_back_release_rw;
833                                 bi->bi_acl_group = glue_back_group;
834                                 bi->bi_acl_attribute = glue_back_attribute;
835                                 bi->bi_chk_referrals = glue_back_referrals;
836
837                                 /*
838                                  * hooks for slap tools
839                                  */
840                                 bi->bi_tool_entry_open = glue_tool_entry_open;
841                                 bi->bi_tool_entry_close = glue_tool_entry_close;
842                                 bi->bi_tool_entry_first = glue_tool_entry_first;
843                                 bi->bi_tool_entry_next = glue_tool_entry_next;
844                                 bi->bi_tool_entry_get = glue_tool_entry_get;
845                                 bi->bi_tool_entry_put = glue_tool_entry_put;
846                                 bi->bi_tool_entry_reindex = glue_tool_entry_reindex;
847                                 bi->bi_tool_sync = glue_tool_sync;
848                         } else {
849                                 gi = (glueinfo *)ch_realloc(gi,
850                                         sizeof(glueinfo) +
851                                         gi->nodes * sizeof(gluenode));
852                         }
853                         gi->n[gi->nodes].be = be;
854                         gi->n[gi->nodes].pdn = dn_parent(NULL,
855                                 be->be_nsuffix[0]->bv_val);
856                         gi->nodes++;
857                 }
858                 if (gi) {
859                         /* One more node for the master */
860                         gi = (glueinfo *)ch_realloc(gi,
861                                 sizeof(glueinfo) + gi->nodes * sizeof(gluenode));
862                         gi->n[gi->nodes].be = gi->be;
863                         gi->n[gi->nodes].pdn = dn_parent(NULL,
864                                 b1->be_nsuffix[0]->bv_val);
865                         gi->nodes++;
866                         b1->be_private = gi;
867                         b1->bd_info = bi;
868                 }
869         }
870         /* If there are any unresolved subordinates left, something is wrong */
871         return cont;
872 }