Author: jelmer Date: 2007-08-04 18:16:33 +0000 (Sat, 04 Aug 2007) New Revision: 24220
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24220 Log: Getting a basic get_predefined_key implementation to work. Modified: branches/4.0-regwrite/ branches/4.0-regwrite/source/lib/registry/interface.c branches/4.0-regwrite/source/lib/registry/local.c branches/4.0-regwrite/source/lib/registry/registry.h branches/4.0-regwrite/source/lib/registry/tests/generic.c branches/4.0-regwrite/source/lib/registry/tests/registry.c Changeset: Property changes on: branches/4.0-regwrite ___________________________________________________________________ Name: bzr:revision-info - timestamp: Wed 2007-06-13 22:53:58.466000080 +0200 committer: Jelmer Vernooij <[EMAIL PROTECTED]> properties: branch-nick: 4.0-regwrite rebase-of: [EMAIL PROTECTED] + timestamp: Mon 2007-06-18 23:15:30.483000040 +0200 committer: Jelmer Vernooij <[EMAIL PROTECTED]> properties: branch-nick: 4.0-regwrite rebase-of: [EMAIL PROTECTED] Name: bzr:file-ids - source/lib/registry/tests/registry.c registry.c-20070613193046-9w6vxztx0uea8a0p-1 + Name: bzr:revision-id:v3-trunk0 - 11140 [EMAIL PROTECTED] 11142 [EMAIL PROTECTED] 11143 [EMAIL PROTECTED] 11144 [EMAIL PROTECTED] 11145 [EMAIL PROTECTED] 11146 [EMAIL PROTECTED] 11147 [EMAIL PROTECTED] 11148 [EMAIL PROTECTED] 11149 [EMAIL PROTECTED] 11150 [EMAIL PROTECTED] 11151 [EMAIL PROTECTED] 11152 [EMAIL PROTECTED] 11153 [EMAIL PROTECTED] 11154 [EMAIL PROTECTED] 11155 [EMAIL PROTECTED] 11156 [EMAIL PROTECTED] 11157 [EMAIL PROTECTED] 11158 [EMAIL PROTECTED] 11159 [EMAIL PROTECTED] 11160 [EMAIL PROTECTED] 11161 [EMAIL PROTECTED] 11162 [EMAIL PROTECTED] 11163 [EMAIL PROTECTED] 11164 [EMAIL PROTECTED] 11165 [EMAIL PROTECTED] 11166 [EMAIL PROTECTED] 11167 [EMAIL PROTECTED] 11168 [EMAIL PROTECTED] 11169 [EMAIL PROTECTED] 11170 [EMAIL PROTECTED] 11171 [EMAIL PROTECTED] 11172 [EMAIL PROTECTED] 11173 [EMAIL PROTECTED] 11174 [EMAIL PROTECTED] 11175 [EMAIL PROTECTED] 11176 [EMAIL PROTECTED] 11177 [EMAIL PROTECTED] 11178 [EMAIL PROTECTED] 11179 [EMAIL PROTECTED] 11180 [EMAIL PROTECTED] 11181 [EMAIL PROTECTED] 11182 [EMAIL PROTECTED] 11183 [EMAIL PROTECTED] 11184 [EMAIL PROTECTED] 11185 [EMAIL PROTECTED] 11186 [EMAIL PROTECTED] 11187 [EMAIL PROTECTED] 11188 [EMAIL PROTECTED] 11189 [EMAIL PROTECTED] 11190 [EMAIL PROTECTED] 11191 [EMAIL PROTECTED] 11192 [EMAIL PROTECTED] + 11140 [EMAIL PROTECTED] 11142 [EMAIL PROTECTED] 11143 [EMAIL PROTECTED] 11144 [EMAIL PROTECTED] 11145 [EMAIL PROTECTED] 11146 [EMAIL PROTECTED] 11147 [EMAIL PROTECTED] 11148 [EMAIL PROTECTED] 11149 [EMAIL PROTECTED] 11150 [EMAIL PROTECTED] 11151 [EMAIL PROTECTED] 11152 [EMAIL PROTECTED] 11153 [EMAIL PROTECTED] 11154 [EMAIL PROTECTED] 11155 [EMAIL PROTECTED] 11156 [EMAIL PROTECTED] 11157 [EMAIL PROTECTED] 11158 [EMAIL PROTECTED] 11159 [EMAIL PROTECTED] 11160 [EMAIL PROTECTED] 11161 [EMAIL PROTECTED] 11162 [EMAIL PROTECTED] 11163 [EMAIL PROTECTED] 11164 [EMAIL PROTECTED] 11165 [EMAIL PROTECTED] 11166 [EMAIL PROTECTED] 11167 [EMAIL PROTECTED] 11168 [EMAIL PROTECTED] 11169 [EMAIL PROTECTED] 11170 [EMAIL PROTECTED] 11171 [EMAIL PROTECTED] 11172 [EMAIL PROTECTED] 11173 [EMAIL PROTECTED] 11174 [EMAIL PROTECTED] 11175 [EMAIL PROTECTED] 11176 [EMAIL PROTECTED] 11177 [EMAIL PROTECTED] 11178 [EMAIL PROTECTED] 11179 [EMAIL PROTECTED] 11180 [EMAIL PROTECTED] 11181 [EMAIL PROTECTED] 11182 [EMAIL PROTECTED] 11183 [EMAIL PROTECTED] 11184 [EMAIL PROTECTED] 11185 [EMAIL PROTECTED] 11186 [EMAIL PROTECTED] 11187 [EMAIL PROTECTED] 11188 [EMAIL PROTECTED] 11189 [EMAIL PROTECTED] 11190 [EMAIL PROTECTED] 11191 [EMAIL PROTECTED] 11192 [EMAIL PROTECTED] 11193 [EMAIL PROTECTED] Modified: branches/4.0-regwrite/source/lib/registry/interface.c =================================================================== --- branches/4.0-regwrite/source/lib/registry/interface.c 2007-08-04 18:16:25 UTC (rev 24219) +++ branches/4.0-regwrite/source/lib/registry/interface.c 2007-08-04 18:16:33 UTC (rev 24220) @@ -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: branches/4.0-regwrite/source/lib/registry/local.c =================================================================== --- branches/4.0-regwrite/source/lib/registry/local.c 2007-08-04 18:16:25 UTC (rev 24219) +++ branches/4.0-regwrite/source/lib/registry/local.c 2007-08-04 18:16:33 UTC (rev 24220) @@ -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: branches/4.0-regwrite/source/lib/registry/registry.h =================================================================== --- branches/4.0-regwrite/source/lib/registry/registry.h 2007-08-04 18:16:25 UTC (rev 24219) +++ branches/4.0-regwrite/source/lib/registry/registry.h 2007-08-04 18:16:33 UTC (rev 24220) @@ -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: branches/4.0-regwrite/source/lib/registry/tests/generic.c =================================================================== --- branches/4.0-regwrite/source/lib/registry/tests/generic.c 2007-08-04 18:16:25 UTC (rev 24219) +++ branches/4.0-regwrite/source/lib/registry/tests/generic.c 2007-08-04 18:16:33 UTC (rev 24220) @@ -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: branches/4.0-regwrite/source/lib/registry/tests/registry.c =================================================================== --- branches/4.0-regwrite/source/lib/registry/tests/registry.c 2007-08-04 18:16:25 UTC (rev 24219) +++ branches/4.0-regwrite/source/lib/registry/tests/registry.c 2007-08-04 18:16:33 UTC (rev 24220) @@ -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; }
