From d5e79de59561e614fce79a9460c3b2caaa459673 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 26 May 2005 20:36:04 +0000 Subject: r6995: * fixing segfault when writing out registry values of zero length * add RegSaveKey() client function * add 'net rpc registry save' subcommand (This used to be commit f35e0a0a8d8df5c39e61ebd34c4aecbc5c9bb635) --- source3/utils/net_rpc_registry.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 53378fadef..f97f67a13b 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -198,7 +198,7 @@ static int rpc_registry_enumerate( int argc, const char **argv ) /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_registry_backup_internal( const DOM_SID *domain_sid, const char *domain_name, +static NTSTATUS rpc_registry_save_internal( const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv ) { @@ -206,7 +206,6 @@ static NTSTATUS rpc_registry_backup_internal( const DOM_SID *domain_sid, const c uint32 hive; pstring subpath; POLICY_HND pol_hive, pol_key; - REGF_FILE *regfile; if (argc != 2 ) { d_printf("Usage: net rpc backup \n"); @@ -232,17 +231,14 @@ static NTSTATUS rpc_registry_backup_internal( const DOM_SID *domain_sid, const c return werror_to_ntstatus(result); } - /* open the file */ - - if ( !(regfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), 0600 )) ) { - d_printf("Unable to open registry file [%s]\n", argv[1]); - return werror_to_ntstatus(WERR_GENERAL_FAILURE); + result = cli_reg_save_key( cli, mem_ctx, &pol_key, argv[1] ); + if ( !W_ERROR_IS_OK(result) ) { + d_printf("Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); } /* cleanup */ - regfio_close( regfile ); cli_reg_close( cli, mem_ctx, &pol_key ); cli_reg_close( cli, mem_ctx, &pol_hive ); @@ -252,10 +248,10 @@ static NTSTATUS rpc_registry_backup_internal( const DOM_SID *domain_sid, const c /******************************************************************** ********************************************************************/ -static int rpc_registry_backup( int argc, const char **argv ) +static int rpc_registry_save( int argc, const char **argv ) { return run_rpc_command( NULL, PI_WINREG, 0, - rpc_registry_backup_internal, argc, argv ); + rpc_registry_save_internal, argc, argv ); } @@ -467,7 +463,7 @@ static int rpc_registry_copy( int argc, const char **argv ) static int net_help_registry( int argc, const char **argv ) { d_printf("net rpc registry enumerate [recurse] Enumerate the subkeya and values for a given registry path\n"); - d_printf("net rpc registry backup Backup a registry tree to a local file\n"); + d_printf("net rpc registry save Backup a registry tree to a file on the server\n"); d_printf("net rpc registry dump Dump the contents of a registry file to stdout\n"); return -1; @@ -480,7 +476,7 @@ int net_rpc_registry(int argc, const char **argv) { struct functable func[] = { {"enumerate", rpc_registry_enumerate}, - {"backup", rpc_registry_backup}, + {"save", rpc_registry_save}, {"dump", rpc_registry_dump}, {"copy", rpc_registry_copy}, {NULL, NULL} -- cgit