diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-05-22 18:49:25 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:53:53 -0500 |
commit | bf52e242f53aeaac33eea69fbdfb3477634b90fb (patch) | |
tree | 76b04dc95e3e7befd45180a661cd7f55d085701e /source4/lib/registry/tools | |
parent | 4e9d01c2a7cd044ac4b466a1039c9a7e3978d6ef (diff) | |
download | samba-bf52e242f53aeaac33eea69fbdfb3477634b90fb.tar.gz samba-bf52e242f53aeaac33eea69fbdfb3477634b90fb.tar.bz2 samba-bf52e242f53aeaac33eea69fbdfb3477634b90fb.zip |
r825: - Introduce support for multiple roots (or 'hives')
- Clean up rpc backend (possible now that multiple hives are supported)
(This used to be commit 8cd1b6bc70510fe576135a66351e9e3ea895c9ff)
Diffstat (limited to 'source4/lib/registry/tools')
-rw-r--r-- | source4/lib/registry/tools/gregedit.c | 31 | ||||
-rw-r--r-- | source4/lib/registry/tools/regdiff.c | 32 | ||||
-rw-r--r-- | source4/lib/registry/tools/regpatch.c | 19 | ||||
-rw-r--r-- | source4/lib/registry/tools/regshell.c | 3 | ||||
-rw-r--r-- | source4/lib/registry/tools/regtree.c | 12 |
5 files changed, 55 insertions, 42 deletions
diff --git a/source4/lib/registry/tools/gregedit.c b/source4/lib/registry/tools/gregedit.c index 7b06b2266f..e8800c6ee9 100644 --- a/source4/lib/registry/tools/gregedit.c +++ b/source4/lib/registry/tools/gregedit.c @@ -1,6 +1,6 @@ /* Unix SMB/CIFS implementation. - Gtk registry frontend + GTK+ registry frontend Copyright (C) Jelmer Vernooij 2004 @@ -115,20 +115,25 @@ static void registry_load_root() { REG_KEY *root; GtkTreeIter iter, tmpiter; - WERROR error; + WERROR error = WERR_OK; + int i = 0; if(!registry) return; - error = reg_get_root(registry, &root); - if(!W_ERROR_IS_OK(error)) { - gtk_show_werror(error); - return; - } - gtk_tree_store_clear(store_keys); - /* Add the root */ - gtk_tree_store_append(store_keys, &iter, NULL); - gtk_tree_store_set (store_keys, + while(1) { + error = reg_get_hive(registry, i, &root); + if(W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { + return; + } + if(!W_ERROR_IS_OK(error)) { + gtk_show_werror(error); + return; + } + + /* Add the root */ + gtk_tree_store_append(store_keys, &iter, NULL); + gtk_tree_store_set (store_keys, &iter, 0, reg_key_name(root), @@ -136,7 +141,9 @@ static void registry_load_root() root, -1); - gtk_tree_store_append(store_keys, &tmpiter, &iter); + gtk_tree_store_append(store_keys, &tmpiter, &iter); + i++; + } gtk_widget_set_sensitive( save, True ); gtk_widget_set_sensitive( save_as, True ); diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index d9419208cd..7520e653bb 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -100,10 +100,11 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) const char *credentials1= NULL, *credentials2 = NULL; char *outputfile = NULL; FILE *fd = stdout; - REG_HANDLE *h2; + REG_HANDLE *h1, *h2; REG_KEY *root1 = NULL, *root2; int from_null = 0; - WERROR error; + int i; + WERROR error, error2; struct poptOption long_options[] = { POPT_AUTOHELP {"backend", 'b', POPT_ARG_STRING, NULL, 'b', "backend to use", NULL}, @@ -130,7 +131,6 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) setup_logging(argv[0], True); if(!from_null) { - REG_HANDLE *h1; const char *location1; location1 = poptGetArg(pc); if(!location1) { @@ -145,8 +145,6 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location1, backend1); return 1; } - - if(!W_ERROR_IS_OK(reg_get_root(h1, &root1))) return 1; } location2 = poptGetArg(pc); @@ -163,12 +161,6 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) return 1; } - error = reg_get_root(h2, &root2); - if(!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Can't open root key for '%s:%s'\n", backend2, location2); - return 1; - } - poptFreeContext(pc); if(outputfile) { @@ -182,7 +174,23 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) fprintf(fd, "REGEDIT4\n\n"); fprintf(fd, "; Generated using regdiff\n"); - writediff(root1, root2, fd); + error2 = error = WERR_OK; + + for(i = 0; ; i++) { + if(backend1) error = reg_get_hive(h1, i, &root1); + else root1 = NULL; + + if(!W_ERROR_IS_OK(error)) break; + + if(backend2) error2 = reg_get_hive(h2, i, &root2); + else root2 = NULL; + + if(!W_ERROR_IS_OK(error2)) break; + + writediff(root1, root2, fd); + + if(!root1 && !root2) break; + } fclose(fd); diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 64c2637a0c..77c0f710c1 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -664,7 +664,7 @@ static CMD_FILE *cmd_file_create(const char *file) char *str_type(unsigned char type); -static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) +static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) { CMD *cmd; BOOL modified = False; @@ -680,12 +680,12 @@ static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) */ switch (cmd->cmd) { case CMD_ADD_KEY: - error = reg_open_key(root, cmd->key, &tmp); + error = reg_open_key_abs(r, cmd->key, &tmp); /* If we found it, apply the other bits, else create such a key */ if (W_ERROR_EQUAL(error, WERR_DEST_NOT_FOUND)) { - if(W_ERROR_IS_OK(reg_key_add_name_recursive(root, cmd->key))) { - error = reg_open_key(root, cmd->key, &tmp); + if(W_ERROR_IS_OK(reg_key_add_name_recursive_abs(r, cmd->key))) { + error = reg_open_key_abs(r, cmd->key, &tmp); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error finding new key '%s' after it has been added\n", cmd->key)); continue; @@ -732,7 +732,7 @@ static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) * Find the key if it exists, and delete it ... */ - error = reg_open_key(root, cmd->key, &tmp); + error = reg_open_key_abs(r, cmd->key, &tmp); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Unable to open key '%s'\n", cmd->key)); continue; @@ -756,7 +756,6 @@ static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) { int opt; poptContext pc; - REG_KEY *root; const char *location; const char *credentials = NULL; const char *patch; @@ -793,13 +792,7 @@ static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) if(!patch) patch = "/dev/stdin"; poptFreeContext(pc); - error = reg_get_root(h, &root); - if(!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Error opening root!\n")); - return 1; - } - - nt_apply_reg_command_file(root, patch); + nt_apply_reg_command_file(h, patch); reg_free(h); diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index e8b01081e8..26312ad4bc 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -27,6 +27,7 @@ * rmval/rm - remove value * rmkey/rmdir - remove key * mkkey/mkdir - make key + * ch - change hive * help * exit */ @@ -227,7 +228,7 @@ static REG_KEY *process_cmd(REG_KEY *k, char *line) setup_logging("regtree", True); - error = reg_get_root(h, &curkey); + error = reg_get_hive(h, 0, &curkey); if(!W_ERROR_IS_OK(error)) return 1; diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 477c63af2c..e583194a56 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -60,7 +60,7 @@ static void print_tree(int l, REG_KEY *p, int fullpath, int novals) int main(int argc, char **argv) { - int opt; + int opt, i; const char *backend = "dir"; const char *credentials = NULL; poptContext pc; @@ -91,10 +91,14 @@ static void print_tree(int l, REG_KEY *p, int fullpath, int novals) } poptFreeContext(pc); - error = reg_get_root(h, &root); - if(!W_ERROR_IS_OK(error)) return 1; + error = WERR_OK; - print_tree(0, root, fullpath, no_values); + for(i = 0; W_ERROR_IS_OK(error); i++) { + error = reg_get_hive(h, i, &root); + if(!W_ERROR_IS_OK(error)) return 1; + + print_tree(0, root, fullpath, no_values); + } return 0; } |