summaryrefslogtreecommitdiffstats
path: root/source4/lib/registry
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-06-24 16:06:39 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-06-28 23:02:55 +0200
commit77e87e66b0e783cd0717f3fed885fcde629aa434 (patch)
tree5ab710997a4460149e78cb80c431ac344d36c822 /source4/lib/registry
parent3549425b30f00adfbee7e2a16f35a17c8e4cd2f8 (diff)
downloadsamba-77e87e66b0e783cd0717f3fed885fcde629aa434.tar.gz
samba-77e87e66b0e783cd0717f3fed885fcde629aa434.tar.xz
samba-77e87e66b0e783cd0717f3fed885fcde629aa434.zip
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.
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/ldb.c37
1 files changed, 17 insertions, 20 deletions
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,