]> git.sur5r.net Git - openldap/blob - servers/slapd/backglue.c
d093521bd9358d83a678135521a6ca8dc7f7db93
[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 (dn_issuffixbv (&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 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 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 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 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                                 dn_issuffixbv (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 (dn_issuffixbv (&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 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 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 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 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 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 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 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 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 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 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 glue_tool_entry_open (
615         BackendDB *b0,
616         int mode
617 )
618 {
619         /* We don't know which backend to talk to yet, so just
620          * remember the mode and move on...
621          */
622
623         glueMode = mode;
624         glueBack = NULL;
625
626         return 0;
627 }
628
629 int
630 glue_tool_entry_close (
631         BackendDB *b0
632 )
633 {
634         int rc = 0;
635
636         if (glueBack) {
637                 if (!glueBack->be_entry_close)
638                         return 0;
639                 rc = glueBack->be_entry_close (glueBack);
640         }
641         return rc;
642 }
643
644 ID
645 glue_tool_entry_first (
646         BackendDB *b0
647 )
648 {
649         glueinfo *gi = (glueinfo *) b0->be_private;
650         int i;
651
652         /* If we're starting from scratch, start at the most general */
653         if (!glueBack) {
654                 for (i = gi->nodes-1; i >= 0; i--) {
655                         if (gi->n[i].be->be_entry_open &&
656                             gi->n[i].be->be_entry_first) {
657                                 glueBack = gi->n[i].be;
658                                 break;
659                         }
660                 }
661
662         }
663         if (!glueBack || glueBack->be_entry_open (glueBack, glueMode) != 0)
664                 return NOID;
665
666         return glueBack->be_entry_first (glueBack);
667 }
668
669 ID
670 glue_tool_entry_next (
671         BackendDB *b0
672 )
673 {
674         glueinfo *gi = (glueinfo *) b0->be_private;
675         int i;
676         ID rc;
677
678         rc = glueBack->be_entry_next (glueBack);
679
680         /* If we ran out of entries in one database, move on to the next */
681         if (rc == NOID) {
682                 glueBack->be_entry_close (glueBack);
683                 for (i=0; i<gi->nodes; i++) {
684                         if (gi->n[i].be == glueBack)
685                                 break;
686                 }
687                 if (i == 0) {
688                         glueBack = NULL;
689                         rc = NOID;
690                 } else {
691                         glueBack = gi->n[i-1].be;
692                         rc = glue_tool_entry_first (b0);
693                 }
694         }
695         return rc;
696 }
697
698 Entry *
699 glue_tool_entry_get (
700         BackendDB *b0,
701         ID id
702 )
703 {
704         return glueBack->be_entry_get (glueBack, id);
705 }
706
707 ID
708 glue_tool_entry_put (
709         BackendDB *b0,
710         Entry *e
711 )
712 {
713         BackendDB *be;
714         int rc;
715
716         be = glue_back_select (b0, e->e_ndn);
717         if (!be->be_entry_put)
718                 return NOID;
719
720         if (!glueBack) {
721                 rc = be->be_entry_open (be, glueMode);
722                 if (rc != 0)
723                         return NOID;
724         } else if (be != glueBack) {
725                 /* If this entry belongs in a different branch than the
726                  * previous one, close the current database and open the
727                  * new one.
728                  */
729                 glueBack->be_entry_close (glueBack);
730                 rc = be->be_entry_open (be, glueMode);
731                 if (rc != 0)
732                         return NOID;
733         }
734         glueBack = be;
735         return be->be_entry_put (be, e);
736 }
737
738 int
739 glue_tool_entry_reindex (
740         BackendDB *b0,
741         ID id
742 )
743 {
744         if (!glueBack->be_entry_reindex)
745                 return -1;
746
747         return glueBack->be_entry_reindex (glueBack, id);
748 }
749
750 int
751 glue_tool_sync (
752         BackendDB *b0
753 )
754 {
755         glueinfo *gi = (glueinfo *) b0->be_private;
756         int i;
757
758         /* just sync everyone */
759         for (i = 0; b0->be_nsuffix[i]; i++)
760                 if (gi->n[i].be->be_sync)
761                         gi->n[i].be->be_sync (gi->n[i].be);
762         return 0;
763 }
764
765 extern int num_subs;    /* config.c */
766
767 int
768 glue_sub_init( )
769 {
770         int i, j, k;
771         int cont = num_subs;
772         BackendDB *b1, *be;
773         BackendInfo *bi;
774         glueinfo *gi;
775
776         /* While there are subordinate backends, search backwards through the
777          * backends and connect them to their superior.
778          */
779         for (i = nBackendDB - 1, b1=&backendDB[i]; cont && i>=0; b1--,i--) {
780                 if (b1->be_glueflags & SLAP_GLUE_SUBORDINATE) {
781                         /* The last database cannot be a subordinate of noone */
782                         if (i == nBackendDB - 1)
783                                 b1->be_glueflags ^= SLAP_GLUE_SUBORDINATE;
784                         continue;
785                 }
786                 gi = NULL;
787                 for (j = i-1, be=&backendDB[j]; j>=0; be--,j--) {
788                         if (!(be->be_glueflags & SLAP_GLUE_SUBORDINATE))
789                                 continue;
790                         /* We will only link it once */
791                         if (be->be_glueflags & SLAP_GLUE_LINKED)
792                                 continue;
793                         if (!dn_issuffixbv(be->be_nsuffix[0],
794                                 b1->be_nsuffix[0]))
795                                 continue;
796                         cont--;
797                         be->be_glueflags |= SLAP_GLUE_LINKED;
798                         if (gi == NULL) {
799                                 /* We create a copy of the superior's be
800                                  * structure, pointing to all of its original
801                                  * information. Then we replace elements of
802                                  * the superior's info with our own. The copy
803                                  * is used whenever we have operations to pass
804                                  * down to the real database.
805                                  */
806                                 b1->be_glueflags |= SLAP_GLUE_INSTANCE;
807                                 gi = (glueinfo *)ch_malloc(sizeof(glueinfo));
808                                 gi->be = (BackendDB *)ch_malloc(sizeof(BackendDB) + sizeof(BackendInfo));
809                                 bi = (BackendInfo *)(gi->be+1);
810                                 *gi->be = *b1;
811                                 gi->nodes = 0;
812                                 *bi = *b1->bd_info;
813                                 bi->bi_open = glue_back_open;
814                                 bi->bi_close = glue_back_close;
815                                 bi->bi_db_open = glue_back_db_open;
816                                 bi->bi_db_close = glue_back_db_close;
817                                 bi->bi_db_destroy = glue_back_db_destroy;
818
819                                 bi->bi_op_bind = glue_back_bind;
820                                 bi->bi_op_search = glue_back_search;
821                                 bi->bi_op_compare = glue_back_compare;
822                                 bi->bi_op_modify = glue_back_modify;
823                                 bi->bi_op_modrdn = glue_back_modrdn;
824                                 bi->bi_op_add = glue_back_add;
825                                 bi->bi_op_delete = glue_back_delete;
826
827                                 bi->bi_entry_release_rw = glue_back_release_rw;
828                                 bi->bi_acl_group = glue_back_group;
829                                 bi->bi_acl_attribute = glue_back_attribute;
830                                 bi->bi_chk_referrals = glue_back_referrals;
831
832                                 /*
833                                  * hooks for slap tools
834                                  */
835                                 bi->bi_tool_entry_open = glue_tool_entry_open;
836                                 bi->bi_tool_entry_close = glue_tool_entry_close;
837                                 bi->bi_tool_entry_first = glue_tool_entry_first;
838                                 bi->bi_tool_entry_next = glue_tool_entry_next;
839                                 bi->bi_tool_entry_get = glue_tool_entry_get;
840                                 bi->bi_tool_entry_put = glue_tool_entry_put;
841                                 bi->bi_tool_entry_reindex = glue_tool_entry_reindex;
842                                 bi->bi_tool_sync = glue_tool_sync;
843                         } else {
844                                 gi = (glueinfo *)ch_realloc(gi,
845                                         sizeof(glueinfo) +
846                                         gi->nodes * sizeof(gluenode));
847                         }
848                         gi->n[gi->nodes].be = be;
849                         gi->n[gi->nodes].pdn = dn_parent(NULL,
850                                 be->be_nsuffix[0]->bv_val);
851                         gi->nodes++;
852                 }
853                 if (gi) {
854                         /* One more node for the master */
855                         gi = (glueinfo *)ch_realloc(gi,
856                                 sizeof(glueinfo) + gi->nodes * sizeof(gluenode));
857                         gi->n[gi->nodes].be = gi->be;
858                         gi->n[gi->nodes].pdn = dn_parent(NULL,
859                                 b1->be_nsuffix[0]->bv_val);
860                         gi->nodes++;
861                         b1->be_private = gi;
862                         b1->bd_info = bi;
863                 }
864         }
865         /* If there are any unresolved subordinates left, something is wrong */
866         return cont;
867 }