summaryrefslogtreecommitdiff
path: root/source3/utils/net_registry.c
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2011-05-30 10:24:16 +0200
committerMichael Adam <obnox@samba.org>2011-05-30 17:42:27 +0200
commit5ec479fa0c9db4072541d46345164542d037cfc9 (patch)
tree6801ca034f3bebb221f43d821e8dc2e83e04e0d5 /source3/utils/net_registry.c
parent22011ddc9e72c8a201e3ca6e01745a68738d5916 (diff)
downloadsamba-5ec479fa0c9db4072541d46345164542d037cfc9.tar.gz
samba-5ec479fa0c9db4072541d46345164542d037cfc9.tar.bz2
samba-5ec479fa0c9db4072541d46345164542d037cfc9.zip
s3:net: registry: use recursive implementation for enumerate
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils/net_registry.c')
-rw-r--r--source3/utils/net_registry.c104
1 files changed, 41 insertions, 63 deletions
diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c
index bb7c67f1f1..62d34184b0 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)
{