Rev 11188: Make ldb pass the current tests. in file:///home/jelmer/bzr.samba-old/4.0-regwrite/

Jelmer Vernooij jelmer at samba.org
Wed Jun 13 17:38:04 GMT 2007


At file:///home/jelmer/bzr.samba-old/4.0-regwrite/

------------------------------------------------------------
revno: 11188
revision-id: jelmer at samba.org-20070612202736-meu8bltye0rberi6
parent: jelmer at samba.org-20070612200826-54acueedast7lnmr
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 4.0-regwrite
timestamp: Tue 2007-06-12 22:27:36 +0200
message:
  Make ldb pass the current tests.
modified:
  source/lib/registry/ldb.c      svn-v2:4132 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2flib%2fregistry%2freg_backend_ldb.c
  source/lib/registry/tests/hive.c hive.c-20070612151642-hsxkm8j4r69ej3px-1
=== modified file 'source/lib/registry/ldb.c'
--- a/source/lib/registry/ldb.c	2007-06-12 16:54:40 +0000
+++ b/source/lib/registry/ldb.c	2007-06-12 20:27:36 +0000
@@ -25,6 +25,8 @@
 #include "db_wrap.h"
 #include "librpc/gen_ndr/winreg.h"
 
+static struct hive_operations reg_backend_ldb;
+
 struct ldb_key_data 
 {
 	struct hive_key key;
@@ -34,7 +36,8 @@
 	int subkey_count, value_count;
 };
 
-static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char **name, uint32_t *type, DATA_BLOB *data)
+static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char **name, 
+								 uint32_t *type, DATA_BLOB *data)
 {
 	const struct ldb_val *val;
 	*name = talloc_strdup(mem_ctx, ldb_msg_find_attr_as_string(msg, "value", NULL));
@@ -45,7 +48,8 @@
 	{
 	case REG_SZ:
 	case REG_EXPAND_SZ:
-		data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, val->data, val->length, (void **)&data->data);
+		data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, 
+											 val->data, val->length, (void **)&data->data);
 		break;
 
 	case REG_DWORD: {
@@ -73,7 +77,8 @@
 	switch (type) {
 	case REG_SZ:
 	case REG_EXPAND_SZ:
-		val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, (void *)data.data, data.length, (void **)&val.data);
+		val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, 
+										   (void *)data.data, data.length, (void **)&val.data);
 		ldb_msg_add_value(msg, "data", &val, NULL);
 		break;
 
@@ -130,7 +135,7 @@
 		return NULL;
 	}
 
-	while(mypath) {
+	while (mypath) {
 		char *keyname;
 
 		begin = strrchr(mypath, '\\');
@@ -197,7 +202,8 @@
 	return WERR_OK;
 }
 
-static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k, int idx, const char **name, uint32_t *data_type, DATA_BLOB *data)
+static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k, int idx, 
+								  const char **name, uint32_t *data_type, DATA_BLOB *data)
 {
 	struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
 	struct ldb_context *c = kd->ldb;
@@ -280,6 +286,7 @@
 	ldb_set_debug_stderr(wrap);
 
 	kd = talloc_zero(parent_ctx, struct ldb_key_data);
+	kd->key.ops = &reg_backend_ldb;
 	kd->ldb = wrap;
 	talloc_set_destructor (kd, reg_close_ldb_key);
 	kd->dn = ldb_dn_new(kd, wrap, "hive=NONE");
@@ -289,8 +296,8 @@
 	return WERR_OK;
 }
 
-static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, struct hive_key *parent, 
-						   const char *name, uint32_t access_mask, 
+static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, const struct hive_key *parent, 
+						   const char *name, const char *classname,
 						   struct security_descriptor *sd, 
 						   struct hive_key **newkey)
 {
@@ -320,7 +327,7 @@
 	return WERR_OK;
 }
 
-static WERROR ldb_del_key (struct hive_key *key, const char *child)
+static WERROR ldb_del_key (const struct hive_key *key, const char *child)
 {
 	int ret;
 	struct ldb_key_data *parentkd = talloc_get_type(key, struct ldb_key_data);
@@ -333,7 +340,9 @@
 
 	talloc_free(childdn);
 
-	if (ret < 0) {
+	if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+		return WERR_NOT_FOUND;
+	} else if (ret < 0) {
 		DEBUG(1, ("ldb_del_key: %s\n", ldb_errstring(parentkd->ldb)));
 		return WERR_FOOBAR;
 	}
@@ -390,6 +399,29 @@
 	return WERR_OK;
 }
 
+static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, 
+							   const struct hive_key *key,
+							   const char **classname, 
+							   uint32_t *num_subkeys,
+							   uint32_t *num_values,
+							   NTTIME *last_change_time)
+{
+	/* FIXME */
+	if (classname != NULL)
+		*classname = NULL;
+
+	if (num_subkeys != NULL)
+		*num_subkeys = 0;
+
+	if (num_values != NULL)
+		*num_values = 0;
+
+	if (last_change_time != NULL)
+		*last_change_time = 0;
+
+	return WERR_OK;
+}
+
 static struct hive_operations reg_backend_ldb = {
 	.name = "ldb",
 	.add_key = ldb_add_key,
@@ -399,4 +431,5 @@
 	.enum_key = ldb_get_subkey_by_id,
 	.set_value = ldb_set_value,
 	.delete_value = ldb_del_value,
+	.get_key_info = ldb_get_key_info,
 };

=== modified file 'source/lib/registry/tests/hive.c'
--- a/source/lib/registry/tests/hive.c	2007-06-12 20:08:26 +0000
+++ b/source/lib/registry/tests/hive.c	2007-06-12 20:27:36 +0000
@@ -91,7 +91,6 @@
 
 static bool hive_setup_dir(struct torture_context *tctx, void **data)
 {
-
 	struct hive_key *key;
 	WERROR error;
 
@@ -106,6 +105,23 @@
 	return true;
 }
 
+static bool hive_setup_ldb(struct torture_context *tctx, void **data)
+{
+	struct hive_key *key;
+	WERROR error;
+
+	error = reg_open_ldb_file(tctx, "bla-ldb", NULL, NULL, &key);
+	if (!W_ERROR_IS_OK(error)) {
+		fprintf(stderr, "Unable to initialize ldb hive\n");
+		return false;
+	}
+
+	*data = key;
+
+	return true;
+
+}
+
 static bool test_dir_refuses_null_location(struct torture_context *tctx)
 {
 	torture_assert_werr_equal(tctx, WERR_INVALID_PARAM, 
@@ -127,5 +143,9 @@
 	tcase = torture_suite_add_tcase(suite, "dir");
 	torture_tcase_set_fixture(tcase, hive_setup_dir, NULL);
 	tcase_add_tests(tcase);
+
+	tcase = torture_suite_add_tcase(suite, "ldb");
+	torture_tcase_set_fixture(tcase, hive_setup_ldb, NULL);
+	tcase_add_tests(tcase);
 	return suite;
 }



More information about the samba-cvs mailing list