]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/search.c
001567081639891fb081bf79e65b8ff9cde14508
[openldap] / servers / slapd / back-ldap / search.c
1 /* search.c - ldap backend search function */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7 /* This is an altered version */
8 /*
9  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
10  * 
11  * Permission is granted to anyone to use this software for any purpose
12  * on any computer system, and to alter it and redistribute it, subject
13  * to the following restrictions:
14  * 
15  * 1. The author is not responsible for the consequences of use of this
16  *    software, no matter how awful, even if they arise from flaws in it.
17  * 
18  * 2. The origin of this software must not be misrepresented, either by
19  *    explicit claim or by omission.  Since few users ever read sources,
20  *    credits should appear in the documentation.
21  * 
22  * 3. Altered versions must be plainly marked as such, and must not be
23  *    misrepresented as being the original software.  Since few users
24  *    ever read sources, credits should appear in the documentation.
25  * 
26  * 4. This notice may not be removed or altered.
27  *
28  *
29  *
30  * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
31  * 
32  * This software is being modified by Pierangelo Masarati.
33  * The previously reported conditions apply to the modified code as well.
34  * Changes in the original code are highlighted where required.
35  * Credits for the original code go to the author, Howard Chu.
36  */
37
38 #include "portable.h"
39
40 #include <stdio.h>
41
42 #include <ac/socket.h>
43 #include <ac/string.h>
44 #include <ac/time.h>
45
46 #include "slap.h"
47 #include "back-ldap.h"
48 #undef ldap_debug       /* silence a warning in ldap-int.h */
49 #include "../../../libraries/libldap/ldap-int.h"
50
51 #include "lutil.h"
52
53 static int
54 ldap_build_entry( Operation *op, LDAPMessage *e, Entry *ent,
55          struct berval *bdn, int flags );
56 #define LDAP_BUILD_ENTRY_PRIVATE        0x01
57 #define LDAP_BUILD_ENTRY_NORMALIZE      0x02
58
59 static struct berval dummy = { 0, NULL };
60
61 int
62 ldap_back_search(
63     Operation   *op,
64     SlapReply *rs )
65 {
66         struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;
67         struct ldapconn *lc;
68         struct timeval  tv;
69         LDAPMessage             *res, *e;
70         int     rc = 0, msgid; 
71         struct berval match = { 0, NULL };
72         char **mapped_attrs = NULL;
73         struct berval mbase;
74         struct berval mfilter = { 0, NULL };
75         struct slap_limits_set *limit = NULL;
76         int isroot = 0;
77         dncookie dc;
78
79         lc = ldap_back_getconn(op, rs);
80         if ( !lc ) {
81                 return( -1 );
82         }
83
84         /*
85          * FIXME: in case of values return filter, we might want
86          * to map attrs and maybe rewrite value
87          */
88         if ( !ldap_back_dobind( lc, op, rs ) ) {
89                 return( -1 );
90         }
91
92         /* if not root, get appropriate limits */
93         if ( be_isroot( op->o_bd, &op->o_ndn ) ) {
94                 isroot = 1;
95         } else {
96                 ( void ) get_limits( op->o_bd, &op->o_ndn, &limit );
97         }
98         
99         /* if no time limit requested, rely on remote server limits */
100         /* if requested limit higher than hard limit, abort */
101         if ( !isroot && op->oq_search.rs_tlimit > limit->lms_t_hard ) {
102                 /* no hard limit means use soft instead */
103                 if ( limit->lms_t_hard == 0
104                                 && limit->lms_t_soft > -1
105                                 && op->oq_search.rs_tlimit > limit->lms_t_soft ) {
106                         op->oq_search.rs_tlimit = limit->lms_t_soft;
107                         
108                 /* positive hard limit means abort */
109                 } else if ( limit->lms_t_hard > 0 ) {
110                         rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
111                         rc = 0;
112                         goto finish;
113                 }
114                 
115                 /* negative hard limit means no limit */
116         }
117         
118         /* if no size limit requested, rely on remote server limits */
119         /* if requested limit higher than hard limit, abort */
120         if ( !isroot && op->oq_search.rs_slimit > limit->lms_s_hard ) {
121                 /* no hard limit means use soft instead */
122                 if ( limit->lms_s_hard == 0
123                                 && limit->lms_s_soft > -1
124                                 && op->oq_search.rs_slimit > limit->lms_s_soft ) {
125                         op->oq_search.rs_slimit = limit->lms_s_soft;
126                         
127                 /* positive hard limit means abort */
128                 } else if ( limit->lms_s_hard > 0 ) {
129                         rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
130                         rc = 0;
131                         goto finish;
132                 }
133                 
134                 /* negative hard limit means no limit */
135         }
136
137         /* should we check return values? */
138         if (op->oq_search.rs_deref != -1)
139                 ldap_set_option( lc->ld, LDAP_OPT_DEREF, (void *)&op->oq_search.rs_deref);
140         if (op->oq_search.rs_tlimit != -1) {
141                 tv.tv_sec = op->oq_search.rs_tlimit;
142                 tv.tv_usec = 0;
143         } else {
144                 tv.tv_sec = 0;
145         }
146
147         /*
148          * Rewrite the search base, if required
149          */
150         dc.rwmap = &li->rwmap;
151 #ifdef ENABLE_REWRITE
152         dc.conn = op->o_conn;
153         dc.rs = rs;
154         dc.ctx = "searchBase";
155 #else
156         dc.tofrom = 1;
157         dc.normalized = 0;
158 #endif
159         if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mbase ) ) {
160                 send_ldap_result( op, rs );
161                 return -1;
162         }
163
164         rc = ldap_back_filter_map_rewrite( &dc, op->oq_search.rs_filter,
165                         &mfilter, BACKLDAP_MAP );
166
167         if ( rc ) {
168                 rs->sr_err = LDAP_OTHER;
169                 rs->sr_text = "Rewrite error";
170                 rc = -1;
171                 goto finish;
172         }
173
174         rs->sr_err = ldap_back_map_attrs( &li->rwmap.rwm_at,
175                         op->oq_search.rs_attrs,
176                         BACKLDAP_MAP, &mapped_attrs );
177         if ( rs->sr_err ) {
178                 rc = -1;
179                 goto finish;
180         }
181
182 #if 0
183         if ( mapped_attrs == NULL && op->oq_search.rs_attrs) {
184                 int count;
185
186                 /* this can happen only if ch_calloc() fails
187                  * in ldap_back_map_attrs() */
188                 for (count=0; op->oq_search.rs_attrs[count].an_name.bv_val; count++);
189                 mapped_attrs = ch_malloc( (count+1) * sizeof(char *));
190                 for (count=0; op->oq_search.rs_attrs[count].an_name.bv_val; count++) {
191                         mapped_attrs[count] = op->oq_search.rs_attrs[count].an_name.bv_val;
192                 }
193                 mapped_attrs[count] = NULL;
194         }
195 #endif
196
197         rs->sr_err = ldap_search_ext(lc->ld, mbase.bv_val,
198                         op->oq_search.rs_scope, mfilter.bv_val,
199                         mapped_attrs, op->oq_search.rs_attrsonly,
200                         op->o_ctrls, NULL,
201                         tv.tv_sec ? &tv : NULL, op->oq_search.rs_slimit,
202                         &msgid);
203         if ( rs->sr_err != LDAP_SUCCESS ) {
204 fail:;
205                 rc = ldap_back_op_result(lc, op, rs, msgid, 0);
206                 goto finish;
207         }
208
209         /* We pull apart the ber result, stuff it into a slapd entry, and
210          * let send_search_entry stuff it back into ber format. Slow & ugly,
211          * but this is necessary for version matching, and for ACL processing.
212          */
213
214         for ( rc=0; rc != -1; rc = ldap_result(lc->ld, msgid, 0, &tv, &res))
215         {
216                 /* check for abandon */
217                 if (op->o_abandon) {
218                         ldap_abandon(lc->ld, msgid);
219                         rc = 0;
220                         goto finish;
221                 }
222
223                 if (rc == 0) {
224                         tv.tv_sec = 0;
225                         tv.tv_usec = 100000;
226                         ldap_pvt_thread_yield();
227
228                 } else if (rc == LDAP_RES_SEARCH_ENTRY) {
229                         Entry ent;
230                         struct berval bdn;
231                         e = ldap_first_entry(lc->ld,res);
232                         if ( ldap_build_entry(op, e, &ent, &bdn,
233                                                 LDAP_BUILD_ENTRY_PRIVATE) == LDAP_SUCCESS ) {
234                                 rs->sr_entry = &ent;
235                                 rs->sr_attrs = op->oq_search.rs_attrs;
236                                 send_search_entry( op, rs );
237                                 while (ent.e_attrs) {
238                                         Attribute *a;
239                                         BerVarray v;
240
241                                         a = ent.e_attrs;
242                                         ent.e_attrs = a->a_next;
243
244                                         v = a->a_vals;
245                                         if (a->a_vals != &dummy)
246                                                 ber_bvarray_free(a->a_vals);
247                                         if (a->a_nvals != v)
248                                                 ber_bvarray_free(a->a_nvals);
249                                         ch_free(a);
250                                 }
251                                 
252                                 if ( ent.e_dn && ( ent.e_dn != bdn.bv_val ) )
253                                         free( ent.e_dn );
254                                 if ( ent.e_ndn )
255                                         free( ent.e_ndn );
256                         }
257                         ldap_msgfree(res);
258
259                 } else if ( rc == LDAP_RES_SEARCH_REFERENCE ) {
260                         char            **references = NULL;
261                         int             cnt;
262
263                         rc = ldap_parse_reference( lc->ld, res,
264                                         &references, &rs->sr_ctrls, 1 );
265
266                         if ( rc != LDAP_SUCCESS ) {
267                                 continue;
268                         }
269
270                         if ( references == NULL ) {
271                                 continue;
272                         }
273
274                         for ( cnt = 0; references[ cnt ]; cnt++ )
275                                 /* NO OP */ ;
276                                 
277                         rs->sr_ref = ch_calloc( cnt + 1, sizeof( struct berval ) );
278
279                         for ( cnt = 0; references[ cnt ]; cnt++ ) {
280                                 rs->sr_ref[ cnt ].bv_val = references[ cnt ];
281                                 rs->sr_ref[ cnt ].bv_len = strlen( references[ cnt ] );
282                         }
283
284                         /* ignore return value by now */
285                         ( void )send_search_reference( op, rs );
286
287                         /* cleanup */
288                         if ( references ) {
289                                 ldap_value_free( references );
290                                 ch_free( rs->sr_ref );
291                                 rs->sr_ref = NULL;
292                         }
293
294                         if ( rs->sr_ctrls ) {
295                                 ldap_controls_free( rs->sr_ctrls );
296                                 rs->sr_ctrls = NULL;
297                         }
298
299                 } else {
300                         rc = ldap_parse_result(lc->ld, res, &rs->sr_err,
301                                         &match.bv_val, (char **)&rs->sr_text,
302                                         NULL, NULL, 1);
303                         if (rc != LDAP_SUCCESS ) rs->sr_err = rc;
304                         rs->sr_err = ldap_back_map_result(rs);
305                         rc = 0;
306                         break;
307                 }
308         }
309
310         if (rc == -1)
311                 goto fail;
312
313         /*
314          * Rewrite the matched portion of the search base, if required
315          */
316         if ( match.bv_val && *match.bv_val ) {
317                 struct berval mdn;
318
319 #ifdef ENABLE_REWRITE
320                 dc.ctx = "matchedDn";
321 #else
322                 dc.tofrom = 0;
323                 dc.normalized = 0;
324 #endif
325                 match.bv_len = strlen( match.bv_val );
326                 ldap_back_dn_massage(&dc, &match, &mdn);
327                 rs->sr_matched = mdn.bv_val;
328         }
329         if ( rs->sr_v2ref ) {
330                 rs->sr_err = LDAP_REFERRAL;
331         }
332
333 finish:;
334         send_ldap_result( op, rs );
335
336         if ( match.bv_val ) {
337                 if ( rs->sr_matched != match.bv_val ) {
338                         free( (char *)rs->sr_matched );
339                 }
340                 rs->sr_matched = NULL;
341                 LDAP_FREE( match.bv_val );
342         }
343         if ( rs->sr_text ) {
344                 LDAP_FREE( (char *)rs->sr_text );
345                 rs->sr_text = NULL;
346         }
347         if ( mapped_attrs ) {
348                 ch_free( mapped_attrs );
349         }
350         if ( mfilter.bv_val != op->oq_search.rs_filterstr.bv_val ) {
351                 ch_free( mfilter.bv_val );
352         }
353         if ( mbase.bv_val != op->o_req_dn.bv_val ) {
354                 free( mbase.bv_val );
355         }
356         
357         return rc;
358 }
359
360 static int
361 ldap_build_entry(
362         Operation *op,
363         LDAPMessage *e,
364         Entry *ent,
365         struct berval *bdn,
366         int flags
367 )
368 {
369         struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;
370         struct berval a, mapped;
371         BerElement ber = *e->lm_ber;
372         Attribute *attr, **attrp;
373         struct berval *bv;
374         const char *text;
375         int last;
376         int private = flags & LDAP_BUILD_ENTRY_PRIVATE;
377         int normalize = flags & LDAP_BUILD_ENTRY_NORMALIZE;
378         dncookie dc;
379
380         /* safe assumptions ... */
381         assert( ent );
382         ent->e_bv.bv_val = NULL;
383
384         if ( ber_scanf( &ber, "{m{", bdn ) == LBER_ERROR ) {
385                 return LDAP_DECODING_ERROR;
386         }
387
388         /*
389          * Rewrite the dn of the result, if needed
390          */
391         dc.rwmap = &li->rwmap;
392 #ifdef ENABLE_REWRITE
393         dc.conn = op->o_conn;
394         dc.rs = NULL;
395         dc.ctx = "searchResult";
396 #else
397         dc.tofrom = 0;
398         dc.normalized = 0;
399 #endif
400         if ( ldap_back_dn_massage( &dc, bdn, &ent->e_name ) ) {
401                 return LDAP_OTHER;
402         }
403
404         /*
405          * Note: this may fail if the target host(s) schema differs
406          * from the one known to the meta, and a DN with unknown
407          * attributes is returned.
408          * 
409          * FIXME: should we log anything, or delegate to dnNormalize2?
410          */
411         if ( dnNormalize2( NULL, &ent->e_name, &ent->e_nname, op->o_tmpmemctx ) != LDAP_SUCCESS ) {
412                 return LDAP_INVALID_DN_SYNTAX;
413         }
414         
415         ent->e_id = 0;
416         ent->e_attrs = 0;
417         ent->e_private = 0;
418         attrp = &ent->e_attrs;
419
420 #ifdef ENABLE_REWRITE
421         dc.ctx = "searchAttrDN";
422 #endif
423         while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
424                 ldap_back_map(&li->rwmap.rwm_at, &a, &mapped, BACKLDAP_REMAP);
425                 if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0')
426                         continue;
427                 attr = (Attribute *)ch_malloc( sizeof(Attribute) );
428                 if (attr == NULL)
429                         continue;
430                 attr->a_flags = 0;
431                 attr->a_next = 0;
432                 attr->a_desc = NULL;
433                 if (slap_bv2ad(&mapped, &attr->a_desc, &text) != LDAP_SUCCESS) {
434                         if (slap_bv2undef_ad(&mapped, &attr->a_desc, &text) 
435                                         != LDAP_SUCCESS) {
436 #ifdef NEW_LOGGING
437                                 LDAP_LOG( BACK_LDAP, DETAIL1, 
438                                         "slap_bv2undef_ad(%s):  %s\n", mapped.bv_val, text, 0 );
439 #else /* !NEW_LOGGING */
440                                 Debug( LDAP_DEBUG_ANY, 
441                                                 "slap_bv2undef_ad(%s):  "
442                                                 "%s\n%s", mapped.bv_val, text, "" );
443 #endif /* !NEW_LOGGING */
444                                 ch_free(attr);
445                                 continue;
446                         }
447                 }
448
449                 /* no subschemaSubentry */
450                 if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry ) {
451
452                         /* 
453                          * We eat target's subschemaSubentry because
454                          * a search for this value is likely not
455                          * to resolve to the appropriate backend;
456                          * later, the local subschemaSubentry is
457                          * added.
458                          */
459                         ( void )ber_scanf( &ber, "x" /* [W] */ );
460
461                         ch_free(attr);
462                         continue;
463                 }
464                 
465                 if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR
466                                 || attr->a_vals == NULL ) {
467                         /*
468                          * Note: attr->a_vals can be null when using
469                          * values result filter
470                          */
471                         if (private) {
472                                 attr->a_vals = &dummy;
473                         } else {
474                                 attr->a_vals = ch_malloc(sizeof(struct berval));
475                                 attr->a_vals->bv_val = NULL;
476                                 attr->a_vals->bv_len = 0;
477                         }
478                         last = 0;
479                 } else {
480                         for ( last = 0; attr->a_vals[last].bv_val; last++ );
481                 }
482                 if ( last == 0 ) {
483                         /* empty */
484                 } else if ( attr->a_desc == slap_schema.si_ad_objectClass
485                                 || attr->a_desc == slap_schema.si_ad_structuralObjectClass ) {
486                         for ( bv = attr->a_vals; bv->bv_val; bv++ ) {
487                                 ldap_back_map(&li->rwmap.rwm_oc, bv, &mapped,
488                                                 BACKLDAP_REMAP);
489                                 if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
490                                         LBER_FREE(bv->bv_val);
491                                         bv->bv_val = NULL;
492                                         if (--last < 0)
493                                                 break;
494                                         *bv = attr->a_vals[last];
495                                         attr->a_vals[last].bv_val = NULL;
496                                         bv--;
497
498                                 } else if ( mapped.bv_val != bv->bv_val ) {
499                                         /*
500                                          * FIXME: after LBER_FREEing
501                                          * the value is replaced by
502                                          * ch_alloc'ed memory
503                                          */
504                                         LBER_FREE(bv->bv_val);
505                                         ber_dupbv( bv, &mapped );
506                                 }
507                         }
508
509                 /*
510                  * It is necessary to try to rewrite attributes with
511                  * dn syntax because they might be used in ACLs as
512                  * members of groups; since ACLs are applied to the
513                  * rewritten stuff, no dn-based subject clause could
514                  * be used at the ldap backend side (see
515                  * http://www.OpenLDAP.org/faq/data/cache/452.html)
516                  * The problem can be overcome by moving the dn-based
517                  * ACLs to the target directory server, and letting
518                  * everything pass thru the ldap backend.
519                  */
520                 } else if ( attr->a_desc->ad_type->sat_syntax ==
521                                 slap_schema.si_syn_distinguishedName ) {
522                         ldap_dnattr_result_rewrite( &dc, attr->a_vals );
523
524                 }
525
526                 if ( normalize && last && attr->a_desc->ad_type->sat_equality &&
527                         attr->a_desc->ad_type->sat_equality->smr_normalize ) {
528                         int i;
529
530                         attr->a_nvals = ch_malloc((last+1)*sizeof(struct berval));
531                         for (i=0; i<last; i++) {
532                                 attr->a_desc->ad_type->sat_equality->smr_normalize(
533                                         SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
534                                         attr->a_desc->ad_type->sat_syntax,
535                                         attr->a_desc->ad_type->sat_equality,
536                                         &attr->a_vals[i], &attr->a_nvals[i],
537                                         op->o_tmpmemctx );
538                         }
539                         attr->a_nvals[i].bv_val = NULL;
540                         attr->a_nvals[i].bv_len = 0;
541                 } else {
542                         attr->a_nvals = attr->a_vals;
543                 }
544                 *attrp = attr;
545                 attrp = &attr->a_next;
546         }
547         /* make sure it's free'able */
548         if (!private && ent->e_name.bv_val == bdn->bv_val)
549                 ber_dupbv( &ent->e_name, bdn );
550         return LDAP_SUCCESS;
551 }
552
553 /* return 0 IFF we can retrieve the entry with ndn
554  */
555 int
556 ldap_back_entry_get(
557         Operation *op,
558         struct berval   *ndn,
559         ObjectClass *oc,
560         AttributeDescription *at,
561         int rw,
562         Entry **ent
563 )
564 {
565         struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;    
566         struct ldapconn *lc;
567         int rc = 1, is_oc;
568         struct berval mapped = { 0, NULL }, bdn, mdn;
569         LDAPMessage     *result = NULL, *e = NULL;
570         char *gattr[3];
571         char *filter = NULL;
572         Connection *oconn;
573         SlapReply rs;
574         dncookie dc;
575
576         /* Tell getconn this is a privileged op */
577         is_oc = op->o_do_not_cache;
578         op->o_do_not_cache = 1;
579         lc = ldap_back_getconn(op, &rs);
580         oconn = op->o_conn;
581         op->o_conn = NULL;
582         if ( !lc || !ldap_back_dobind(lc, op, &rs) ) {
583                 op->o_do_not_cache = is_oc;
584                 op->o_conn = oconn;
585                 return 1;
586         }
587         op->o_do_not_cache = is_oc;
588         op->o_conn = oconn;
589
590         /*
591          * Rewrite the search base, if required
592          */
593         dc.rwmap = &li->rwmap;
594 #ifdef ENABLE_REWRITE
595         dc.conn = op->o_conn;
596         dc.rs = &rs;
597         dc.ctx = "searchBase";
598 #else
599         dc.tofrom = 1;
600         dc.normalized = 1;
601 #endif
602         if ( ldap_back_dn_massage( &dc, ndn, &mdn ) ) {
603                 return 1;
604         }
605
606         ldap_back_map(&li->rwmap.rwm_at, &at->ad_cname, &mapped, BACKLDAP_MAP);
607         if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') {
608                 rc = 1;
609                 goto cleanup;
610         }
611
612         is_oc = (strcasecmp("objectclass", mapped.bv_val) == 0);
613         if (oc && !is_oc) {
614                 gattr[0] = "objectclass";
615                 gattr[1] = mapped.bv_val;
616                 gattr[2] = NULL;
617         } else {
618                 gattr[0] = mapped.bv_val;
619                 gattr[1] = NULL;
620         }
621         if (oc) {
622                 char *ptr;
623                 ldap_back_map(&li->rwmap.rwm_oc, &oc->soc_cname, &mapped,
624                                                 BACKLDAP_MAP);
625                 filter = ch_malloc(sizeof("(objectclass=)") + mapped.bv_len);
626                 ptr = lutil_strcopy(filter, "(objectclass=");
627                 ptr = lutil_strcopy(ptr, mapped.bv_val);
628                 *ptr++ = ')';
629                 *ptr++ = '\0';
630         }
631                 
632         if (ldap_search_ext_s(lc->ld, mdn.bv_val, LDAP_SCOPE_BASE, filter,
633                                 gattr, 0, NULL, NULL, LDAP_NO_LIMIT,
634                                 LDAP_NO_LIMIT, &result) != LDAP_SUCCESS)
635         {
636                 goto cleanup;
637         }
638
639         if ((e = ldap_first_entry(lc->ld, result)) == NULL) {
640                 goto cleanup;
641         }
642
643         *ent = ch_calloc(1,sizeof(Entry));
644
645         rc = ldap_build_entry(op, e, *ent, &bdn, LDAP_BUILD_ENTRY_NORMALIZE);
646
647         if (rc != LDAP_SUCCESS) {
648                 ch_free(*ent);
649                 *ent = NULL;
650         }
651
652 cleanup:
653         if (result) {
654                 ldap_msgfree(result);
655         }
656
657         if ( filter ) {
658                 ch_free( filter );
659         }
660
661         if ( mdn.bv_val != ndn->bv_val ) {
662                 ch_free( mdn.bv_val );
663         }
664
665         return(rc);
666 }
667