summaryrefslogtreecommitdiff
path: root/source4/lib/registry
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-09-23 14:30:06 -0400
committerSimo Sorce <idra@samba.org>2008-09-23 18:17:46 -0400
commit508527890adc7bedd47522a7dae0c96d2b2e4bae (patch)
tree77e510421ff8eb98c0a9b0836905ca2f67eaf42f /source4/lib/registry
parentd275cc762dad1985045d381ca211e92234d9d77d (diff)
downloadsamba-508527890adc7bedd47522a7dae0c96d2b2e4bae.tar.gz
samba-508527890adc7bedd47522a7dae0c96d2b2e4bae.tar.bz2
samba-508527890adc7bedd47522a7dae0c96d2b2e4bae.zip
Merge ldb_search() and ldb_search_exp_fmt() into a simgle function.
The previous ldb_search() interface made it way too easy to leak results, and being able to use a printf-like expression turns to be really useful.
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/ldb.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index a8a9ed597e..25b8c583ed 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -199,7 +199,7 @@ static WERROR cache_subkeys(struct ldb_key_data *kd)
struct ldb_result *res;
int ret;
- ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, "(key=*)", NULL, &res);
+ ret = ldb_search(c, c, &res, kd->dn, LDB_SCOPE_ONELEVEL, NULL, "(key=*)");
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting subkeys for '%s': %s\n",
@@ -220,8 +220,8 @@ static WERROR cache_values(struct ldb_key_data *kd)
struct ldb_result *res;
int ret;
- ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL,
- "(value=*)", NULL, &res);
+ ret = ldb_search(c, c, &res, kd->dn, LDB_SCOPE_ONELEVEL,
+ NULL, "(value=*)");
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting values for '%s': %s\n",
@@ -299,21 +299,25 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
int ret;
char *query = talloc_asprintf(mem_ctx, "(value=%s)", name);
- ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, query, NULL, &res);
+ ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_ONELEVEL, NULL, "%s", query);
talloc_free(query);
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting values for '%s': %s\n",
ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+ talloc_free(res);
return WERR_FOOBAR;
}
- if (res->count == 0)
+ if (res->count == 0) {
+ talloc_free(res);
return WERR_BADFILE;
+ }
reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), res->msgs[0], NULL, data_type, data);
+ talloc_free(res);
return WERR_OK;
}
@@ -329,7 +333,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
ldap_path = reg_path_to_ldb(mem_ctx, h, name, NULL);
- ret = ldb_search(c, ldap_path, LDB_SCOPE_BASE, "(key=*)", NULL, &res);
+ ret = ldb_search(c, mem_ctx, &res, ldap_path, LDB_SCOPE_BASE, NULL, "(key=*)");
if (ret != LDB_SUCCESS) {
DEBUG(3, ("Error opening key '%s': %s\n",
@@ -501,8 +505,8 @@ static WERROR ldb_del_key(const struct hive_key *key, const char *name)
}
/* Search for subkeys */
- ret = ldb_search(c, ldap_path, LDB_SCOPE_ONELEVEL,
- "(key=*)", NULL, &res_keys);
+ ret = ldb_search(c, mem_ctx, &res_keys, ldap_path, LDB_SCOPE_ONELEVEL,
+ NULL, "(key=*)");
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting subkeys for '%s': %s\n",
@@ -512,8 +516,8 @@ static WERROR ldb_del_key(const struct hive_key *key, const char *name)
}
/* Search for values */
- ret = ldb_search(c, ldap_path, LDB_SCOPE_ONELEVEL,
- "(value=*)", NULL, &res_vals);
+ ret = ldb_search(c, mem_ctx, &res_vals, ldap_path, LDB_SCOPE_ONELEVEL,
+ NULL, "(value=*)");
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Error getting values for '%s': %s\n",