From: Michael Adam Date: Wed, 9 Apr 2008 10:31:05 +0000 (+0200) Subject: net registry: add a getvalue subcommand that prints a single given value. X-Git-Tag: samba-3.3.0pre1~2825 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=77f049943e133986dc47d25fff2415def1cec32f;p=thirdparty%2Fsamba.git net registry: add a getvalue subcommand that prints a single given value. usage: "net registry getvalue " Michael --- diff --git a/source/utils/net_registry.c b/source/utils/net_registry.c index c7cc5af4933..6af82360922 100644 --- a/source/utils/net_registry.c +++ b/source/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,