mirror of
https://github.com/samba-team/samba.git
synced 2025-12-10 04:23:50 +03:00
r25204: Patch by Andrew Kroeger <andrew@sprocks.gotdns.com> fixing bug #4958 -
rename of ldb entries for a case change (only). I've modified the testsuite to verify this. Andrew Bartlett
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
e882dcb7aa
commit
9cccd00dac
@@ -856,6 +856,27 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) == 0) {
|
||||
/* The rename operation is apparently only changing case -
|
||||
the DNs are the same. Delete the old DN before adding
|
||||
the new one to avoid a TDB_ERR_EXISTS error.
|
||||
|
||||
The only drawback to this is that if the delete
|
||||
succeeds but the add fails, we rely on the
|
||||
transaction to roll this all back. */
|
||||
ret = ltdb_delete_internal(module, req->op.rename.olddn);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = ltdb_add_internal(module, msg);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
/* The rename operation is changing DNs. Try to add the new
|
||||
DN first to avoid clobbering another DN not related to
|
||||
this rename operation. */
|
||||
ret = ltdb_add_internal(module, msg);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
goto done;
|
||||
@@ -867,6 +888,7 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
|
||||
ret = LDB_ERR_OPERATIONS_ERROR;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (ltdb_ac->callback) {
|
||||
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
|
||||
|
||||
@@ -60,6 +60,11 @@ x: 4
|
||||
res = ldb.search("x=4", NULL, ldb.SCOPE_DEFAULT, attrs);
|
||||
assert(res.msgs[0].dn == "cn=x3,cn=test");
|
||||
|
||||
ok = ldb.rename("cn=x3,cn=test", "cn=X3,cn=test");
|
||||
assert(ok.error == 0);
|
||||
res = ldb.search("x=4", NULL, ldb.SCOPE_DEFAULT, attrs);
|
||||
assert(res.msgs[0].dn == "cn=X3,cn=test");
|
||||
|
||||
ok = ldb.modify("
|
||||
dn: cn=x3,cn=test
|
||||
changetype: modify
|
||||
|
||||
Reference in New Issue
Block a user