[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-731-g51026d6
Michael Adam
obnox at samba.org
Wed Apr 9 22:11:08 GMT 2008
The branch, v3-2-test has been updated
via 51026d64b3e19626b51bee73fb257a75a6455355 (commit)
via ba59383437aed9058a58bdeedcf61a0076a94924 (commit)
via 77f049943e133986dc47d25fff2415def1cec32f (commit)
via 88c4851ad7240bc4f72a5ef92e21629e6a4c99c6 (commit)
from 6cee34703503fbf3629057345fe221b866560648 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 51026d64b3e19626b51bee73fb257a75a6455355
Author: Michael Adam <obnox at samba.org>
Date: Wed Apr 9 18:54:20 2008 +0200
net: don't process net_registry_util.c with make proto
it has its own herader net_registry_util.h
Michael
commit ba59383437aed9058a58bdeedcf61a0076a94924
Author: Michael Adam <obnox at samba.org>
Date: Wed Apr 9 14:30:18 2008 +0200
net rpc registry: add getvalue command.
This is the same as already implemented for "net registry".
usage: net rpc registry getvalue <key> <valuename>
Michael
commit 77f049943e133986dc47d25fff2415def1cec32f
Author: Michael Adam <obnox at samba.org>
Date: Wed Apr 9 12:31:05 2008 +0200
net registry: add a getvalue subcommand that prints a single given value.
usage: "net registry getvalue <keyname> <valuename>"
Michael
commit 88c4851ad7240bc4f72a5ef92e21629e6a4c99c6
Author: Michael Adam <obnox at samba.org>
Date: Wed Apr 9 12:29:34 2008 +0200
net (registry util): refactor printing of value without name out.
This renames print_registry_value() to print_registry_value_with_name().
The new function is called print_registry_value().
Michael
-----------------------------------------------------------------------
Summary of changes:
source/Makefile.in | 8 ++-
source/utils/net_registry.c | 43 ++++++++++++++++-
source/utils/net_registry_util.c | 11 +++-
source/utils/net_registry_util.h | 6 ++-
source/utils/net_rpc_registry.c | 102 +++++++++++++++++++++++++++++++++++++-
5 files changed, 161 insertions(+), 9 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/Makefile.in b/source/Makefile.in
index 781e8de..5241801 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -847,10 +847,14 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
$(PASSWD_UTIL_OBJ) utils/net_dns.o utils/net_ads_gpo.o \
utils/net_conf.o \
utils/net_registry.o \
- utils/net_registry_util.o \
auth/token_util.o utils/net_dom.o nsswitch/wb_client.o
-NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \
+# these are not processed by make proto
+NET_OBJ2 = utils/net_registry_util.o
+
+NET_OBJ = $(NET_OBJ1) \
+ $(NET_OBJ2) \
+ $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \
$(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
$(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(LIBADDNS_OBJ0) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \
diff --git a/source/utils/net_registry.c b/source/utils/net_registry.c
index 8a45dec..6af8236 100644
--- a/source/utils/net_registry.c
+++ b/source/utils/net_registry.c
@@ -156,7 +156,7 @@ static int net_registry_enumerate(int argc, const char **argv)
W_ERROR_IS_OK(werr);
count++)
{
- print_registry_value(valname, valvalue);
+ print_registry_value_with_name(valname, valvalue);
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
goto done;
@@ -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 <key> "
+ "<valuename>\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;
@@ -415,6 +451,11 @@ int net_registry(int argc, const char **argv)
"Delete a registry key"
},
{
+ "getvalue",
+ net_registry_getvalue,
+ "Print a registry value",
+ },
+ {
"setvalue",
net_registry_setvalue,
"Set a new registry value"
diff --git a/source/utils/net_registry_util.c b/source/utils/net_registry_util.c
index 948f8b6..ca80e60 100644
--- a/source/utils/net_registry_util.c
+++ b/source/utils/net_registry_util.c
@@ -32,10 +32,8 @@ void print_registry_key(const char *keyname, NTTIME *modtime)
d_printf("\n");
}
-void print_registry_value(const char *valname,
- const struct registry_value *valvalue)
+void print_registry_value(const struct registry_value *valvalue)
{
- d_printf("Valuename = %s\n", valname);
d_printf("Type = %s\n",
reg_type_lookup(valvalue->type));
switch(valvalue->type) {
@@ -62,6 +60,13 @@ void print_registry_value(const char *valname,
d_printf("Value = <unprintable>\n");
break;
}
+}
+
+void print_registry_value_with_name(const char *valname,
+ const struct registry_value *valvalue)
+{
+ d_printf("Valuename = %s\n", valname);
+ print_registry_value(valvalue);
d_printf("\n");
}
diff --git a/source/utils/net_registry_util.h b/source/utils/net_registry_util.h
index 13ec6eb..09aaa83 100644
--- a/source/utils/net_registry_util.h
+++ b/source/utils/net_registry_util.h
@@ -24,8 +24,10 @@
void print_registry_key(const char *keyname, NTTIME *modtime);
-void print_registry_value(const char *valname,
- const struct registry_value *valvalue);
+void print_registry_value(const struct registry_value *valvalue);
+
+void print_registry_value_with_name(const char *valname,
+ const struct registry_value *valvalue);
/**
* Split path into hive name and subkeyname
diff --git a/source/utils/net_rpc_registry.c b/source/utils/net_rpc_registry.c
index da078f4..4237008 100644
--- a/source/utils/net_rpc_registry.c
+++ b/source/utils/net_rpc_registry.c
@@ -488,6 +488,104 @@ static int rpc_registry_deletevalue( int argc, const char **argv )
rpc_registry_deletevalue_internal, argc, argv );
}
+static NTSTATUS rpc_registry_getvalue_internal(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
+{
+ struct policy_handle hive_hnd, key_hnd;
+ NTSTATUS status;
+ WERROR werr;
+ struct winreg_String valuename;
+ struct registry_value *value = NULL;
+ enum winreg_Type type = REG_NONE;
+ uint8_t *data = NULL;
+ uint32_t data_size = 0;
+ uint32_t value_length = 0;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+
+ ZERO_STRUCT(valuename);
+
+ status = registry_openkey(tmp_ctx, pipe_hnd, argv[0],
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &hive_hnd, &key_hnd);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "registry_openkey failed: %s\n",
+ nt_errstr(status));
+ return status;
+ }
+
+ valuename.name = argv[1];
+
+ /*
+ * call QueryValue once with data == NULL to get the
+ * needed memory size to be allocated, then allocate
+ * data buffer and call again.
+ */
+ status = rpccli_winreg_QueryValue(pipe_hnd, tmp_ctx, &key_hnd,
+ &valuename,
+ &type,
+ data,
+ &data_size,
+ &value_length,
+ NULL);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "registry_queryvalue failed: %s\n",
+ nt_errstr(status));
+ goto done;
+ }
+
+ data = (uint8 *)TALLOC(tmp_ctx, data_size);
+ value_length = 0;
+
+ status = rpccli_winreg_QueryValue(pipe_hnd, tmp_ctx, &key_hnd,
+ &valuename,
+ &type,
+ data,
+ &data_size,
+ &value_length,
+ NULL);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "registry_queryvalue failed: %s\n",
+ nt_errstr(status));
+ goto done;
+ }
+
+ werr = registry_pull_value(tmp_ctx, &value, type, data,
+ data_size, value_length);
+ if (!W_ERROR_IS_OK(werr)) {
+ status = werror_to_ntstatus(werr);
+ goto done;
+ }
+
+ print_registry_value(value);
+
+done:
+ rpccli_winreg_CloseKey(pipe_hnd, tmp_ctx, &key_hnd, NULL);
+ rpccli_winreg_CloseKey(pipe_hnd, tmp_ctx, &hive_hnd, NULL);
+
+ TALLOC_FREE(tmp_ctx);
+
+ return status;
+}
+
+static int rpc_registry_getvalue(int argc, const char **argv)
+{
+ if (argc != 2) {
+ d_fprintf(stderr, "usage: net rpc registry deletevalue <key> "
+ "<valuename>\n");
+ return -1;
+ }
+
+ return run_rpc_command(NULL, PI_WINREG, 0,
+ rpc_registry_getvalue_internal, argc, argv);
+}
+
static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid,
const char *domain_name,
struct cli_state *cli,
@@ -661,7 +759,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
}
for (i=0; i<num_values; i++) {
- print_registry_value(names[i], values[i]);
+ print_registry_value_with_name(names[i], values[i]);
}
rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key, NULL);
@@ -1069,6 +1167,8 @@ int net_rpc_registry(int argc, const char **argv)
"Create a new registry key" },
{ "deletekey", rpc_registry_deletekey,
"Delete a registry key" },
+ { "getvalue", rpc_registry_getvalue,
+ "Print a registry value" },
{ "setvalue", rpc_registry_setvalue,
"Set a new registry value" },
{ "deletevalue", rpc_registry_deletevalue,
--
Samba Shared Repository
More information about the samba-cvs
mailing list