From 77e87e66b0e783cd0717f3fed885fcde629aa434 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Thu, 24 Jun 2010 16:06:39 +0200 Subject: s4:lib/registry/ldb.c - change the "ldb_get_value" implementation to use the value cache and not an LDB lookup In addition this fixes the use of special characters in registry object names. --- source4/lib/registry/ldb.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 01d82e24e7..5aea30a287 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -467,37 +467,34 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k, DATA_BLOB *data) { struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data); - struct ldb_context *c = kd->ldb; - struct ldb_result *res; - int ret; + const char *res_name; + uint32_t idx; if (name == NULL) { return WERR_INVALID_PARAM; } + /* the default value was requested, give it back */ if (name[0] == '\0') { - /* default value */ return ldb_get_default_value(mem_ctx, k, NULL, data_type, data); - } else { - /* normal value */ - ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_ONELEVEL, - NULL, "(value=%s)", name); - - if (ret != LDB_SUCCESS) { - DEBUG(0, ("Error getting values for '%s': %s\n", - ldb_dn_get_linearized(kd->dn), ldb_errstring(c))); - return WERR_FOOBAR; - } - - if (res->count == 0) - return WERR_BADFILE; + } - reg_ldb_unpack_value(mem_ctx, res->msgs[0], NULL, data_type, data); + /* Do the search if necessary */ + if (kd->values == NULL) { + W_ERROR_NOT_OK_RETURN(cache_values(kd)); + } - talloc_free(res); + for (idx = 0; idx < kd->value_count; idx++) { + res_name = ldb_msg_find_attr_as_string(kd->values[idx], "value", + ""); + if (ldb_attr_cmp(name, res_name) == 0) { + reg_ldb_unpack_value(mem_ctx, kd->values[idx], NULL, + data_type, data); + return WERR_OK; + } } - return WERR_OK; + return WERR_BADFILE; } static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h, -- cgit