]> git.sur5r.net Git - openldap/commitdiff
add newRDN rewriting; fix rewriteContext names (ITS#5834)
authorPierangelo Masarati <ando@openldap.org>
Fri, 28 Nov 2008 20:34:02 +0000 (20:34 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 28 Nov 2008 20:34:02 +0000 (20:34 +0000)
doc/man/man5/slapo-rwm.5
servers/slapd/overlays/rwm.c

index 065e01bb6d3301ba2b0f4ab79b64e74eaa51b4c5..fecaca4403ad4f084e01c5272aa8c3fe9d260aa3 100644 (file)
@@ -355,8 +355,9 @@ modifyDN             modify
 modifyAttrDN         modify AVA (DN portion of "ref" excluded)
 referralAttrDN       add/modify DN portion of referrals
                      (default to none)
-modrDN               modrdn
-newSuperiorDN        modrdn
+renameDN             modrdn (the old DN)
+newSuperiorDN        modrdn (the new parent DN, if any)
+newRDN               modrdn (the new relative DN)
 deleteDN             delete
 exopPasswdDN         password modify extended operation DN
 .fi
index 37ddd04e78de946da96d36c44f916ba27975812b..84013a4a68976d0fb99b392574e55d231b8a05ca 100644 (file)
@@ -96,6 +96,12 @@ rwm_op_rollback( Operation *op, SlapReply *rs, rwm_op_state *ros )
                        op->orr_newSup = ros->orr_newSup;
                        op->orr_nnewSup = ros->orr_nnewSup;
                }
+               if ( op->orr_newrdn.bv_val != ros->orr_newrdn.bv_val ) {
+                       ch_free( op->orr_newrdn.bv_val );
+                       ch_free( op->orr_nnewrdn.bv_val );
+                       op->orr_newrdn = ros->orr_newrdn;
+                       op->orr_nnewrdn = ros->orr_nnewrdn;
+               }
                break;
        case LDAP_REQ_SEARCH:
                ch_free( ros->mapped_attrs );
@@ -684,11 +690,11 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
                        (struct ldaprwmap *)on->on_bi.bi_private;
        
        int                     rc;
+       dncookie                dc;
 
        rwm_op_cb               *roc = rwm_callback_get( op, rs );
 
        if ( op->orr_newSup ) {
-               dncookie        dc;
                struct berval   nnewSup = BER_BVNULL;
                struct berval   newSup = BER_BVNULL;
 
@@ -718,6 +724,32 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
                }
        }
 
+       /*
+        * Rewrite the newRDN, if needed
+        */
+       {
+               struct berval   newrdn = BER_BVNULL;
+               struct berval   nnewrdn = BER_BVNULL;
+
+               dc.rwmap = rwmap;
+               dc.conn = op->o_conn;
+               dc.rs = rs;
+               dc.ctx = "newRDN";
+               newrdn = op->orr_newrdn;
+               nnewrdn = op->orr_nnewrdn;
+               rc = rwm_dn_massage_pretty_normalize( &dc, &op->orr_newrdn, &newrdn, &nnewrdn );
+               if ( rc != LDAP_SUCCESS ) {
+                       op->o_bd->bd_info = (BackendInfo *)on->on_info;
+                       send_ldap_error( op, rs, rc, "newRDN massage error" );
+                       goto err;
+               }
+
+               if ( op->orr_newrdn.bv_val != newrdn.bv_val ) {
+                       op->orr_newrdn = newrdn;
+                       op->orr_nnewrdn = nnewrdn;
+               }
+       }
+
        /*
         * Rewrite the dn, if needed
         */
@@ -725,6 +757,15 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
        if ( rc != LDAP_SUCCESS ) {
                op->o_bd->bd_info = (BackendInfo *)on->on_info;
                send_ldap_error( op, rs, rc, "renameDN massage error" );
+               goto err;
+       }
+
+       op->o_callback = &roc->cb;
+
+       rc = SLAP_CB_CONTINUE;
+
+       if ( 0 ) {
+err:;
                if ( op->orr_newSup != roc->ros.orr_newSup ) {
                        ch_free( op->orr_newSup->bv_val );
                        ch_free( op->orr_nnewSup->bv_val );
@@ -733,15 +774,16 @@ rwm_op_modrdn( Operation *op, SlapReply *rs )
                        op->orr_newSup = roc->ros.orr_newSup;
                        op->orr_nnewSup = roc->ros.orr_nnewSup;
                }
-               return -1;
-       }
-
-       /* TODO: rewrite newRDN, attribute types, 
-        * values of DN-valued attributes (hopefully not used in RDN)... */
 
-       op->o_callback = &roc->cb;
+               if ( op->orr_newrdn.bv_val != roc->ros.orr_newrdn.bv_val ) {
+                       ch_free( op->orr_newrdn.bv_val );
+                       ch_free( op->orr_nnewrdn.bv_val );
+                       op->orr_newrdn = roc->ros.orr_newrdn;
+                       op->orr_nnewrdn = roc->ros.orr_nnewrdn;
+               }
+       }
 
-       return SLAP_CB_CONTINUE;
+       return rc;
 }