svn commit: samba r25204 - in branches/SAMBA_4_0:
source/lib/ldb/ldb_tdb testprogs/ejs
abartlet at samba.org
abartlet at samba.org
Tue Sep 18 06:36:12 GMT 2007
Author: abartlet
Date: 2007-09-18 06:36:07 +0000 (Tue, 18 Sep 2007)
New Revision: 25204
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25204
Log:
Patch by Andrew Kroeger <andrew at 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
Modified:
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
branches/SAMBA_4_0/testprogs/ejs/ldb.js
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2007-09-18 02:43:56 UTC (rev 25203)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2007-09-18 06:36:07 UTC (rev 25204)
@@ -856,16 +856,38 @@
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) {
Modified: branches/SAMBA_4_0/testprogs/ejs/ldb.js
===================================================================
--- branches/SAMBA_4_0/testprogs/ejs/ldb.js 2007-09-18 02:43:56 UTC (rev 25203)
+++ branches/SAMBA_4_0/testprogs/ejs/ldb.js 2007-09-18 06:36:07 UTC (rev 25204)
@@ -60,6 +60,11 @@
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
More information about the samba-cvs
mailing list