diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-11-21 10:48:11 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:15:58 -0500 |
commit | c63be3a4e7909cc3f71fcad6d134a7bb2fc19529 (patch) | |
tree | b72b32136c88d7d28f2c689ca7d73ef7f1cb5307 /source3 | |
parent | 28bbef032fa86f2346639ee8e5d5efdd3fd67d1b (diff) | |
download | samba-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')
-rw-r--r-- | source3/rpc_client/cli_reg.c | 44 | ||||
-rw-r--r-- | source3/utils/net_rpc_registry.c | 74 |
2 files changed, 19 insertions, 99 deletions
diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c index 3aadc04975..292d1d9d28 100644 --- a/source3/rpc_client/cli_reg.c +++ b/source3/rpc_client/cli_reg.c @@ -58,50 +58,6 @@ NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } -/* - * - * Utility functions - * - */ - -/***************************************************************** - Splits out the start of the key (HKLM or HKU) and the rest of the key. -*****************************************************************/ - -BOOL reg_split_hive(const char *full_keyname, uint32 *reg_type, pstring key_name) -{ - pstring tmp; - - if (!next_token(&full_keyname, tmp, "\\", sizeof(tmp))) - return False; - - (*reg_type) = 0; - - DEBUG(10, ("reg_split_key: hive %s\n", tmp)); - - if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE")) - (*reg_type) = HKEY_LOCAL_MACHINE; - else if (strequal(tmp, "HKCR") || strequal(tmp, "HKEY_CLASSES_ROOT")) - (*reg_type) = HKEY_CLASSES_ROOT; - else if (strequal(tmp, "HKU") || strequal(tmp, "HKEY_USERS")) - (*reg_type) = HKEY_USERS; - else if (strequal(tmp, "HKPD")||strequal(tmp, "HKEY_PERFORMANCE_DATA")) - (*reg_type) = HKEY_PERFORMANCE_DATA; - else { - DEBUG(10,("reg_split_key: unrecognised hive key %s\n", tmp)); - return False; - } - - if (next_token(&full_keyname, tmp, "\n\r", sizeof(tmp))) - pstrcpy(key_name, tmp); - else - key_name[0] = 0; - - DEBUG(10, ("reg_split_key: name %s\n", key_name)); - - return True; -} - /******************************************************************* Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE *******************************************************************/ 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) ) { |