From 2547baebc48ecb215668183d2552d83ecd4564f3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 9 Apr 2008 12:31:05 +0200 Subject: net registry: add a getvalue subcommand that prints a single given value. usage: "net registry getvalue " Michael (This used to be commit 77f049943e133986dc47d25fff2415def1cec32f) --- source3/utils/net_registry.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c index c7cc5af493..6af8236092 100644 --- a/source3/utils/net_registry.c +++ b/source3/utils/net_registry.c @@ -260,6 +260,42 @@ done: return ret; } +static int net_registry_getvalue(int argc, const char **argv) +{ + WERROR werr; + int ret = -1; + struct registry_key *key = NULL; + struct registry_value *value = NULL; + TALLOC_CTX *ctx = talloc_stackframe(); + + if (argc != 2) { + d_fprintf(stderr, "usage: net rpc registry getvalue " + "\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", dos_errstr(werr)); + goto done; + } + + werr = reg_queryvalue(ctx, key, argv[1], &value); + if (!W_ERROR_IS_OK(werr)) { + d_fprintf(stderr, "reg_queryvalue failed: %s\n", + dos_errstr(werr)); + goto done; + } + + print_registry_value(value); + + ret = 0; + +done: + TALLOC_FREE(ctx); + return ret; +} + static int net_registry_setvalue(int argc, const char **argv) { WERROR werr; @@ -414,6 +450,11 @@ int net_registry(int argc, const char **argv) net_registry_deletekey, "Delete a registry key" }, + { + "getvalue", + net_registry_getvalue, + "Print a registry value", + }, { "setvalue", net_registry_setvalue, -- cgit