[SCM] Samba Shared Repository - branch master updated
Matthias Dieter Wallnöfer
mdw at samba.org
Mon Jun 28 15:03:33 MDT 2010
The branch, master has been updated
via ba01b21... s4:lib/registry/ldb.c - fix memory handling in "ldb_open_key"
via 094c103... s4:lib/ldb/registry.c - handle the classname in the right way
via 2fb3d8a... s4:lib/registry/ldb.c - remove really useless "local_ctx"
via 3935502... s4:lib/registry/ldb.c - retrieve the classname correctly in "ldb_get_subkey_by_id"
via 77e87e6... s4:lib/registry/ldb.c - change the "ldb_get_value" implementation to use the value cache and not an LDB lookup
from 3549425... s3: Change exit on immediate socket failure.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit ba01b216e23ddae9961f7120792969fc2fe075b1
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Mon Jun 28 21:17:37 2010 +0200
s4:lib/registry/ldb.c - fix memory handling in "ldb_open_key"
commit 094c1034d2fb11e746261ff5b5048cd52fce2938
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Mon Jun 28 21:15:17 2010 +0200
s4:lib/ldb/registry.c - handle the classname in the right way
This is for "ldb_get_key_info".
commit 2fb3d8a6cc94bd74974a2cc11996a2032774b08c
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Thu Jun 24 20:11:09 2010 +0200
s4:lib/registry/ldb.c - remove really useless "local_ctx"
"mem_ctx" should fit for these few local allocations.
commit 3935502c67edd436134bac0c663ed3d5b593ec32
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Thu Jun 24 16:17:16 2010 +0200
s4:lib/registry/ldb.c - retrieve the classname correctly in "ldb_get_subkey_by_id"
commit 77e87e66b0e783cd0717f3fed885fcde629aa434
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Thu Jun 24 16:06:39 2010 +0200
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.
-----------------------------------------------------------------------
Summary of changes:
source4/lib/registry/ldb.c | 74 ++++++++++++++++++++++----------------------
1 files changed, 37 insertions(+), 37 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 01d82e2..f0a1c43 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -35,6 +35,7 @@ struct ldb_key_data
struct ldb_dn *dn;
struct ldb_message **subkeys, **values;
unsigned int subkey_count, value_count;
+ const char *classname;
};
static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx,
@@ -275,19 +276,15 @@ static struct ldb_dn *reg_path_to_ldb(TALLOC_CTX *mem_ctx,
const struct hive_key *from,
const char *path, const char *add)
{
- TALLOC_CTX *local_ctx;
struct ldb_dn *ret;
char *mypath = talloc_strdup(mem_ctx, path);
char *begin;
struct ldb_key_data *kd = talloc_get_type(from, struct ldb_key_data);
struct ldb_context *ldb = kd->ldb;
- local_ctx = talloc_new(mem_ctx);
-
ret = ldb_dn_new(mem_ctx, ldb, add);
if (!ldb_dn_validate(ret)) {
talloc_free(ret);
- talloc_free(local_ctx);
return NULL;
}
@@ -301,10 +298,10 @@ static struct ldb_dn *reg_path_to_ldb(TALLOC_CTX *mem_ctx,
if (keyname[0] != '\0') {
if (!ldb_dn_add_base_fmt(ret, "key=%s",
- reg_ldb_escape(local_ctx,
+ reg_ldb_escape(mem_ctx,
keyname)))
{
- talloc_free(local_ctx);
+ talloc_free(ret);
return NULL;
}
}
@@ -318,8 +315,6 @@ static struct ldb_dn *reg_path_to_ldb(TALLOC_CTX *mem_ctx,
ldb_dn_add_base(ret, kd->dn);
- talloc_free(local_ctx);
-
return ret;
}
@@ -372,14 +367,13 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
const char **classname,
NTTIME *last_mod_time)
{
- struct ldb_message_element *el;
struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
/* Initialization */
if (name != NULL)
*name = NULL;
if (classname != NULL)
- *classname = NULL; /* TODO: Store properly */
+ *classname = NULL;
if (last_mod_time != NULL)
*last_mod_time = 0; /* TODO: we need to add this to the
ldb backend properly */
@@ -392,12 +386,12 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
if (idx >= kd->subkey_count)
return WERR_NO_MORE_ITEMS;
- el = ldb_msg_find_element(kd->subkeys[idx], "key");
- SMB_ASSERT(el != NULL);
- SMB_ASSERT(el->num_values != 0);
-
if (name != NULL)
- *name = talloc_strdup(mem_ctx, (char *)el->values[0].data);
+ *name = talloc_strdup(mem_ctx,
+ ldb_msg_find_attr_as_string(kd->subkeys[idx], "key", NULL));
+ if (classname != NULL)
+ *classname = talloc_strdup(mem_ctx,
+ ldb_msg_find_attr_as_string(kd->subkeys[idx], "classname", NULL));
return WERR_OK;
}
@@ -467,37 +461,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,
@@ -531,9 +522,14 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
}
newkd = talloc_zero(mem_ctx, struct ldb_key_data);
+ W_ERROR_HAVE_NO_MEMORY(newkd);
newkd->key.ops = ®_backend_ldb;
newkd->ldb = talloc_reference(newkd, kd->ldb);
- newkd->dn = ldb_dn_copy(mem_ctx, res->msgs[0]->dn);
+ newkd->dn = ldb_dn_copy(newkd, res->msgs[0]->dn);
+ newkd->classname = talloc_steal(newkd,
+ ldb_msg_find_attr_as_string(res->msgs[0], "classname", NULL);
+
+ talloc_free(res);
*key = (struct hive_key *)newkd;
@@ -626,6 +622,7 @@ static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
newkd->ldb = talloc_reference(newkd, parentkd->ldb);
newkd->key.ops = ®_backend_ldb;
newkd->dn = talloc_steal(newkd, msg->dn);
+ newkd->classname = talloc_steal(newkd, classname);
*newkey = (struct hive_key *)newkd;
@@ -913,11 +910,14 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
if (kd->subkeys == NULL) {
W_ERROR_NOT_OK_RETURN(cache_subkeys(kd));
}
-
if (kd->values == NULL) {
W_ERROR_NOT_OK_RETURN(cache_values(kd));
}
+ if (classname != NULL) {
+ *classname = kd->classname;
+ }
+
if (num_subkeys != NULL) {
*num_subkeys = kd->subkey_count;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list