Rev 11193: Getting a basic get_predefined_key implementation to
work. in file:///home/jelmer/bzr.samba-old/4.0-regwrite/
Jelmer Vernooij
jelmer at samba.org
Mon Jun 18 21:15:39 GMT 2007
At file:///home/jelmer/bzr.samba-old/4.0-regwrite/
------------------------------------------------------------
revno: 11193
revision-id: jelmer at samba.org-20070618211530-94qthtfumeziwpyy
parent: jelmer at samba.org-20070613205358-bw2nnemz6ringkd0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 4.0-regwrite
timestamp: Mon 2007-06-18 23:15:30 +0200
message:
Getting a basic get_predefined_key implementation to work.
modified:
source/lib/registry/interface.c svn-v2:20 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2flib%2fregistry%2fcommon%2freg_interface.c
source/lib/registry/local.c local.c-20070602140117-9a3wth1mhbrq7ej1-2
source/lib/registry/registry.h svn-v2:10026 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2flib%2fregistry%2fregistry.h
source/lib/registry/tests/generic.c svn-v2:21656 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2flib%2fregistry%2ftests%2fgeneric.c
source/lib/registry/tests/registry.c registry.c-20070613193046-9w6vxztx0uea8a0p-1
=== modified file 'source/lib/registry/interface.c'
--- a/source/lib/registry/interface.c 2007-06-13 20:53:58 +0000
+++ b/source/lib/registry/interface.c 2007-06-18 21:15:30 +0000
@@ -43,21 +43,6 @@
{ 0, NULL }
};
-/** Obtain a list of predefined keys. */
-_PUBLIC_ int reg_list_predefs(TALLOC_CTX *mem_ctx, char ***predefs, uint32_t **hkeys)
-{
- int i;
- *predefs = talloc_array(mem_ctx, char *, ARRAY_SIZE(reg_predefined_keys));
- *hkeys = talloc_array(mem_ctx, uint32_t, ARRAY_SIZE(reg_predefined_keys));
-
- for (i = 0; reg_predefined_keys[i].name; i++) {
- (*predefs)[i] = talloc_strdup(mem_ctx, reg_predefined_keys[i].name);
- (*hkeys)[i] = reg_predefined_keys[i].handle;
- }
-
- return i;
-}
-
/** Obtain name of specific hkey. */
_PUBLIC_ const char *reg_get_predef_name(uint32_t hkey)
{
@@ -71,12 +56,16 @@
}
/** Get predefined key by name. */
-_PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx, const char *name, struct registry_key **key)
+_PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
+ const char *name,
+ struct registry_key **key)
{
int i;
for (i = 0; reg_predefined_keys[i].name; i++) {
- if (!strcasecmp(reg_predefined_keys[i].name, name)) return reg_get_predefined_key(ctx, reg_predefined_keys[i].handle, key);
+ if (!strcasecmp(reg_predefined_keys[i].name, name))
+ return reg_get_predefined_key(ctx, reg_predefined_keys[i].handle,
+ key);
}
DEBUG(1, ("No predefined key with name '%s'\n", name));
@@ -227,7 +216,8 @@
/**
* Set a value.
*/
-_PUBLIC_ WERROR reg_val_set(struct registry_key *key, const char *value, uint32_t type, const DATA_BLOB data)
+_PUBLIC_ WERROR reg_val_set(struct registry_key *key, const char *value,
+ uint32_t type, const DATA_BLOB data)
{
if (key == NULL)
return WERR_INVALID_PARAM;
@@ -262,8 +252,7 @@
/**
* Delete a value.
*/
-_PUBLIC_ WERROR reg_del_value(struct registry_key *key,
- const char *valname)
+_PUBLIC_ WERROR reg_del_value(struct registry_key *key, const char *valname)
{
if (key == NULL)
return WERR_INVALID_PARAM;
=== modified file 'source/lib/registry/local.c'
--- a/source/lib/registry/local.c 2007-06-13 20:53:58 +0000
+++ b/source/lib/registry/local.c 2007-06-18 21:15:30 +0000
@@ -48,10 +48,6 @@
struct hive_key *hive_key;
};
-WERROR reg_mount_hive(struct registry_context *ctx, struct reg_key_path *path,
- struct hive_key *hive);
-WERROR reg_unmount_hive(struct registry_context *ctx, struct hive_key *hive);
-
static WERROR local_open_key(TALLOC_CTX *mem_ctx,
struct registry_key *parent,
const char *path,
@@ -103,7 +99,7 @@
return WERR_OK;
}
-WERROR local_get_predefined_key (struct registry_context *ctx,
+WERROR local_get_predefined_key (const struct registry_context *ctx,
uint32_t key_id, struct registry_key **key)
{
struct registry_local *rctx = talloc_get_type(ctx, struct registry_local);
@@ -152,3 +148,27 @@
return WERR_OK;
}
+
+WERROR reg_mount_hive(struct registry_context *rctx,
+ struct hive_key *hive_key,
+ uint32_t key_id,
+ const char **elements)
+{
+ struct registry_local *reg_local = talloc_get_type(rctx, struct registry_local);
+ struct mountpoint *mp = talloc(rctx, struct mountpoint);
+ int i = 0;
+
+ mp->path.predefined_key = key_id;
+ mp->prev = mp->next = NULL;
+ mp->key = hive_key;
+ mp->path.elements = talloc_array(mp, const char *,
+ str_list_length(elements));
+ for (i = 0; elements[i]; i++) {
+ mp->path.elements[i] = elements[i];
+ }
+ mp->path.elements[i] = NULL;
+
+ DLIST_ADD(reg_local->mountpoints, mp);
+
+ return WERR_OK;
+}
=== modified file 'source/lib/registry/registry.h'
--- a/source/lib/registry/registry.h 2007-06-13 20:53:58 +0000
+++ b/source/lib/registry/registry.h 2007-06-18 21:15:30 +0000
@@ -192,8 +192,6 @@
_PUBLIC_ WERROR reg_open_wine(struct registry_context **ctx, const char *path);
-_PUBLIC_ int reg_list_predefs(TALLOC_CTX *mem_ctx, char ***predefs,
- uint32_t **hkeys);
_PUBLIC_ const char *reg_get_predef_name(uint32_t hkey);
_PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
const char *name,
@@ -251,4 +249,9 @@
WERROR reg_load_key(struct registry_context *ctx, struct registry_key *key,
const char *name, const char *filename);
+WERROR reg_mount_hive(struct registry_context *rctx,
+ struct hive_key *hive_key,
+ uint32_t key_id,
+ const char **elements);
+
#endif /* _REGISTRY_H */
=== modified file 'source/lib/registry/tests/generic.c'
--- a/source/lib/registry/tests/generic.c 2007-06-12 16:54:40 +0000
+++ b/source/lib/registry/tests/generic.c 2007-06-18 21:15:30 +0000
@@ -27,6 +27,7 @@
#include "librpc/gen_ndr/winreg.h"
struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx);
+struct torture_suite *torture_registry_registry(TALLOC_CTX *mem_ctx);
static bool test_str_regtype(struct torture_context *ctx)
{
@@ -109,6 +110,7 @@
torture_suite_add_simple_test(suite, "reg_val_description null", test_reg_val_description_nullname);
torture_suite_add_suite(suite, torture_registry_hive(mem_ctx));
+ torture_suite_add_suite(suite, torture_registry_registry(mem_ctx));
return suite;
}
=== modified file 'source/lib/registry/tests/registry.c'
--- a/source/lib/registry/tests/registry.c 2007-06-13 20:53:58 +0000
+++ b/source/lib/registry/tests/registry.c 2007-06-18 21:15:30 +0000
@@ -27,6 +27,9 @@
#include "librpc/gen_ndr/winreg.h"
#include "system/filesys.h"
+NTSTATUS torture_temp_dir(TALLOC_CTX *mem_ctx, const char *prefix,
+ const char **tempdir);
+
static bool test_get_predefined(struct torture_context *tctx,
const void *_data)
{
@@ -45,13 +48,34 @@
{
struct registry_context *rctx;
WERROR error;
+ const char *tempdir;
+ NTSTATUS status;
+ struct hive_key *hive_key;
error = reg_open_local(tctx, &rctx, NULL, NULL);
if (!W_ERROR_IS_OK(error)) {
return false;
}
- /* FIXME */
+ status = torture_temp_dir(tctx, "registry-local", &tempdir);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ error = reg_open_ldb_file(tctx,
+ talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir),
+ NULL,
+ NULL,
+ &hive_key);
+ if (!W_ERROR_IS_OK(error)) {
+ return false;
+ }
+
+ error = reg_mount_hive(rctx, hive_key, HKEY_CLASSES_ROOT, NULL);
+ if (!W_ERROR_IS_OK(error)) {
+ return false;
+ }
+
return true;
}
More information about the samba-cvs
mailing list