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,16 +856,38 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ltdb_add_internal(module, msg);
|
if (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) == 0) {
|
||||||
if (ret != LDB_SUCCESS) {
|
/* The rename operation is apparently only changing case -
|
||||||
goto done;
|
the DNs are the same. Delete the old DN before adding
|
||||||
}
|
the new one to avoid a TDB_ERR_EXISTS error.
|
||||||
|
|
||||||
tret = ltdb_delete_internal(module, req->op.rename.olddn);
|
The only drawback to this is that if the delete
|
||||||
if (tret != LDB_SUCCESS) {
|
succeeds but the add fails, we rely on the
|
||||||
ltdb_delete_internal(module, req->op.rename.newdn);
|
transaction to roll this all back. */
|
||||||
ret = LDB_ERR_OPERATIONS_ERROR;
|
ret = ltdb_delete_internal(module, req->op.rename.olddn);
|
||||||
goto done;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
tret = ltdb_delete_internal(module, req->op.rename.olddn);
|
||||||
|
if (tret != LDB_SUCCESS) {
|
||||||
|
ltdb_delete_internal(module, req->op.rename.newdn);
|
||||||
|
ret = LDB_ERR_OPERATIONS_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltdb_ac->callback) {
|
if (ltdb_ac->callback) {
|
||||||
|
|||||||
@@ -60,6 +60,11 @@ x: 4
|
|||||||
res = ldb.search("x=4", NULL, ldb.SCOPE_DEFAULT, attrs);
|
res = ldb.search("x=4", NULL, ldb.SCOPE_DEFAULT, attrs);
|
||||||
assert(res.msgs[0].dn == "cn=x3,cn=test");
|
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("
|
ok = ldb.modify("
|
||||||
dn: cn=x3,cn=test
|
dn: cn=x3,cn=test
|
||||||
changetype: modify
|
changetype: modify
|
||||||
|
|||||||
Reference in New Issue
Block a user