r25762: This test belongs best with the other checks for a valid parent, in
authorAndrew Bartlett <abartlet@samba.org>
Wed, 31 Oct 2007 03:41:36 +0000 (04:41 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:43:47 +0000 (05:43 +0100)
the objectclass module.

Andrew Bartlett

source/dsdb/samdb/ldb_modules/objectclass.c
source/dsdb/samdb/ldb_modules/subtree_rename.c
testprogs/ejs/ldap.js

index 12a63590376d6f0e834b55b51b0550bdd632af85..0cd00e38348970d86c91af2eca9d6f77232170b9 100644 (file)
@@ -865,6 +865,14 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req
        if (ldb_dn_is_special(req->op.rename.newdn)) { /* do not manipulate our control entries */
                return ldb_next_request(module, req);
        }
+       
+       /* Firstly ensure we are not trying to rename it to be a child of itself */
+       if ((ldb_dn_compare_base(req->op.rename.olddn, req->op.rename.newdn) == 0) 
+           && (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) != 0)) {
+               ldb_asprintf_errstring(module->ldb, "Cannot rename %s to be a child of itself",
+                                      ldb_dn_get_linearized(req->op.rename.olddn));
+               return LDB_ERR_UNWILLING_TO_PERFORM;
+       }
 
        h = oc_init_handle(req, module);
        if (!h) {
index 5c287233918a8f3475c96daccc0050fe76542d72..72857cb864e7c5bc63f48a9b593781bd36aeec7c 100644 (file)
@@ -163,14 +163,6 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req)
                return ldb_next_request(module, req);
        }
 
-       /* Firstly ensure we are not trying to rename it to be a child of itself */
-       if ((ldb_dn_compare_base(req->op.rename.olddn, req->op.rename.newdn) == 0) 
-           && (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) != 0)) {
-               ldb_asprintf_errstring(module->ldb, "Cannot rename %s to be a child of itself",
-                                      ldb_dn_get_linearized(req->op.rename.olddn));
-               return LDB_ERR_UNWILLING_TO_PERFORM;
-       }
-
        /* This gets complex:  We need to:
           - Do a search for all entires under this entry 
           - Wait for these results to appear
index 9be30c8eff3763351934b3b315e8282e36b0361f..b5c73e4f65a7450400a3f3b86b0ba81e5ec1ddc6 100755 (executable)
@@ -295,6 +295,13 @@ cn: LDAPtestUSER4
                assert(ok.error == 53);
        }
 
+       println("Testing ldb.rename (into non-existent container) of cn=ldaptestcontainer2," + base_dn + " to cn=ldaptestcontainer,cn=ldaptestcontainer3," + base_dn);
+       ok = ldb.rename("cn=ldaptestcontainer2," + base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer3," + base_dn);
+       if (ok.error != 53 && ok.error != 80) { /* LDAP_UNWILLING_TO_PERFORM or LDAP_OTHER*/
+               println(ok.errstr);
+               assert(ok.error == 53 || ok.error == 80);
+       }
+
        println("Testing delete (should fail, not a leaf node) of renamed cn=ldaptestcontainer2," + base_dn);
        ok = ldb.del("cn=ldaptestcontainer2," + base_dn);
        if (ok.error != 66) { /* LDB_ERR_NOT_ALLOWED_ON_NON_LEAF */