]> git.sur5r.net Git - openldap/commitdiff
build entry's pretty DN from parent's (ITS#5326)
authorPierangelo Masarati <ando@openldap.org>
Thu, 5 Feb 2009 18:44:52 +0000 (18:44 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 5 Feb 2009 18:44:52 +0000 (18:44 +0000)
servers/slapd/back-bdb/add.c

index 921c41d573f8fd5408811a25ec24d02da19b4a7e..f9a42f7a61dbad9e7df4aa64a81cf0f0c1be1cf3 100644 (file)
@@ -284,6 +284,26 @@ retry:     /* transaction retry */
 
        /* free parent and reader lock */
        if ( p != (Entry *)&slap_entry_root ) {
+               if ( p->e_nname.bv_len ) {
+                       struct berval ppdn;
+
+                       /* ITS#5326: use parent's DN if differs from provided one */
+                       dnParent( &op->ora_e->e_name, &ppdn );
+                       if ( !dn_match( &p->e_name, &ppdn ) ) {
+                               struct berval rdn;
+                               struct berval newdn;
+
+                               dnRdn( &op->ora_e->e_name, &rdn );
+
+                               build_new_dn( &newdn, &p->e_name, &rdn, NULL ); 
+                               ber_memfree( op->ora_e->e_name.bv_val );
+                               op->ora_e->e_name = newdn;
+
+                               /* FIXME: should check whether
+                                * dnNormalize(newdn) == e->e_nname ... */
+                       }
+               }
+
                bdb_unlocked_cache_return_entry_r( bdb, p );
        }
        p = NULL;