summaryrefslogtreecommitdiff
path: root/source4/lib/registry/tools/regtree.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-12-10 20:07:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:06:29 -0500
commit444a86792471c0bef33dde15c7a4a33e16a951b4 (patch)
tree075b0cdd27acb80470a4e90e99598cbcea3b082c /source4/lib/registry/tools/regtree.c
parent60c69445f6fa86b27bd697cc8af52b582f620725 (diff)
downloadsamba-444a86792471c0bef33dde15c7a4a33e16a951b4.tar.gz
samba-444a86792471c0bef33dde15c7a4a33e16a951b4.tar.bz2
samba-444a86792471c0bef33dde15c7a4a33e16a951b4.zip
r4132: - Bunch of rather large fixes in the registry
- Added some README files Not everything works yet, e.g. the EnumValue test appears to be broken. (This used to be commit c169e86c1f52763b83e77e509f89cb91f9b69071)
Diffstat (limited to 'source4/lib/registry/tools/regtree.c')
-rw-r--r--source4/lib/registry/tools/regtree.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index ced7a00f94..8ff68229eb 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -36,7 +36,7 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
/* Hive name */
if(p->hive->root == p) {
- if(p->hive->name) printf("%s\n", p->hive->name); else printf("<No Name>\n");
+ if(p->hive->root->name) printf("%s\n", p->hive->root->name); else printf("<No Name>\n");
} else {
if(!p->name) printf("<No Name>\n");
if(fullpath) printf("%s\n", p->path);
@@ -73,17 +73,19 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
int main(int argc, char **argv)
{
int opt, i;
- const char *backend = "rpc";
- const char *credentials = NULL;
+ const char *backend = NULL;
+ const char *remote = NULL;
poptContext pc;
- struct registry_context *h;
+ struct registry_context *h = NULL;
+ struct registry_key *root = NULL;
WERROR error;
int fullpath = 0, no_values = 0;
struct poptOption long_options[] = {
POPT_AUTOHELP
+ POPT_COMMON_CREDENTIALS
{"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL},
{"fullpath", 'f', POPT_ARG_NONE, &fullpath, 0, "show full paths", NULL},
- {"credentials", 'c', POPT_ARG_STRING, &credentials, 0, "credentials (user%password)", NULL},
+ {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL },
{"no-values", 'V', POPT_ARG_NONE, &no_values, 0, "don't show values", NULL},
POPT_TABLEEND
};
@@ -102,7 +104,14 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
setup_logging("regtree", True);
- error = reg_open(&h, backend, poptPeekArg(pc), credentials);
+ if (remote) {
+ error = reg_open_remote(&h, cmdline_get_username(), cmdline_get_userpassword(), remote);
+ } else if (backend) {
+ error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &root);
+ } else {
+ error = reg_open_local (&h);
+ }
+
if(!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to open '%s' with backend '%s':%s \n", poptGetArg(pc), backend, win_errstr(error));
return 1;
@@ -110,10 +119,19 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
poptFreeContext(pc);
error = WERR_OK;
-
- for(i = 0; i < h->num_hives; i++) {
- print_tree(0, h->hives[i]->root, fullpath, no_values);
- }
+ if (!h) {
+ print_tree(0, root, fullpath, no_values);
+ } else {
+ for(i = HKEY_CLASSES_ROOT; i < HKEY_PN; i++) {
+ error = reg_get_hive(h, i, &root);
+ if (!W_ERROR_IS_OK(error)) {
+ fprintf(stderr, "Skipping %s\n", reg_get_hkey_name(i));
+ continue;
+ }
+ print_tree(0, root, fullpath, no_values);
+ }
+ }
+
return 0;
}