The Samba-Bugzilla – Attachment 6505 Details for
Bug 8193
net regirstry should support recursive enumeration of keys
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patchset for v3-6-test
enumerate_recursive.patch (text/plain), 8.31 KB, created by
Gregor Beck (550 Unknown user)
on 2011-05-31 14:33:25 UTC
(
hide
)
Description:
patchset for v3-6-test
Filename:
MIME Type:
Creator:
Gregor Beck (550 Unknown user)
Created:
2011-05-31 14:33:25 UTC
Size:
8.31 KB
patch
obsolete
>From ab16bd989afed72682b6c4e01014e70ada3552af Mon Sep 17 00:00:00 2001 >From: Gregor Beck <gbeck@sernet.de> >Date: Mon, 30 May 2011 08:58:34 +0200 >Subject: [PATCH 1/3] s3:net: registry: add new command enumerate_recursive > >Signed-off-by: Michael Adam <obnox@samba.org> >(cherry picked from commit 22011ddc9e72c8a201e3ca6e01745a68738d5916) > >Fix bug: #8193 >--- > source3/utils/net_registry.c | 107 ++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 107 insertions(+), 0 deletions(-) > >diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c >index 19405e2..bb7c67f 100644 >--- a/source3/utils/net_registry.c >+++ b/source3/utils/net_registry.c >@@ -185,6 +185,105 @@ done: > return ret; > } > >+static WERROR registry_enumkey(struct registry_key* parent, const char* keyname, bool recursive) >+{ >+ WERROR werr; >+ TALLOC_CTX *ctx = talloc_stackframe(); >+ char* subkey_name; >+ NTTIME modtime; >+ uint32_t count; >+ char* valname = NULL; >+ struct registry_value *valvalue = NULL; >+ struct registry_key* key = NULL; >+ >+ werr = reg_openkey(ctx, parent, keyname, REG_KEY_READ, &key); >+ if (!W_ERROR_IS_OK(werr)) { >+ goto done; >+ } >+ >+ printf("[%s]\n", key->key->name); >+ >+ for (count = 0; >+ werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime), >+ W_ERROR_IS_OK(werr); >+ count++) >+ { >+ print_registry_key(subkey_name, &modtime); >+ } >+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { >+ goto done; >+ } >+ >+ for (count = 0; >+ werr = reg_enumvalue(ctx, key, count, &valname, &valvalue), >+ W_ERROR_IS_OK(werr); >+ count++) >+ { >+ print_registry_value_with_name(valname, valvalue); >+ } >+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { >+ goto done; >+ } >+ >+ if (!recursive) { >+ werr = WERR_OK; >+ goto done; >+ } >+ >+ for (count = 0; >+ werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime), >+ W_ERROR_IS_OK(werr); >+ count++) >+ { >+ werr = registry_enumkey(key, subkey_name, recursive); >+ if (!W_ERROR_IS_OK(werr)) { >+ goto done; >+ } >+ } >+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { >+ goto done; >+ } >+ werr = WERR_OK; >+done: >+ TALLOC_FREE(ctx); >+ return werr; >+} >+ >+static int net_registry_enumerate_recursive(struct net_context *c, int argc, >+ const char **argv) >+{ >+ WERROR werr; >+ struct registry_key *key = NULL; >+ char* name = NULL; >+ TALLOC_CTX *ctx = talloc_stackframe(); >+ int ret = -1; >+ >+ if (argc != 1 || c->display_usage) { >+ d_printf("%s\n%s", >+ _("Usage:"), >+ _("net registry enumerate <path>\n")); >+ d_printf("%s\n%s", >+ _("Example:"), >+ _("net registry enumerate 'HKLM\\Software\\Samba'\n")); >+ goto done; >+ } >+ >+ werr = open_hive(ctx, argv[0], REG_KEY_READ, &key, &name); >+ if (!W_ERROR_IS_OK(werr)) { >+ d_fprintf(stderr, _("open_key failed: %s\n"), win_errstr(werr)); >+ goto done; >+ } >+ >+ werr = registry_enumkey(key, name, true); >+ if (W_ERROR_IS_OK(werr)) { >+ ret = 0; >+ } >+done: >+ TALLOC_FREE(ctx); >+ return ret; >+} >+ >+ > static int net_registry_createkey(struct net_context *c, int argc, > const char **argv) > { >@@ -1174,6 +1273,14 @@ int net_registry(struct net_context *c, int argc, const char **argv) > " Enumerate registry keys and values") > }, > { >+ "enumerate_recursive", >+ net_registry_enumerate_recursive, >+ NET_TRANSPORT_LOCAL, >+ N_("Enumerate registry keys and values"), >+ N_("net registry enumerate_recursive\n" >+ " Enumerate registry keys and values") >+ }, >+ { > "createkey", > net_registry_createkey, > NET_TRANSPORT_LOCAL, >-- >1.7.5.2 > > >From 29a5c3022dd397a8b5b07f97be25052da2205319 Mon Sep 17 00:00:00 2001 >From: Gregor Beck <gbeck@sernet.de> >Date: Mon, 30 May 2011 10:24:16 +0200 >Subject: [PATCH 2/3] s3:net: registry: use recursive implementation for > enumerate > >Signed-off-by: Michael Adam <obnox@samba.org> >(cherry picked from commit 5ec479fa0c9db4072541d46345164542d037cfc9) > >Fix bug: #8193 >--- > source3/utils/net_registry.c | 104 ++++++++++++++++------------------------- > 1 files changed, 41 insertions(+), 63 deletions(-) > >diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c >index bb7c67f..62d3418 100644 >--- a/source3/utils/net_registry.c >+++ b/source3/utils/net_registry.c >@@ -122,69 +122,6 @@ done: > return werr; > } > >-/* >- * >- * the main "net registry" function implementations >- * >- */ >- >-static int net_registry_enumerate(struct net_context *c, int argc, >- const char **argv) >-{ >- WERROR werr; >- struct registry_key *key = NULL; >- TALLOC_CTX *ctx = talloc_stackframe(); >- char *subkey_name; >- NTTIME modtime; >- uint32_t count; >- char *valname = NULL; >- struct registry_value *valvalue = NULL; >- int ret = -1; >- >- if (argc != 1 || c->display_usage) { >- d_printf("%s\n%s", >- _("Usage:"), >- _("net registry enumerate <path>\n")); >- d_printf("%s\n%s", >- _("Example:"), >- _("net registry enumerate 'HKLM\\Software\\Samba'\n")); >- goto done; >- } >- >- werr = open_key(ctx, argv[0], REG_KEY_READ, &key); >- if (!W_ERROR_IS_OK(werr)) { >- d_fprintf(stderr, _("open_key failed: %s\n"), win_errstr(werr)); >- goto done; >- } >- >- for (count = 0; >- werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime), >- W_ERROR_IS_OK(werr); >- count++) >- { >- print_registry_key(subkey_name, &modtime); >- } >- if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { >- goto done; >- } >- >- for (count = 0; >- werr = reg_enumvalue(ctx, key, count, &valname, &valvalue), >- W_ERROR_IS_OK(werr); >- count++) >- { >- print_registry_value_with_name(valname, valvalue); >- } >- if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { >- goto done; >- } >- >- ret = 0; >-done: >- TALLOC_FREE(ctx); >- return ret; >-} >- > static WERROR registry_enumkey(struct registry_key* parent, const char* keyname, bool recursive) > { > WERROR werr; >@@ -249,6 +186,47 @@ done: > return werr; > } > >+ >+ >+/* >+ * >+ * the main "net registry" function implementations >+ * >+ */ >+static int net_registry_enumerate(struct net_context *c, int argc, >+ const char **argv) >+{ >+ WERROR werr; >+ struct registry_key *key = NULL; >+ char* name = NULL; >+ TALLOC_CTX *ctx = talloc_stackframe(); >+ int ret = -1; >+ >+ if (argc != 1 || c->display_usage) { >+ d_printf("%s\n%s", >+ _("Usage:"), >+ _("net registry enumerate <path>\n")); >+ d_printf("%s\n%s", >+ _("Example:"), >+ _("net registry enumerate 'HKLM\\Software\\Samba'\n")); >+ goto done; >+ } >+ >+ werr = open_hive(ctx, argv[0], REG_KEY_READ, &key, &name); >+ if (!W_ERROR_IS_OK(werr)) { >+ d_fprintf(stderr, _("open_key failed: %s\n"), win_errstr(werr)); >+ goto done; >+ } >+ >+ werr = registry_enumkey(key, name, c->opt_reboot); >+ if (W_ERROR_IS_OK(werr)) { >+ ret = 0; >+ } >+done: >+ TALLOC_FREE(ctx); >+ return ret; >+} >+ > static int net_registry_enumerate_recursive(struct net_context *c, int argc, > const char **argv) > { >-- >1.7.5.2 > > >From da8b73469f15a61df82914921594022af7ab4324 Mon Sep 17 00:00:00 2001 >From: Michael Adam <obnox@samba.org> >Date: Mon, 30 May 2011 16:54:47 +0200 >Subject: [PATCH 3/3] s3:net registry: polish output of net registry > enumerate[_recursive] > >so that net registry enumerate output is as before, and >net registry enumerate_recursive is formatted more nicely >(cherry picked from commit 0d746f653e76de52985d543a15fd6ee3bf2f4823) > >Fix bug: #8193 >--- > source3/utils/net_registry.c | 26 +++++++++++++++----------- > 1 files changed, 15 insertions(+), 11 deletions(-) > >diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c >index 62d3418..961cfc1 100644 >--- a/source3/utils/net_registry.c >+++ b/source3/utils/net_registry.c >@@ -138,17 +138,19 @@ static WERROR registry_enumkey(struct registry_key* parent, const char* keyname, > goto done; > } > >- printf("[%s]\n", key->key->name); >- >- for (count = 0; >- werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime), >- W_ERROR_IS_OK(werr); >- count++) >- { >- print_registry_key(subkey_name, &modtime); >- } >- if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { >- goto done; >+ if (recursive) { >+ printf("[%s]\n\n", key->key->name); >+ } else { >+ for (count = 0; >+ werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime), >+ W_ERROR_IS_OK(werr); >+ count++) >+ { >+ print_registry_key(subkey_name, &modtime); >+ } >+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { >+ goto done; >+ } > } > > for (count = 0; >@@ -180,7 +182,9 @@ static WERROR registry_enumkey(struct registry_key* parent, const char* keyname, > if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { > goto done; > } >+ > werr = WERR_OK; >+ > done: > TALLOC_FREE(ctx); > return werr; >-- >1.7.5.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
obnox
:
review+
Actions:
View
Attachments on
bug 8193
: 6505 |
6519