summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-06-26 23:59:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:52 -0500
commit1702f52498168c0437416dec1014cedead634774 (patch)
tree51085d868dd9e562571ccb96dac48a5dd43bd55a /source4/lib/ldb/ldb_tdb
parent14b0722edf38872ba258c27e27094536ecb93d4f (diff)
downloadsamba-1702f52498168c0437416dec1014cedead634774.tar.gz
samba-1702f52498168c0437416dec1014cedead634774.tar.bz2
samba-1702f52498168c0437416dec1014cedead634774.zip
r7936: new ldb_dn_explode and ldb_dn_casefold functions and co
(This used to be commit 7ccf21ab4eeb9821e457308a239f2103a106fb12)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index f8c98d6712..bc61378f18 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -38,6 +38,7 @@
#include "includes.h"
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
+#include "ldb/include/ldb_dn.h"
#include "ldb/ldb_tdb/ldb_tdb.h"
#define LDBLOCK "INT_LDBLOCK"
@@ -107,9 +108,30 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn)
talloc_free(attr_name_folded);
}
talloc_free(attr_name);
- } else {
- dn_folded = ldb_dn_fold(module->ldb, dn,
- module, ltdb_case_fold_attr_required);
+ }
+ /* special cases for tdb */
+ else if (*dn == '@' || strncmp(LDBLOCK, dn, strlen(LDBLOCK)) == 0) {
+
+ dn_folded = talloc_strdup(ldb, dn);
+ }
+ else {
+ struct ldb_dn *edn, *cedn;
+
+ edn = ldb_dn_explode(ldb, dn);
+ if (!edn)
+ goto failed;
+
+ cedn = ldb_dn_casefold(ldb, edn, module,
+ ltdb_case_fold_attr_required);
+ if (!edn)
+ goto failed;
+
+ dn_folded = ldb_dn_linearize(ldb, cedn);
+ if (!dn_folded)
+ goto failed;
+
+ talloc_free(edn);
+ talloc_free(cedn);
}
if (!dn_folded) {
@@ -141,6 +163,7 @@ failed:
static int ltdb_lock(struct ldb_module *module, const char *lockname)
{
struct ltdb_private *ltdb = module->private_data;
+ char *lock_dn;
TDB_DATA key;
int ret;
@@ -148,14 +171,21 @@ static int ltdb_lock(struct ldb_module *module, const char *lockname)
return -1;
}
- key = ltdb_key(module, lockname);
+ lock_dn = talloc_asprintf(module->ldb, "%s_%s", LDBLOCK, lockname);
+ if (lock_dn == NULL) {
+ return -1;
+ }
+
+ key = ltdb_key(module, lock_dn);
if (!key.dptr) {
+ talloc_free(lock_dn);
return -1;
}
ret = tdb_chainlock(ltdb->tdb, key);
talloc_free(key.dptr);
+ talloc_free(lock_dn);
return ret;
}
@@ -166,20 +196,28 @@ static int ltdb_lock(struct ldb_module *module, const char *lockname)
static int ltdb_unlock(struct ldb_module *module, const char *lockname)
{
struct ltdb_private *ltdb = module->private_data;
+ char *lock_dn;
TDB_DATA key;
if (lockname == NULL) {
return -1;
}
- key = ltdb_key(module, lockname);
+ lock_dn = talloc_asprintf(module->ldb, "%s_%s", LDBLOCK, lockname);
+ if (lock_dn == NULL) {
+ return -1;
+ }
+
+ key = ltdb_key(module, lock_dn);
if (!key.dptr) {
+ talloc_free(lock_dn);
return -1;
}
tdb_chainunlock(ltdb->tdb, key);
talloc_free(key.dptr);
+ talloc_free(lock_dn);
return 0;
}