1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-09 00: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:
Andrew Bartlett
2007-09-18 06:36:07 +00:00
committed by Gerald (Jerry) Carter
parent e882dcb7aa
commit 9cccd00dac
2 changed files with 36 additions and 9 deletions

View File

@@ -856,16 +856,38 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
goto done;
}
ret = ltdb_add_internal(module, msg);
if (ret != LDB_SUCCESS) {
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.
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;
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;
}
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) {