1 /* modrdn.c - ldbm backend modrdn routine */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9 * LDAP v3 newSuperior support. Add new rdn as an attribute.
10 * (Full support for v2 also used software/ideas contributed
11 * by Roy Hooper rhooper@cyberus.ca, thanks to him for his
14 * Copyright 1999, Juan C. Gomez, All rights reserved.
15 * This software is not subject to any license of Silicon Graphics
16 * Inc. or Purdue University.
18 * Redistribution and use in source and binary forms are permitted
19 * without restriction or fee of any kind as long as this notice
28 #include <ac/string.h>
29 #include <ac/socket.h>
32 #include "back-ldbm.h"
33 #include "proto-back-ldbm.h"
42 struct berval *newrdn,
43 struct berval *nnewrdn,
45 struct berval *newSuperior,
46 struct berval *nnewSuperior
49 AttributeDescription *children = slap_schema.si_ad_children;
50 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
51 struct berval p_dn, p_ndn;
52 struct berval new_dn = { 0, NULL}, new_ndn = { 0, NULL };
56 #define CAN_ROLLBACK -1
57 #define MUST_DESTROY 1
58 int rc = CAN_ROLLBACK;
61 const char *text = NULL;
62 char textbuf[SLAP_TEXT_BUFLEN];
63 size_t textlen = sizeof textbuf;
64 /* Added to support LDAP v2 correctly (deleteoldrdn thing) */
65 LDAPRDN *new_rdn = NULL;
66 LDAPRDN *old_rdn = NULL;
68 /* Added to support newSuperior */
69 Entry *np = NULL; /* newSuperior Entry */
70 struct berval *np_ndn = NULL; /* newSuperior ndn */
71 struct berval *new_parent_dn = NULL; /* np_dn, p_dn, or NULL */
72 /* Used to interface with ldbm_modify_internal() */
73 Modifications *mod = NULL; /* Used to delete old/add new rdn */
74 int manageDSAit = get_manageDSAit( op );
77 LDAP_LOG( BACK_LDBM, ENTRY,
78 "ldbm_back_modrdn: dn: %s newSuperior=%s\n",
79 dn->bv_len ? dn->bv_val : "NULL",
80 ( newSuperior && newSuperior->bv_len ) ? newSuperior->bv_val : "NULL",0 );
82 Debug( LDAP_DEBUG_TRACE,
83 "==>ldbm_back_modrdn: dn: %s newSuperior=%s\n",
84 dn->bv_len ? dn->bv_val : "NULL",
85 ( newSuperior && newSuperior->bv_len )
86 ? newSuperior->bv_val : "NULL", 0 );
89 /* grab giant lock for writing */
90 ldap_pvt_thread_rdwr_wlock(&li->li_giant_rwlock);
92 /* get entry with writer lock */
93 if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
94 char* matched_dn = NULL;
97 if( matched != NULL ) {
98 matched_dn = strdup( matched->e_dn );
99 refs = is_entry_referral( matched )
100 ? get_entry_referrals( be, conn, op, matched )
102 cache_return_entry_r( &li->li_cache, matched );
104 refs = referral_rewrite( default_referral,
105 NULL, dn, LDAP_SCOPE_DEFAULT );
108 ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
110 send_ldap_result( conn, op, LDAP_REFERRAL,
111 matched_dn, NULL, refs, NULL );
113 if ( refs ) ber_bvarray_free( refs );
119 if (!manageDSAit && is_entry_referral( e ) ) {
120 /* parent is a referral, don't allow add */
121 /* parent is an alias, don't allow add */
122 BerVarray refs = get_entry_referrals( be,
126 LDAP_LOG( BACK_LDBM, INFO,
127 "ldbm_back_modrdn: entry %s is a referral\n", e->e_dn, 0, 0 );
129 Debug( LDAP_DEBUG_TRACE, "entry %s is referral\n", e->e_dn,
133 send_ldap_result( conn, op, LDAP_REFERRAL,
134 e->e_dn, NULL, refs, NULL );
136 if ( refs ) ber_bvarray_free( refs );
140 if ( has_children( be, e ) ) {
142 LDAP_LOG( BACK_LDBM, INFO,
143 "ldbm_back_modrdn: entry %s has children\n", e->e_dn, 0, 0 );
145 Debug( LDAP_DEBUG_TRACE, "entry %s has children\n", e->e_dn,
149 send_ldap_result( conn, op, LDAP_NOT_ALLOWED_ON_NONLEAF,
150 NULL, "subtree rename not supported", NULL, NULL );
154 if ( be_issuffix( be, &e->e_nname ) ) {
155 p_ndn = slap_empty_bv ;
157 dnParent( &e->e_nname, &p_ndn );
160 if ( p_ndn.bv_len != 0 ) {
161 /* Make sure parent entry exist and we can write its
165 if( (p = dn2entry_w( be, &p_ndn, NULL )) == NULL) {
167 LDAP_LOG( BACK_LDBM, INFO,
168 "ldbm_back_modrdn: parent of %s does not exist\n",
171 Debug( LDAP_DEBUG_TRACE, "parent does not exist\n",
175 send_ldap_result( conn, op, LDAP_OTHER,
176 NULL, "parent entry does not exist", NULL, NULL );
181 /* check parent for "children" acl */
182 if ( ! access_allowed( be, conn, op, p,
183 children, NULL, ACL_WRITE, NULL ) )
186 LDAP_LOG( BACK_LDBM, INFO,
187 "ldbm_back_modrdn: no access to parent of (%s)\n",
190 Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
194 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
195 NULL, NULL, NULL, NULL );
200 LDAP_LOG( BACK_LDBM, DETAIL1,
201 "ldbm_back_modrdn: wr to children of entry %s OK\n",
202 p_ndn.bv_val, 0, 0 );
204 Debug( LDAP_DEBUG_TRACE,
205 "ldbm_back_modrdn: wr to children of entry %s OK\n",
206 p_ndn.bv_val, 0, 0 );
209 if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
210 p_dn = slap_empty_bv;
212 dnParent( &e->e_name, &p_dn );
216 LDAP_LOG( BACK_LDBM, DETAIL1,
217 "ldbm_back_modrdn: parent dn=%s\n", p_dn.bv_val, 0, 0 );
219 Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: parent dn=%s\n",
224 /* no parent, must be root to modify rdn */
225 isroot = be_isroot( be, &op->o_ndn );
227 if ( be_issuffix( be, (struct berval *)&slap_empty_bv ) || be_isupdate( be, &op->o_ndn ) ) {
228 p = (Entry *)&slap_entry_root;
230 rc = access_allowed( be, conn, op, p,
231 children, NULL, ACL_WRITE, NULL );
234 /* check parent for "children" acl */
237 LDAP_LOG( BACK_LDBM, ERR,
238 "ldbm_back_modrdn: no access to parent \"\"\n", 0,0,0 );
240 Debug( LDAP_DEBUG_TRACE,
241 "<=- ldbm_back_modrdn: no "
242 "access to parent\n", 0, 0, 0 );
245 send_ldap_result( conn, op,
246 LDAP_INSUFFICIENT_ACCESS,
247 NULL, NULL, NULL, NULL );
253 LDAP_LOG( BACK_LDBM, ERR,
254 "ldbm_back_modrdn: (%s) has no parent & not a root.\n",
257 Debug( LDAP_DEBUG_TRACE,
258 "<=- ldbm_back_modrdn: no parent & "
259 "not root\n", 0, 0, 0);
262 send_ldap_result( conn, op,
263 LDAP_INSUFFICIENT_ACCESS,
264 NULL, NULL, NULL, NULL );
270 LDAP_LOG( BACK_LDBM, INFO,
271 "ldbm_back_modrdn: (%s) no parent, locked root.\n", e->e_dn, 0, 0 );
273 Debug( LDAP_DEBUG_TRACE,
274 "ldbm_back_modrdn: no parent, locked root\n",
279 new_parent_dn = &p_dn; /* New Parent unless newSuperior given */
281 if ( newSuperior != NULL ) {
283 LDAP_LOG( BACK_LDBM, DETAIL1,
284 "ldbm_back_modrdn: new parent \"%s\" requested\n",
285 newSuperior->bv_val, 0, 0 );
287 Debug( LDAP_DEBUG_TRACE,
288 "ldbm_back_modrdn: new parent \"%s\" requested...\n",
289 newSuperior->bv_val, 0, 0 );
292 np_ndn = nnewSuperior;
294 /* newSuperior == oldParent? */
295 if ( dn_match( &p_ndn, np_ndn ) ) {
297 LDAP_LOG( BACK_LDBM, INFO, "ldbm_back_modrdn: "
298 "new parent\"%s\" seems to be the same as the "
299 "old parent \"%s\"\n", newSuperior->bv_val, p_dn.bv_val, 0 );
301 Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: "
302 "new parent\"%s\" seems to be the same as the "
303 "old parent \"%s\"\n",
304 newSuperior->bv_val, p_dn.bv_val, 0 );
307 newSuperior = NULL; /* ignore newSuperior */
311 if ( newSuperior != NULL ) {
312 /* newSuperior == entry being moved?, if so ==> ERROR */
313 /* Get Entry with dn=newSuperior. Does newSuperior exist? */
315 if ( nnewSuperior->bv_len ) {
316 if( (np = dn2entry_w( be, np_ndn, NULL )) == NULL) {
318 LDAP_LOG( BACK_LDBM, ERR,
319 "ldbm_back_modrdn: newSup(ndn=%s) not found.\n",
320 np_ndn->bv_val, 0, 0 );
322 Debug( LDAP_DEBUG_TRACE,
323 "ldbm_back_modrdn: newSup(ndn=%s) not here!\n",
324 np_ndn->bv_val, 0, 0);
327 send_ldap_result( conn, op, LDAP_OTHER,
328 NULL, "newSuperior not found", NULL, NULL );
333 LDAP_LOG( BACK_LDBM, DETAIL1,
334 "ldbm_back_modrdn: wr to new parent OK np=%p, id=%ld\n",
337 Debug( LDAP_DEBUG_TRACE,
338 "ldbm_back_modrdn: wr to new parent OK np=%p, id=%ld\n",
342 /* check newSuperior for "children" acl */
343 if ( !access_allowed( be, conn, op, np, children, NULL,
347 LDAP_LOG( BACK_LDBM, INFO,
348 "ldbm_back_modrdn: no wr to newSup children.\n", 0, 0, 0 );
350 Debug( LDAP_DEBUG_TRACE,
351 "ldbm_back_modrdn: no wr to newSup children\n",
355 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
356 NULL, NULL, NULL, NULL );
360 if ( is_entry_alias( np ) ) {
361 /* parent is an alias, don't allow add */
363 LDAP_LOG( BACK_LDBM, INFO,
364 "ldbm_back_modrdn: entry (%s) is an alias.\n", np->e_dn,0,0);
366 Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 );
370 send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM,
371 NULL, "newSuperior is an alias", NULL, NULL );
376 if ( is_entry_referral( np ) ) {
377 /* parent is a referral, don't allow add */
379 LDAP_LOG( BACK_LDBM, INFO,
380 "ldbm_back_modrdn: entry (%s) is a referral\n",
383 Debug( LDAP_DEBUG_TRACE, "entry (%s) is referral\n",
387 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
388 NULL, "newSuperior is a referral", NULL, NULL );
395 /* no parent, must be root to modify newSuperior */
396 if ( isroot == -1 ) {
397 isroot = be_isroot( be, &op->o_ndn );
401 if ( be_issuffix( be, (struct berval *)&slap_empty_bv ) || be_isupdate( be, &op->o_ndn ) ) {
402 np = (Entry *)&slap_entry_root;
404 rc = access_allowed( be, conn, op, np,
405 children, NULL, ACL_WRITE, NULL );
408 /* check parent for "children" acl */
411 LDAP_LOG( BACK_LDBM, ERR,
412 "ldbm_back_modrdn: no access "
413 "to new superior \"\"\n", 0, 0, 0 );
415 Debug( LDAP_DEBUG_TRACE,
416 "<=- ldbm_back_modrdn: no "
417 "access to new superior\n", 0, 0, 0 );
420 send_ldap_result( conn, op,
421 LDAP_INSUFFICIENT_ACCESS,
422 NULL, NULL, NULL, NULL );
428 LDAP_LOG( BACK_LDBM, ERR,
429 "ldbm_back_modrdn: \"\" not allowed as new superior\n",
432 Debug( LDAP_DEBUG_TRACE,
433 "<=- ldbm_back_modrdn: \"\" "
434 "not allowed as new superior\n",
438 send_ldap_result( conn, op,
439 LDAP_INSUFFICIENT_ACCESS,
440 NULL, NULL, NULL, NULL );
447 LDAP_LOG( BACK_LDBM, DETAIL1,
448 "ldbm_back_modrdn: wr to new parent's children OK.\n", 0, 0, 0 );
450 Debug( LDAP_DEBUG_TRACE,
451 "ldbm_back_modrdn: wr to new parent's children OK\n",
455 new_parent_dn = newSuperior;
458 /* Build target dn and make sure target entry doesn't exist already. */
459 build_new_dn( &new_dn, new_parent_dn, newrdn );
460 dnNormalize2( NULL, &new_dn, &new_ndn );
463 LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_modrdn: new ndn=%s\n",
464 new_ndn.bv_val, 0, 0 );
466 Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n",
467 new_ndn.bv_val, 0, 0 );
470 /* check for abandon */
471 if ( op->o_abandon ) {
475 if ( ( rc_id = dn2id ( be, &new_ndn, &id ) ) || id != NOID ) {
476 /* if (rc_id) something bad happened to ldbm cache */
477 send_ldap_result( conn, op,
478 rc_id ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS,
479 NULL, NULL, NULL, NULL );
484 LDAP_LOG( BACK_LDBM, INFO, "ldbm_back_modrdn: new ndn (%s) does not exist\n",
485 new_ndn.bv_val, 0, 0 );
487 Debug( LDAP_DEBUG_TRACE,
488 "ldbm_back_modrdn: new ndn=%s does not exist\n",
489 new_ndn.bv_val, 0, 0 );
493 /* Get attribute types and values of our new rdn, we will
494 * need to add that to our new entry
496 if ( ldap_bv2rdn( newrdn, &new_rdn, (char **)&text,
497 LDAP_DN_FORMAT_LDAP ) )
500 LDAP_LOG( BACK_LDBM, INFO,
501 "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n",
504 Debug( LDAP_DEBUG_TRACE,
505 "ldbm_back_modrdn: can't figure out type(s)/value(s) of newrdn\n",
509 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
510 NULL, "unable to parse type(s)/value(s) used in RDN", NULL, NULL );
515 LDAP_LOG( BACK_LDBM, DETAIL1,
516 "ldbm_back_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
517 new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 );
519 Debug( LDAP_DEBUG_TRACE,
520 "ldbm_back_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
521 new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 );
524 /* Retrieve the old rdn from the entry's dn */
525 if ( ldap_bv2rdn( dn, &old_rdn, (char **)&text,
526 LDAP_DN_FORMAT_LDAP ) )
529 LDAP_LOG( BACK_LDBM, INFO,
530 "ldbm_back_modrdn: can't figure out the old_rdn "
531 "type(s)/value(s).\n", 0, 0, 0 );
533 Debug( LDAP_DEBUG_TRACE,
534 "ldbm_back_modrdn: can't figure out the old_rdn type(s)/value(s)\n",
538 send_ldap_result( conn, op, LDAP_OTHER,
539 NULL, "unable to parse type(s)/value(s) used in RDN from old DN", NULL, NULL );
544 if ( newSuperior == NULL
545 && charray_strcasecmp( (const char **)old_rdn_types, (const char **)new_rdn_types ) != 0 )
547 /* Not a big deal but we may say something */
549 LDAP_LOG( BACK_LDBM, INFO,
550 "ldbm_back_modrdn: old_rdn_type=%s new_rdn_type=%s\n",
551 old_rdn_types[0], new_rdn_types[0], 0 );
553 Debug( LDAP_DEBUG_TRACE,
554 "ldbm_back_modrdn: old_rdn_type=%s, new_rdn_type=%s!\n",
555 old_rdn_types[0], new_rdn_types[0], 0 );
561 LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_modrdn: DN_X500\n", 0, 0, 0 );
563 Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: DN_X500\n",
568 for ( a_cnt = 0; new_rdn[0][a_cnt]; a_cnt++ ) {
570 AttributeDescription *desc = NULL;
571 Modifications *mod_tmp;
573 rc = slap_bv2ad( &new_rdn[0][a_cnt]->la_attr, &desc, &text );
575 if ( rc != LDAP_SUCCESS ) {
577 LDAP_LOG( BACK_LDBM, INFO,
578 "ldbm_back_modrdn: slap_bv2ad error: %s (%s)\n",
579 text, new_rdn[0][a_cnt]->la_attr.bv_val, 0 );
581 Debug( LDAP_DEBUG_TRACE,
582 "ldbm_back_modrdn: %s: %s (new)\n",
583 text, new_rdn[0][a_cnt]->la_attr.bv_val, 0 );
586 send_ldap_result( conn, op, rc,
587 NULL, text, NULL, NULL );
592 if ( ! access_allowed( be, conn, op, e,
593 desc, &new_rdn[0][a_cnt]->la_value, ACL_WRITE, NULL ) ) {
595 LDAP_LOG( BACK_LDBM, INFO,
596 "ldbm_back_modrdn: access not allowed to attr \"%s\"\n",
597 new_rdn[0][a_cnt]->la_attr.bv_val, 0, 0 );
599 Debug( LDAP_DEBUG_TRACE,
600 "ldbm_back_modrdn: access not allowed "
601 "to attr \"%s\"\n%s%s",
602 new_rdn[0][a_cnt]->la_attr.bv_val, "", "" );
604 send_ldap_result( conn, op,
605 LDAP_INSUFFICIENT_ACCESS,
606 NULL, NULL, NULL, NULL );
611 mod_tmp = (Modifications *)ch_malloc( sizeof( Modifications )
612 + 2 * sizeof( struct berval ) );
613 mod_tmp->sml_desc = desc;
614 mod_tmp->sml_bvalues = (BerVarray)( mod_tmp + 1 );
615 mod_tmp->sml_bvalues[0] = new_rdn[0][a_cnt]->la_value;
616 mod_tmp->sml_bvalues[1].bv_val = NULL;
617 mod_tmp->sml_op = SLAP_MOD_SOFTADD;
618 mod_tmp->sml_next = mod;
622 /* Remove old rdn value if required */
623 if ( deleteoldrdn ) {
624 /* Get value of old rdn */
625 if ( old_rdn == NULL ) {
627 LDAP_LOG( BACK_LDBM, INFO,
628 "ldbm_back_modrdn: can't figure out old RDN value(s) "
629 "from old RDN\n", 0, 0, 0 );
631 Debug( LDAP_DEBUG_TRACE,
632 "ldbm_back_modrdn: can't figure out oldRDN value(s) from old RDN\n",
636 send_ldap_result( conn, op, LDAP_OTHER,
637 NULL, "could not parse value(s) from old RDN", NULL, NULL );
641 for ( d_cnt = 0; old_rdn[0][d_cnt]; d_cnt++ ) {
643 AttributeDescription *desc = NULL;
644 Modifications *mod_tmp;
646 rc = slap_bv2ad( &old_rdn[0][d_cnt]->la_attr, &desc, &text );
648 if ( rc != LDAP_SUCCESS ) {
650 LDAP_LOG( BACK_LDBM, INFO,
651 "ldbm_back_modrdn: %s: %s (old)\n",
652 text, old_rdn[0][d_cnt]->la_attr.bv_val, 0 );
654 Debug( LDAP_DEBUG_TRACE,
655 "ldbm_back_modrdn: %s: %s (old)\n",
656 text, old_rdn[0][d_cnt]->la_attr.bv_val, 0 );
659 send_ldap_result( conn, op, rc,
660 NULL, text, NULL, NULL );
665 if ( ! access_allowed( be, conn, op, e,
666 desc, &old_rdn[0][d_cnt]->la_value, ACL_WRITE, NULL ) ) {
668 LDAP_LOG( BACK_LDBM, INFO,
669 "ldbm_back_modrdn: access not allowed to attr \"%s\"\n",
670 old_rdn[0][d_cnt]->la_attr.bv_val, 0, 0 );
672 Debug( LDAP_DEBUG_TRACE,
673 "ldbm_back_modrdn: access not allowed "
674 "to attr \"%s\"\n%s%s",
675 old_rdn[0][d_cnt]->la_attr.bv_val, "", "" );
677 send_ldap_result( conn, op,
678 LDAP_INSUFFICIENT_ACCESS,
679 NULL, NULL, NULL, NULL );
684 /* Remove old value of rdn as an attribute. */
685 mod_tmp = (Modifications *)ch_malloc( sizeof( Modifications )
686 + 2 * sizeof( struct berval ) );
687 mod_tmp->sml_desc = desc;
688 mod_tmp->sml_bvalues = (BerVarray)(mod_tmp+1);
689 mod_tmp->sml_bvalues[0] = old_rdn[0][d_cnt]->la_value;
690 mod_tmp->sml_bvalues[1].bv_val = NULL;
691 mod_tmp->sml_op = LDAP_MOD_DELETE;
692 mod_tmp->sml_next = mod;
696 LDAP_LOG( BACK_LDBM, DETAIL1,
697 "ldbm_back_modrdn: removing old_rdn_val=%s\n",
698 old_rdn[0][d_cnt]->la_value.bv_val, 0, 0 );
700 Debug( LDAP_DEBUG_TRACE,
701 "ldbm_back_modrdn: removing old_rdn_val=%s\n",
702 old_rdn[0][d_cnt]->la_value.bv_val, 0, 0 );
708 /* check for abandon */
709 if ( op->o_abandon ) {
714 if ( dn2id_delete( be, &e->e_nname, e->e_id ) != 0 ) {
715 send_ldap_result( conn, op, LDAP_OTHER,
716 NULL, "DN index delete fail", NULL, NULL );
720 (void) cache_delete_entry( &li->li_cache, e );
723 /* XXX: there is no going back! */
728 e->e_nname = new_ndn;
729 new_dn.bv_val = NULL;
730 new_ndn.bv_val = NULL;
733 if ( dn2id_add( be, &e->e_nname, e->e_id ) != 0 ) {
734 send_ldap_result( conn, op, LDAP_OTHER,
735 NULL, "DN index add failed", NULL, NULL );
739 /* modify memory copy of entry */
740 rc = ldbm_modify_internal( be, conn, op, dn->bv_val, &mod[0], e,
741 &text, textbuf, textlen );
743 if( rc != LDAP_SUCCESS ) {
744 if( rc != SLAPD_ABANDON ) {
745 send_ldap_result( conn, op, rc,
746 NULL, text, NULL, NULL );
749 /* here we may try to delete the newly added dn */
750 if ( dn2id_delete( be, &e->e_nname, e->e_id ) != 0 ) {
751 /* we already are in trouble ... */
758 (void) cache_update_entry( &li->li_cache, e );
760 /* NOTE: after this you must not free new_dn or new_ndn!
761 * They are used by cache.
765 if ( id2entry_add( be, e ) != 0 ) {
766 send_ldap_result( conn, op, LDAP_OTHER,
767 NULL, "entry update failed", NULL, NULL );
771 send_ldap_result( conn, op, LDAP_SUCCESS,
772 NULL, NULL, NULL, NULL );
774 cache_entry_commit( e );
777 if( new_dn.bv_val != NULL ) free( new_dn.bv_val );
778 if( new_ndn.bv_val != NULL ) free( new_ndn.bv_val );
780 /* LDAP v2 supporting correct attribute handling. */
781 if( new_rdn ) ldap_rdnfree( new_rdn );
782 if( old_rdn ) ldap_rdnfree( old_rdn );
786 for (; mod; mod = tmp ) {
792 /* LDAP v3 Support */
794 /* free new parent and writer lock */
795 cache_return_entry_w( &li->li_cache, np );
799 /* free parent and writer lock */
800 cache_return_entry_w( &li->li_cache, p );
803 /* free entry and writer lock */
804 cache_return_entry_w( &li->li_cache, e );
805 if ( rc == MUST_DESTROY ) {
806 /* if rc == MUST_DESTROY the entry is uncached
807 * and its private data is destroyed;
808 * the entry must be freed */
811 ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);