summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb/ldb_cache.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-11-15 01:53:44 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:45:18 +0100
commitd544879e434c36f02bfc7d1322f1179d00294669 (patch)
treee3296fdf646c1476e2318bc5d932250063892aeb /source4/lib/ldb/ldb_tdb/ldb_cache.c
parentf8bf16960e701433572d12f4c888ab271f05f485 (diff)
downloadsamba-d544879e434c36f02bfc7d1322f1179d00294669.tar.gz
samba-d544879e434c36f02bfc7d1322f1179d00294669.tar.bz2
samba-d544879e434c36f02bfc7d1322f1179d00294669.zip
r25959: Add a new special DN to LDB: @OPTIONS
Use the checkBaseOnSearch attribute to control if we should check the base DN on search requests. Also ensure we honour any errors in searching, not just errors in the supplied 'done' callback. Andrew Bartlett (This used to be commit deaac92f439ef001bfe052df170d6e34e8ba5845)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_cache.c')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_cache.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c
index de489e3d8b..77922a97c7 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_cache.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c
@@ -113,11 +113,13 @@ static int ltdb_attributes_load(struct ldb_module *module)
if (dn == NULL) goto failed;
r = ltdb_search_dn1(module, dn, msg);
+ talloc_free(dn);
if (r != LDB_SUCCESS && r != LDB_ERR_NO_SUCH_OBJECT) {
- talloc_free(dn);
goto failed;
}
- talloc_free(dn);
+ if (r == LDB_ERR_NO_SUCH_OBJECT) {
+ return 0;
+ }
/* mapping these flags onto ldap 'syntaxes' isn't strictly correct,
but its close enough for now */
for (i=0;i<msg->num_elements;i++) {
@@ -247,10 +249,10 @@ int ltdb_cache_reload(struct ldb_module *module)
int ltdb_cache_load(struct ldb_module *module)
{
struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
- struct ldb_dn *baseinfo_dn = NULL;
+ struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL;
struct ldb_dn *indexlist_dn = NULL;
uint64_t seq;
- struct ldb_message *baseinfo = NULL;
+ struct ldb_message *baseinfo = NULL, *options = NULL;
int r;
/* a very fast check to avoid extra database reads */
@@ -282,7 +284,7 @@ int ltdb_cache_load(struct ldb_module *module)
}
/* possibly initialise the baseinfo */
- if (!baseinfo->dn) {
+ if (r == LDB_ERR_NO_SUCH_OBJECT) {
if (ltdb_baseinfo_init(module) != LDB_SUCCESS) {
goto failed;
}
@@ -301,6 +303,25 @@ int ltdb_cache_load(struct ldb_module *module)
}
ltdb->sequence_number = seq;
+ /* Read an interpret database options */
+ options = talloc(ltdb->cache, struct ldb_message);
+ if (options == NULL) goto failed;
+
+ options_dn = ldb_dn_new(module, module->ldb, LTDB_OPTIONS);
+ if (options_dn == NULL) goto failed;
+
+ r= ltdb_search_dn1(module, options_dn, options);
+ if (r != LDB_SUCCESS && r != LDB_ERR_NO_SUCH_OBJECT) {
+ goto failed;
+ }
+
+ /* possibly initialise the baseinfo */
+ if (r == LDB_SUCCESS) {
+ ltdb->check_base = ldb_msg_find_attr_as_bool(options, LTDB_CHECK_BASE, false);
+ } else {
+ ltdb->check_base = false;
+ }
+
talloc_free(ltdb->cache->last_attribute.name);
memset(&ltdb->cache->last_attribute, 0, sizeof(ltdb->cache->last_attribute));
@@ -328,12 +349,16 @@ int ltdb_cache_load(struct ldb_module *module)
}
done:
+ talloc_free(options);
+ talloc_free(options_dn);
talloc_free(baseinfo);
talloc_free(baseinfo_dn);
talloc_free(indexlist_dn);
return 0;
failed:
+ talloc_free(options);
+ talloc_free(options_dn);
talloc_free(baseinfo);
talloc_free(baseinfo_dn);
talloc_free(indexlist_dn);