summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-09-18 06:36:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:06:52 -0500
commit6a9a1bd913a7cdc865c88a290020e6bddb777f98 (patch)
treea7e646d2f3f1f97752f06d36aa374d6bbd2c8a0d /source4
parent09a5ef13844788926d4ad519f4fb15fa008e66d1 (diff)
downloadsamba-6a9a1bd913a7cdc865c88a290020e6bddb777f98.tar.gz
samba-6a9a1bd913a7cdc865c88a290020e6bddb777f98.tar.bz2
samba-6a9a1bd913a7cdc865c88a290020e6bddb777f98.zip
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 used to be commit 9cccd00dac44dd9152ec03cecf5ffac24f918445)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 324a8e3881..21661b1d46 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -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.
+
+ 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;
+ }
- 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;
+ 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) {