diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/registry/README | 15 | ||||
-rw-r--r-- | source4/lib/registry/common/reg_interface.c | 61 | ||||
-rw-r--r-- | source4/lib/registry/reg_backend_rpc.c | 5 | ||||
-rw-r--r-- | source4/lib/registry/reg_samba.c | 19 | ||||
-rw-r--r-- | source4/lib/registry/tools/regdiff.c | 8 | ||||
-rw-r--r-- | source4/lib/registry/tools/regshell.c | 25 | ||||
-rw-r--r-- | source4/lib/registry/tools/regtree.c | 4 |
7 files changed, 67 insertions, 70 deletions
diff --git a/source4/lib/registry/README b/source4/lib/registry/README index 757029cdc2..c91d361acd 100644 --- a/source4/lib/registry/README +++ b/source4/lib/registry/README @@ -1,6 +1,5 @@ This is the registry library. The registry is basically a bunch of hives -(HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, etc) that can be loaded from -different places. +that can be loaded from different places. The various registry backends provide support for loading/saving specific types of hives: @@ -28,3 +27,15 @@ registry:HKEY_CURRENT_USER = nt4:NTUSER.DAT registry:HKEY_LOCAL_MACHINE = ldb:tdb://registry.tdb WERR_NOT_SUPPORTED will be returned for all hives that haven't been set. + +On Windows the various registry hives are loaded from: + +HKEY_CURRENT_CONFIG: %SystemRoot%\System32\Config\System +HKEY_CURRENT_USER: %Profile%\NTUser.dat +HKEY_LOCAL_MACHINE\SAM: %SystemRoot%\System32\Config\Sam +HKEY_LOCAL_MACHINE\Security: %SystemRoot%\System32\Config\Security +HKEY_LOCAL_MACHINE\Software: %SystemRoot%\System32\Config\Software +HKEY_LOCAL_MACHINE\System: %SystemRoot%\System32\Config\System +HKEY_USERS\.DEFAULT: %SystemRoot%\System32\Config\Default +HKEY_LOCAL_MACHINE\HARDWARE: is autogenerated + diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c index ba65e570c4..ee140e150f 100644 --- a/source4/lib/registry/common/reg_interface.c +++ b/source4/lib/registry/common/reg_interface.c @@ -74,9 +74,9 @@ BOOL reg_has_backend(const char *backend) } static struct { - enum reg_predefined_key handle; + uint32_t handle; const char *name; -} hkey_names[] = +} predef_names[] = { {HKEY_CLASSES_ROOT,"HKEY_CLASSES_ROOT" }, {HKEY_CURRENT_USER,"HKEY_CURRENT_USER" }, @@ -90,39 +90,39 @@ static struct { { 0, NULL } }; -int reg_list_predefs(TALLOC_CTX *mem_ctx, char ***hives, enum reg_predefined_key **hkeys) +int reg_list_predefs(TALLOC_CTX *mem_ctx, char ***predefs, uint32_t **hkeys) { int i; - *hives = talloc_array_p(mem_ctx, char *, ARRAY_SIZE(hkey_names)); - *hkeys = talloc_array_p(mem_ctx, enum reg_predefined_key, ARRAY_SIZE(hkey_names)); + *predefs = talloc_array_p(mem_ctx, char *, ARRAY_SIZE(predef_names)); + *hkeys = talloc_array_p(mem_ctx, uint32_t, ARRAY_SIZE(predef_names)); - for (i = 0; hkey_names[i].name; i++) { - (*hives)[i] = talloc_strdup(mem_ctx, hkey_names[i].name); - (*hkeys)[i] = hkey_names[i].handle; + for (i = 0; predef_names[i].name; i++) { + (*predefs)[i] = talloc_strdup(mem_ctx, predef_names[i].name); + (*hkeys)[i] = predef_names[i].handle; } return i; } -const char *reg_get_hkey_name(enum reg_predefined_key hkey) +const char *reg_get_predef_name(uint32_t hkey) { int i; - for (i = 0; hkey_names[i].name; i++) { - if (hkey_names[i].handle == hkey) return hkey_names[i].name; + for (i = 0; predef_names[i].name; i++) { + if (predef_names[i].handle == hkey) return predef_names[i].name; } return NULL; } -WERROR reg_get_hive_by_name(struct registry_context *ctx, const char *name, struct registry_key **key) +WERROR reg_get_predefined_key_by_name(struct registry_context *ctx, const char *name, struct registry_key **key) { int i; - for (i = 0; hkey_names[i].name; i++) { - if (!strcmp(hkey_names[i].name, name)) return reg_get_hive(ctx, hkey_names[i].handle, key); + for (i = 0; predef_names[i].name; i++) { + if (!strcmp(predef_names[i].name, name)) return reg_get_predefined_key(ctx, predef_names[i].handle, key); } - DEBUG(1, ("No hive with name '%s'\n", name)); + DEBUG(1, ("No predefined key with name '%s'\n", name)); return WERR_BADFILE; } @@ -134,12 +134,12 @@ WERROR reg_close (struct registry_context *ctx) return WERR_OK; } -WERROR reg_get_hive(struct registry_context *ctx, enum reg_predefined_key hkey, struct registry_key **key) +WERROR reg_get_predefined_key(struct registry_context *ctx, uint32_t hkey, struct registry_key **key) { - WERROR ret = ctx->get_hive(ctx, hkey, key); + WERROR ret = ctx->get_predefined_key(ctx, hkey, key); if (W_ERROR_IS_OK(ret)) { - (*key)->name = talloc_strdup(*key, reg_get_hkey_name(hkey)); + (*key)->name = talloc_strdup(*key, reg_get_predef_name(hkey)); (*key)->path = ""; } @@ -147,7 +147,7 @@ WERROR reg_get_hive(struct registry_context *ctx, enum reg_predefined_key hkey, } /* Open a registry file/host/etc */ -WERROR reg_open_hive(struct registry_context *parent_ctx, const char *backend, const char *location, const char *credentials, struct registry_key **root) +WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *backend, const char *location, const char *credentials, struct registry_key **root) { struct registry_hive *rethive; struct registry_key *retkey = NULL; @@ -169,7 +169,6 @@ WERROR reg_open_hive(struct registry_context *parent_ctx, const char *backend, c rethive->location = location?talloc_strdup(rethive, location):NULL; rethive->functions = entry->hive_functions; rethive->backend_data = NULL; - rethive->reg_ctx = parent_ctx; werr = entry->hive_functions->open_hive(rethive, &retkey); @@ -193,26 +192,26 @@ WERROR reg_open_hive(struct registry_context *parent_ctx, const char *backend, c return WERR_OK; } -/* Open a key by name (including the hive name!) */ +/* Open a key by name (including the predefined key name!) */ WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle, const char *name, struct registry_key **result) { - struct registry_key *hive; + struct registry_key *predef; WERROR error; - int hivelength; - char *hivename; + int predeflength; + char *predefname; - if(strchr(name, '\\')) hivelength = strchr(name, '\\')-name; - else hivelength = strlen(name); + if(strchr(name, '\\')) predeflength = strchr(name, '\\')-name; + else predeflength = strlen(name); - hivename = strndup(name, hivelength); - error = reg_get_hive_by_name(handle, hivename, &hive); - SAFE_FREE(hivename); + predefname = strndup(name, predeflength); + error = reg_get_predefined_key_by_name(handle, predefname, &predef); + SAFE_FREE(predefname); if(!W_ERROR_IS_OK(error)) { return error; } - return reg_open_key(mem_ctx, hive, name, result); + return reg_open_key(mem_ctx, predef, name, result); } /* Open a key @@ -484,7 +483,7 @@ WERROR reg_key_add_name_recursive_abs(struct registry_context *handle, const cha else hivelength = strlen(name); hivename = strndup(name, hivelength); - error = reg_get_hive_by_name(handle, hivename, &hive); + error = reg_get_predefined_key_by_name(handle, hivename, &hive); SAFE_FREE(hivename); if(!W_ERROR_IS_OK(error)) return error; diff --git a/source4/lib/registry/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc.c index 927ed7fcaa..78c45f6365 100644 --- a/source4/lib/registry/reg_backend_rpc.c +++ b/source4/lib/registry/reg_backend_rpc.c @@ -93,7 +93,7 @@ struct { static WERROR rpc_query_key(struct registry_key *k); -static WERROR rpc_get_hive (struct registry_context *ctx, uint32 hkey_type, struct registry_key **k) +static WERROR rpc_get_predefined_key (struct registry_context *ctx, uint32 hkey_type, struct registry_key **k) { int n; struct registry_hive *h; @@ -113,7 +113,6 @@ static WERROR rpc_get_hive (struct registry_context *ctx, uint32 hkey_type, stru h->functions = ®_backend_rpc; h->location = NULL; h->backend_data = ctx->backend_data; - h->reg_ctx = ctx; (*k) = h->root = talloc_p(h, struct registry_key); (*k)->hive = h; @@ -380,7 +379,7 @@ WERROR reg_open_remote (struct registry_context **ctx, const char *user, const c return ntstatus_to_werror(status); } - (*ctx)->get_hive = rpc_get_hive; + (*ctx)->get_predefined_key = rpc_get_predefined_key; talloc_set_destructor(*ctx, rpc_close); diff --git a/source4/lib/registry/reg_samba.c b/source4/lib/registry/reg_samba.c index a19029524d..62973a14ab 100644 --- a/source4/lib/registry/reg_samba.c +++ b/source4/lib/registry/reg_samba.c @@ -23,12 +23,12 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_REGISTRY -static WERROR reg_samba_get_hive (struct registry_context *ctx, uint32 hkey, struct registry_key **k) +static WERROR reg_samba_get_predef (struct registry_context *ctx, uint32 hkey, struct registry_key **k) { WERROR error; const char *conf; char *backend, *location; - const char *hivename = reg_get_hkey_name(hkey); + const char *hivename = reg_get_predef_name(hkey); *k = NULL; @@ -45,7 +45,18 @@ static WERROR reg_samba_get_hive (struct registry_context *ctx, uint32 hkey, str *location = '\0'; location++; } - + + /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes + * and HKEY_CURRENT_USER\Software\Classes */ + + /* FIXME: HKEY_CURRENT_CONFIG is an alias for HKEY_LOCAL_MACHINE\System\CurrentControlSet\Hardware Profiles\Current */ + + /* FIXME: HKEY_PERFORMANCE_DATA is dynamically generated */ + + /* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */ + + /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */ + error = reg_open_hive(ctx, backend, location, NULL, k); talloc_destroy(backend); @@ -56,7 +67,7 @@ static WERROR reg_samba_get_hive (struct registry_context *ctx, uint32 hkey, str WERROR reg_open_local (struct registry_context **ctx) { *ctx = talloc_p(NULL, struct registry_context); - (*ctx)->get_hive = reg_samba_get_hive; + (*ctx)->get_predefined_key = reg_samba_get_predef; return WERR_OK; } diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index dfa85d636f..8d88cafe59 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -175,15 +175,15 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, for(i = HKEY_CLASSES_ROOT; i <= HKEY_PERFORMANCE_NLSTEXT; i++) { struct registry_key *r1, *r2; - error = reg_get_hive(h1, i, &r1); + error = reg_get_predefined_key(h1, i, &r1); if (!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to open hive %s for backend 1\n", reg_get_hkey_name(i))); + DEBUG(0, ("Unable to open hive %s for backend 1\n", reg_get_predef_name(i))); continue; } - error = reg_get_hive(h2, i, &r2); + error = reg_get_predefined_key(h2, i, &r2); if (!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to open hive %s for backend 2\n", reg_get_hkey_name(i))); + DEBUG(0, ("Unable to open hive %s for backend 2\n", reg_get_predef_name(i))); continue; } diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 3fd9dab268..47d84c1f62 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -162,28 +162,6 @@ static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_key * return NULL; } -static struct registry_key *cmd_hive(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) -{ - if (!cur->hive->reg_ctx) { - fprintf(stderr, "Only one hive loaded\n"); - return cur; - } - - if (argc == 1) { - printf("%s\n", cur->hive->root->name); - } else { - struct registry_key *newroot; - WERROR error = reg_get_hive_by_name(cur->hive->reg_ctx, argv[1], &newroot); - if (W_ERROR_IS_OK(error)) { - return newroot; - } else { - fprintf(stderr, "Can't switch to hive %s: %s\n", cur->hive->root->name, win_errstr(error)); - } - } - - return NULL; -} - static struct registry_key *cmd_exit(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { exit(0); @@ -199,7 +177,6 @@ struct { struct registry_key *(*handle)(TALLOC_CTX *mem_ctx, struct registry_key *, int argc, char **argv); } regshell_cmds[] = { {"ck", "cd", "Change current key", cmd_ck }, - {"ch", "hive", "Change current hive", cmd_hive }, {"info", "i", "Show detailed information of a key", cmd_info }, {"list", "ls", "List values/keys in current key", cmd_ls }, {"mkkey", "mkdir", "Make new key", cmd_mkkey }, @@ -407,7 +384,7 @@ static char **reg_completion(const char *text, int start, int end) if (h) { /*FIXME: What if HKEY_CLASSES_ROOT is not present ? */ - reg_get_hive(h, HKEY_CLASSES_ROOT, &curkey); + reg_get_predefined_key(h, HKEY_CLASSES_ROOT, &curkey); } poptFreeContext(pc); diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 7adeeea731..a6beb2b484 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -124,9 +124,9 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals) print_tree(0, root, fullpath, no_values); } else { for(i = HKEY_CLASSES_ROOT; i < HKEY_PERFORMANCE_NLSTEXT; i++) { - error = reg_get_hive(h, i, &root); + error = reg_get_predefined_key(h, i, &root); if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Skipping %s\n", reg_get_hkey_name(i)); + fprintf(stderr, "Skipping %s\n", reg_get_predef_name(i)); continue; } print_tree(0, root, fullpath, no_values); |