]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#5344 slapo-rwm: fix prev commit
authorHoward Chu <hyc@openldap.org>
Fri, 13 Aug 2021 20:09:28 +0000 (21:09 +0100)
committerHoward Chu <hyc@openldap.org>
Fri, 13 Aug 2021 20:09:28 +0000 (21:09 +0100)
Must always generate newDN

servers/slapd/overlays/rwm.c

index 34ee7f26b788eded1e2ed78b3bc1a25b7e080b03..ff0c996d80835c6f5bdd58b5dadfdee118605bca 100644 (file)
@@ -730,8 +730,9 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
        slap_overinst           *on = (slap_overinst *) op->o_bd->bd_info;
        struct ldaprwmap        *rwmap = 
                        (struct ldaprwmap *)on->on_bi.bi_private;
+       struct berval pdn, pndn;
        
-       int                     rc, changedNewDN = 0;
+       int                     rc;
        dncookie                dc;
 
        rwm_op_cb               *roc = rwm_callback_get( op );
@@ -757,7 +758,6 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
                }
 
                if ( op->orr_newSup->bv_val != newSup.bv_val ) {
-                       changedNewDN = 1;
                        op->orr_newSup = op->o_tmpalloc( sizeof( struct berval ),
                                op->o_tmpmemctx );
                        op->orr_nnewSup = op->o_tmpalloc( sizeof( struct berval ),
@@ -765,6 +765,8 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
                        *op->orr_newSup = newSup;
                        *op->orr_nnewSup = nnewSup;
                }
+               pdn = newSup;
+               pndn = nnewSup;
        }
 
        /*
@@ -788,29 +790,11 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
                }
 
                if ( op->orr_newrdn.bv_val != newrdn.bv_val ) {
-                       changedNewDN = 1;
                        op->orr_newrdn = newrdn;
                        op->orr_nnewrdn = nnewrdn;
                }
        }
 
-       /*
-        * Update the new DN if changed
-        */
-       if ( changedNewDN ) {
-               struct berval pdn, pndn;
-
-               if ( op->orr_newSup ) {
-                       pdn = *op->orr_newSup;
-                       pndn = *op->orr_nnewSup;
-               } else {
-                       dnParent( &op->o_req_dn, &pdn );
-                       dnParent( &op->o_req_ndn, &pndn );
-               }
-               build_new_dn( &op->orr_newDN, &pdn, &op->orr_newrdn, op->o_tmpmemctx );
-               build_new_dn( &op->orr_nnewDN, &pndn, &op->orr_nnewrdn, op->o_tmpmemctx );
-       }
-
        /*
         * Rewrite the dn, if needed
         */
@@ -820,6 +804,16 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
                send_ldap_error( op, rs, rc, "renameDN massage error" );
                goto err;
        }
+       if ( !op->orr_newSup ) {
+               dnParent( &op->o_req_dn, &pdn );
+               dnParent( &op->o_req_ndn, &pndn );
+       }
+
+       /*
+        * Update the new DN
+        */
+       build_new_dn( &op->orr_newDN, &pdn, &op->orr_newrdn, op->o_tmpmemctx );
+       build_new_dn( &op->orr_nnewDN, &pndn, &op->orr_nnewrdn, op->o_tmpmemctx );
 
        op->o_callback = &roc->cb;