summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-11-21 10:48:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:58 -0500
commitc63be3a4e7909cc3f71fcad6d134a7bb2fc19529 (patch)
treeb72b32136c88d7d28f2c689ca7d73ef7f1cb5307 /source3/utils
parent28bbef032fa86f2346639ee8e5d5efdd3fd67d1b (diff)
downloadsamba-c63be3a4e7909cc3f71fcad6d134a7bb2fc19529.tar.gz
samba-c63be3a4e7909cc3f71fcad6d134a7bb2fc19529.tar.bz2
samba-c63be3a4e7909cc3f71fcad6d134a7bb2fc19529.zip
r19818: Remove reg_split_hive, make use of registry_openkey
(This used to be commit 7fd1578a905d3c974cb88cc93452d43a03038d30)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_rpc_registry.c74
1 files changed, 19 insertions, 55 deletions
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 10848d0afd..65af269c02 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -474,12 +474,6 @@ static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid,
NTSTATUS status;
struct registry_value value;
- if (argc < 4) {
- d_fprintf(stderr, "usage: net rpc registry setvalue <key> "
- "<valuename> <type> [<val>]+\n");
- return NT_STATUS_INVALID_PARAMETER;
- }
-
status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_WRITE,
&hive_hnd, &key_hnd);
if (!NT_STATUS_IS_OK(status)) {
@@ -525,6 +519,12 @@ static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid,
static int rpc_registry_setvalue( int argc, const char **argv )
{
+ if (argc < 4) {
+ d_fprintf(stderr, "usage: net rpc registry setvalue <key> "
+ "<valuename> <type> [<val>]+\n");
+ return -1;
+ }
+
return run_rpc_command( NULL, PI_WINREG, 0,
rpc_registry_setvalue_internal, argc, argv );
}
@@ -540,12 +540,8 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
int argc,
const char **argv )
{
- WERROR result = WERR_GENERAL_FAILURE;
- uint32 hive;
- pstring subpath;
POLICY_HND pol_hive, pol_key;
NTSTATUS status;
- struct winreg_String subkeyname;
uint32 num_subkeys;
uint32 num_values;
char **names, **classes;
@@ -558,28 +554,13 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
d_printf("Example: net rpc enumerate 'HKLM\\Software\\Samba'\n");
return NT_STATUS_OK;
}
-
- if ( !reg_split_hive( argv[0], &hive, subpath ) ) {
- d_fprintf(stderr, "invalid registry path\n");
- return NT_STATUS_OK;
- }
-
- /* open the top level hive and then the registry key */
-
- status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
- if ( !NT_STATUS_IS_OK(status) ) {
- d_fprintf(stderr, "Unable to connect to remote registry: "
- "%s\n", nt_errstr(status));
- return status;
- }
-
- subkeyname.name = subpath;
- status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, &pol_hive, subkeyname,
- 0, MAXIMUM_ALLOWED_ACCESS, &pol_key );
- if ( !NT_STATUS_IS_OK(status) ) {
- d_fprintf(stderr, "Unable to open [%s]: %s\n", argv[0],
+
+ status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_READ,
+ &pol_hive, &pol_key);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "registry_openkey failed: %s\n",
nt_errstr(status));
- return werror_to_ntstatus(result);
+ return status;
}
status = registry_enumkeys(mem_ctx, pipe_hnd, &pol_key, &num_subkeys,
@@ -639,8 +620,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
d_printf("\n");
}
- if ( strlen( subpath ) != 0 )
- rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key );
+ rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key );
rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive );
return status;
@@ -667,11 +647,8 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
const char **argv )
{
WERROR result = WERR_GENERAL_FAILURE;
- uint32 hive;
- pstring subpath;
POLICY_HND pol_hive, pol_key;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- struct winreg_String subkeyname;
struct winreg_String filename;
if (argc != 2 ) {
@@ -679,27 +656,14 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
return NT_STATUS_OK;
}
- if ( !reg_split_hive( argv[0], &hive, subpath ) ) {
- d_fprintf(stderr, "invalid registry path\n");
- return NT_STATUS_OK;
- }
-
- /* open the top level hive and then the registry key */
-
- status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
- if ( !NT_STATUS_IS_OK(status) ) {
- d_fprintf(stderr, "Unable to connect to remote registry\n");
+ status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_ALL,
+ &pol_hive, &pol_key);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "registry_openkey failed: %s\n",
+ nt_errstr(status));
return status;
}
-
- subkeyname.name = subpath;
- status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, &pol_hive, subkeyname,
- 0, MAXIMUM_ALLOWED_ACCESS, &pol_key );
- if ( !NT_STATUS_IS_OK(status) ) {
- d_fprintf(stderr, "Unable to open [%s]\n", argv[0]);
- return werror_to_ntstatus(result);
- }
-
+
filename.name = argv[1];
status = rpccli_winreg_SaveKey( pipe_hnd, mem_ctx, &pol_key, &filename, NULL );
if ( !W_ERROR_IS_OK(result) ) {