From f0c650a38286c07b9f3e83139c15bfbadc70ad5f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 May 2005 16:25:31 +0000 Subject: r6942: * merging the registry changes back to the 3.0 tree * removing the testprns tool (This used to be commit 81ffb0dbbbd244623507880c323a3c37e2b8dc4d) --- source3/utils/net_rpc_registry.c | 495 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 495 insertions(+) create mode 100644 source3/utils/net_rpc_registry.c (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c new file mode 100644 index 0000000000..53378fadef --- /dev/null +++ b/source3/utils/net_rpc_registry.c @@ -0,0 +1,495 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + Copyright (C) Gerald (Jerry) Carter 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "includes.h" +#include "utils/net.h" +#include "regfio.h" +#include "reg_objects.h" + + +/******************************************************************** +********************************************************************/ + +char* dump_regval_type( uint32 type ) +{ + static fstring string; + + switch (type) { + case REG_SZ: + fstrcpy( string, "REG_SZ" ); + break; + case REG_MULTI_SZ: + fstrcpy( string, "REG_MULTI_SZ" ); + break; + case REG_EXPAND_SZ: + fstrcpy( string, "REG_EXPAND_SZ" ); + break; + case REG_DWORD: + fstrcpy( string, "REG_DWORD" ); + break; + case REG_BINARY: + fstrcpy( string, "REG_BINARY" ); + break; + default: + fstr_sprintf( string, "UNKNOWN [%d]", type ); + } + + return string; +} +/******************************************************************** +********************************************************************/ + +void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer ) +{ + pstring string; + uint32 value; + + switch (type) { + case REG_SZ: + rpcstr_pull( string, buffer->buffer, sizeof(string), -1, STR_TERMINATE ); + d_printf("%s\n", string); + break; + case REG_MULTI_SZ: + d_printf("\n"); + break; + case REG_DWORD: + value = IVAL( buffer->buffer, 0 ); + d_printf( "0x%x\n", value ); + break; + case REG_BINARY: + d_printf("\n"); + break; + + + default: + d_printf( "\tUnknown type [%d]\n", type ); + } +} + +/******************************************************************** +********************************************************************/ + +static NTSTATUS rpc_registry_enumerate_internal( const DOM_SID *domain_sid, const char *domain_name, + struct cli_state *cli, TALLOC_CTX *mem_ctx, + int argc, const char **argv ) +{ + WERROR result = WERR_GENERAL_FAILURE; + uint32 hive; + pstring subpath; + POLICY_HND pol_hive, pol_key; + uint32 idx; + + if (argc != 1 ) { + d_printf("Usage: net rpc enumerate [recurse]\n"); + d_printf("Example:: net rpc enumerate 'HKLM\\Software\\Samba'\n"); + return NT_STATUS_OK; + } + + if ( !reg_split_hive( argv[0], &hive, subpath ) ) { + d_printf("invalid registry path\n"); + return NT_STATUS_OK; + } + + /* open the top level hive and then the registry key */ + + result = cli_reg_connect( cli, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); + if ( !W_ERROR_IS_OK(result) ) { + d_printf("Unable to connect to remote registry\n"); + return werror_to_ntstatus(result); + } + + result = cli_reg_open_entry( cli, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); + if ( !W_ERROR_IS_OK(result) ) { + d_printf("Unable to open [%s]\n", argv[0]); + return werror_to_ntstatus(result); + } + + /* get the subkeys */ + + result = WERR_OK; + idx = 0; + while ( W_ERROR_IS_OK(result) ) { + time_t modtime; + fstring keyname, classname; + + result = cli_reg_enum_key( cli, mem_ctx, &pol_key, idx, + keyname, classname, &modtime ); + + if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) { + result = WERR_OK; + break; + } + + d_printf("Keyname = %s\n", keyname ); + d_printf("Classname = %s\n", classname ); + d_printf("Modtime = %s\n", http_timestring(modtime) ); + d_printf("\n" ); + + idx++; + } + + if ( !W_ERROR_IS_OK(result) ) + goto out; + + /* get the values */ + + result = WERR_OK; + idx = 0; + while ( W_ERROR_IS_OK(result) ) { + uint32 type; + fstring name; + REGVAL_BUFFER value; + + fstrcpy( name, "" ); + ZERO_STRUCT( value ); + + result = cli_reg_enum_val( cli, mem_ctx, &pol_key, idx, + name, &type, &value ); + + if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) { + result = WERR_OK; + break; + } + + d_printf("Valuename = %s\n", name ); + d_printf("Type = %s\n", dump_regval_type(type) ); + d_printf("Data = " ); + dump_regval_buffer( type, &value ); + d_printf("\n" ); + + idx++; + } + + +out: + /* cleanup */ + + cli_reg_close( cli, mem_ctx, &pol_key ); + cli_reg_close( cli, mem_ctx, &pol_hive ); + + return werror_to_ntstatus(result); +} + +/******************************************************************** +********************************************************************/ + +static int rpc_registry_enumerate( int argc, const char **argv ) +{ + return run_rpc_command( NULL, PI_WINREG, 0, + rpc_registry_enumerate_internal, argc, argv ); +} + +/******************************************************************** +********************************************************************/ + +static NTSTATUS rpc_registry_backup_internal( const DOM_SID *domain_sid, const char *domain_name, + struct cli_state *cli, TALLOC_CTX *mem_ctx, + int argc, const char **argv ) +{ + WERROR result = WERR_GENERAL_FAILURE; + uint32 hive; + pstring subpath; + POLICY_HND pol_hive, pol_key; + REGF_FILE *regfile; + + if (argc != 2 ) { + d_printf("Usage: net rpc backup \n"); + return NT_STATUS_OK; + } + + if ( !reg_split_hive( argv[0], &hive, subpath ) ) { + d_printf("invalid registry path\n"); + return NT_STATUS_OK; + } + + /* open the top level hive and then the registry key */ + + result = cli_reg_connect( cli, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); + if ( !W_ERROR_IS_OK(result) ) { + d_printf("Unable to connect to remote registry\n"); + return werror_to_ntstatus(result); + } + + result = cli_reg_open_entry( cli, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); + if ( !W_ERROR_IS_OK(result) ) { + d_printf("Unable to open [%s]\n", argv[0]); + 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); + } + + + /* cleanup */ + + regfio_close( regfile ); + cli_reg_close( cli, mem_ctx, &pol_key ); + cli_reg_close( cli, mem_ctx, &pol_hive ); + + return werror_to_ntstatus(result); +} + +/******************************************************************** +********************************************************************/ + +static int rpc_registry_backup( int argc, const char **argv ) +{ + return run_rpc_command( NULL, PI_WINREG, 0, + rpc_registry_backup_internal, argc, argv ); +} + + +/******************************************************************** +********************************************************************/ + +static void dump_values( REGF_NK_REC *nk ) +{ + int i, j; + pstring data_str; + uint32 data_size, data; + + if ( !nk->values ) + return; + + for ( i=0; inum_values; i++ ) { + d_printf( "\"%s\" = ", nk->values[i].valuename ? nk->values[i].valuename : "(default)" ); + d_printf( "(%s) ", dump_regval_type( nk->values[i].type ) ); + + data_size = nk->values[i].data_size & ~VK_DATA_IN_OFFSET; + switch ( nk->values[i].type ) { + case REG_SZ: + rpcstr_pull( data_str, nk->values[i].data, sizeof(data_str), -1, STR_TERMINATE ); + d_printf( "%s", data_str ); + break; + case REG_MULTI_SZ: + case REG_EXPAND_SZ: + for ( j=0; jvalues[i].data[j] ); + } + break; + case REG_DWORD: + data = IVAL( nk->values[i].data, 0 ); + d_printf("0x%x", data ); + break; + case REG_BINARY: + for ( j=0; jvalues[i].data[j] ); + } + break; + default: + d_printf("unknown"); + break; + } + + d_printf( "\n" ); + } + +} + +/******************************************************************** +********************************************************************/ + +static BOOL dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *parent ) +{ + REGF_NK_REC *key; + pstring regpath; + + /* depth first dump of the registry tree */ + + while ( (key = regfio_fetch_subkey( file, nk )) ) { + pstr_sprintf( regpath, "%s\\%s", parent, key->keyname ); + d_printf("[%s]\n", regpath ); + dump_values( key ); + d_printf("\n"); + dump_registry_tree( file, key, regpath ); + } + + return True; +} + +/******************************************************************** +********************************************************************/ + +static BOOL write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, + REGF_NK_REC *parent, REGF_FILE *outfile, + const char *parentpath ) +{ + REGF_NK_REC *key, *subkey; + REGVAL_CTR values; + REGSUBKEY_CTR subkeys; + int i; + pstring path; + + ZERO_STRUCT( values ); + ZERO_STRUCT( subkeys ); + + regsubkey_ctr_init( &subkeys ); + regval_ctr_init( &values ); + + /* copy values into the REGVAL_CTR */ + + for ( i=0; inum_values; i++ ) { + regval_ctr_addvalue( &values, nk->values[i].valuename, nk->values[i].type, + nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) ); + } + + /* copy subkeys into the REGSUBKEY_CTR */ + + while ( (subkey = regfio_fetch_subkey( infile, nk )) ) { + regsubkey_ctr_addkey( &subkeys, subkey->keyname ); + } + + key = regfio_write_key( outfile, nk->keyname, &values, &subkeys, nk->sec_desc->sec_desc, parent ); + + /* write each one of the subkeys out */ + + pstr_sprintf( path, "%s%s%s", parentpath, parent ? "\\" : "", nk->keyname ); + nk->subkey_index = 0; + while ( (subkey = regfio_fetch_subkey( infile, nk )) ) { + write_registry_tree( infile, subkey, key, outfile, path ); + } + + regval_ctr_destroy( &values ); + regsubkey_ctr_destroy( &subkeys ); + + d_printf("[%s]\n", path ); + + return True; +} + +/******************************************************************** +********************************************************************/ + +static int rpc_registry_dump( int argc, const char **argv ) +{ + REGF_FILE *registry; + REGF_NK_REC *nk; + + if (argc != 1 ) { + d_printf("Usage: net rpc dump \n"); + return 0; + } + + d_printf("Opening %s....", argv[0]); + if ( !(registry = regfio_open( argv[0], O_RDONLY, 0)) ) { + d_printf("Failed to open %s for reading\n", argv[0]); + return 1; + } + d_printf("ok\n"); + + /* get the root of the registry file */ + + nk = regfio_rootkey( registry ); + d_printf("[%s]\n", nk->keyname); + dump_values( nk ); + d_printf("\n"); + + dump_registry_tree( registry, nk, nk->keyname ); + +#if 0 + talloc_report_full( registry->mem_ctx, stderr ); +#endif + d_printf("Closing registry..."); + regfio_close( registry ); + d_printf("ok\n"); + + return 0; +} + +/******************************************************************** +********************************************************************/ + +static int rpc_registry_copy( int argc, const char **argv ) +{ + REGF_FILE *infile, *outfile; + REGF_NK_REC *nk; + + if (argc != 2 ) { + d_printf("Usage: net rpc copy \n"); + return 0; + } + + d_printf("Opening %s....", argv[0]); + if ( !(infile = regfio_open( argv[0], O_RDONLY, 0 )) ) { + d_printf("Failed to open %s for reading\n", argv[0]); + return 1; + } + d_printf("ok\n"); + + d_printf("Opening %s....", argv[1]); + if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) { + d_printf("Failed to open %s for writing\n", argv[1]); + return 1; + } + d_printf("ok\n"); + + /* get the root of the registry file */ + + nk = regfio_rootkey( infile ); + d_printf("RootKey: [%s]\n", nk->keyname); + + write_registry_tree( infile, nk, NULL, outfile, "" ); + + d_printf("Closing %s...", argv[1]); + regfio_close( outfile ); + d_printf("ok\n"); + + d_printf("Closing %s...", argv[0]); + regfio_close( infile ); + d_printf("ok\n"); + + return 0; +} + +/******************************************************************** +********************************************************************/ + +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 dump Dump the contents of a registry file to stdout\n"); + + return -1; +} + +/******************************************************************** +********************************************************************/ + +int net_rpc_registry(int argc, const char **argv) +{ + struct functable func[] = { + {"enumerate", rpc_registry_enumerate}, + {"backup", rpc_registry_backup}, + {"dump", rpc_registry_dump}, + {"copy", rpc_registry_copy}, + {NULL, NULL} + }; + + if ( argc ) + return net_run_function( argc, argv, func, net_help_registry ); + + return net_help_registry( argc, argv ); +} + + -- cgit 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/net_rpc_registry.c') 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 From 2129d3c711a109b47c3c1596a6a639520d2f72d2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 17 Jun 2005 15:35:31 +0000 Subject: r7691: * add .gdbinit to the svn:ignore files * start adding write support to the Samba registry Flesh out the server implementations of RegCreateKey(), RegSetValue(), RegDeleteKey() and RegDeleteValue() I can create a new key using regedit.exe now but the 'New Key #1' key cannot be deleted yet. (This used to be commit e188fdbef8f0ad202b0ecf3c30be2941ebe6d5b1) --- source3/utils/net_rpc_registry.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index f97f67a13b..8a97f64584 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -336,9 +336,6 @@ static BOOL write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, int i; pstring path; - ZERO_STRUCT( values ); - ZERO_STRUCT( subkeys ); - regsubkey_ctr_init( &subkeys ); regval_ctr_init( &values ); -- cgit From 44707ad2e00a91f459e80efbe8f362b5853b0a62 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 29 Aug 2005 14:55:40 +0000 Subject: r9739: conver the reg_objects (REGSUBKEY_CTR & REGVAL_CTR) to use the new talloc() features: Note that the REGSUB_CTR and REGVAL_CTR objects *must* be talloc()'d since the methods use the object pointer as the talloc context for internal private data. There is no longer a regXXX_ctr_intit() and regXXX_ctr_destroy() pair of functions. Simply TALLOC_ZERO_P() and TALLOC_FREE() the object. Also had to convert the printer_info_2->NT_PRINTER_DATA field to be talloc()'d as well. This is just a stop on the road to cleaning up the printer memory management. (This used to be commit ef721333ab9639cb5346067497e99fbd0d4425dd) --- source3/utils/net_rpc_registry.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 8a97f64584..8bb01cd89a 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -331,28 +331,35 @@ static BOOL write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, const char *parentpath ) { REGF_NK_REC *key, *subkey; - REGVAL_CTR values; - REGSUBKEY_CTR subkeys; + REGVAL_CTR *values; + REGSUBKEY_CTR *subkeys; int i; pstring path; - regsubkey_ctr_init( &subkeys ); - regval_ctr_init( &values ); - + if ( !( subkeys = TALLOC_ZERO_P( infile->mem_ctx, REGSUBKEY_CTR )) ) { + DEBUG(0,("write_registry_tree: talloc() failed!\n")); + return False; + } + + if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) { + DEBUG(0,("write_registry_tree: talloc() failed!\n")); + return False; + } + /* copy values into the REGVAL_CTR */ for ( i=0; inum_values; i++ ) { - regval_ctr_addvalue( &values, nk->values[i].valuename, nk->values[i].type, + regval_ctr_addvalue( values, nk->values[i].valuename, nk->values[i].type, nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) ); } /* copy subkeys into the REGSUBKEY_CTR */ while ( (subkey = regfio_fetch_subkey( infile, nk )) ) { - regsubkey_ctr_addkey( &subkeys, subkey->keyname ); + regsubkey_ctr_addkey( subkeys, subkey->keyname ); } - key = regfio_write_key( outfile, nk->keyname, &values, &subkeys, nk->sec_desc->sec_desc, parent ); + key = regfio_write_key( outfile, nk->keyname, values, subkeys, nk->sec_desc->sec_desc, parent ); /* write each one of the subkeys out */ @@ -362,8 +369,7 @@ static BOOL write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, write_registry_tree( infile, subkey, key, outfile, path ); } - regval_ctr_destroy( &values ); - regsubkey_ctr_destroy( &subkeys ); + TALLOC_FREE( subkeys ); d_printf("[%s]\n", path ); -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/utils/net_rpc_registry.c | 45 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 8bb01cd89a..33ccb6c1b7 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -22,7 +22,6 @@ #include "regfio.h" #include "reg_objects.h" - /******************************************************************** ********************************************************************/ @@ -85,9 +84,13 @@ void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer ) /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_registry_enumerate_internal( const DOM_SID *domain_sid, const char *domain_name, - struct cli_state *cli, TALLOC_CTX *mem_ctx, - int argc, const char **argv ) +static NTSTATUS rpc_registry_enumerate_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 ) { WERROR result = WERR_GENERAL_FAILURE; uint32 hive; @@ -108,13 +111,13 @@ static NTSTATUS rpc_registry_enumerate_internal( const DOM_SID *domain_sid, cons /* open the top level hive and then the registry key */ - result = cli_reg_connect( cli, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); + result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); if ( !W_ERROR_IS_OK(result) ) { d_printf("Unable to connect to remote registry\n"); return werror_to_ntstatus(result); } - result = cli_reg_open_entry( cli, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); + result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); if ( !W_ERROR_IS_OK(result) ) { d_printf("Unable to open [%s]\n", argv[0]); return werror_to_ntstatus(result); @@ -128,7 +131,7 @@ static NTSTATUS rpc_registry_enumerate_internal( const DOM_SID *domain_sid, cons time_t modtime; fstring keyname, classname; - result = cli_reg_enum_key( cli, mem_ctx, &pol_key, idx, + result = rpccli_reg_enum_key(pipe_hnd, mem_ctx, &pol_key, idx, keyname, classname, &modtime ); if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) { @@ -159,7 +162,7 @@ static NTSTATUS rpc_registry_enumerate_internal( const DOM_SID *domain_sid, cons fstrcpy( name, "" ); ZERO_STRUCT( value ); - result = cli_reg_enum_val( cli, mem_ctx, &pol_key, idx, + result = rpccli_reg_enum_val(pipe_hnd, mem_ctx, &pol_key, idx, name, &type, &value ); if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) { @@ -180,8 +183,8 @@ static NTSTATUS rpc_registry_enumerate_internal( const DOM_SID *domain_sid, cons out: /* cleanup */ - cli_reg_close( cli, mem_ctx, &pol_key ); - cli_reg_close( cli, mem_ctx, &pol_hive ); + rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key ); + rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive ); return werror_to_ntstatus(result); } @@ -198,9 +201,13 @@ static int rpc_registry_enumerate( int argc, const char **argv ) /******************************************************************** ********************************************************************/ -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 ) +static NTSTATUS rpc_registry_save_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 ) { WERROR result = WERR_GENERAL_FAILURE; uint32 hive; @@ -219,19 +226,19 @@ static NTSTATUS rpc_registry_save_internal( const DOM_SID *domain_sid, const cha /* open the top level hive and then the registry key */ - result = cli_reg_connect( cli, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); + result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); if ( !W_ERROR_IS_OK(result) ) { d_printf("Unable to connect to remote registry\n"); return werror_to_ntstatus(result); } - result = cli_reg_open_entry( cli, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); + result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); if ( !W_ERROR_IS_OK(result) ) { d_printf("Unable to open [%s]\n", argv[0]); return werror_to_ntstatus(result); } - result = cli_reg_save_key( cli, mem_ctx, &pol_key, argv[1] ); + result = rpccli_reg_save_key(pipe_hnd, 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]); } @@ -239,8 +246,8 @@ static NTSTATUS rpc_registry_save_internal( const DOM_SID *domain_sid, const cha /* cleanup */ - cli_reg_close( cli, mem_ctx, &pol_key ); - cli_reg_close( cli, mem_ctx, &pol_hive ); + rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key ); + rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive ); return werror_to_ntstatus(result); } @@ -490,5 +497,3 @@ int net_rpc_registry(int argc, const char **argv) return net_help_registry( argc, argv ); } - - -- cgit From 8d7c88667190fe286971ac4fffb64ee5bd9eeeb0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Oct 2005 03:24:00 +0000 Subject: r11137: Compile with only 2 warnings (I'm still working on that code) on a gcc4 x86_64 box. Jeremy. (This used to be commit d720867a788c735e56d53d63265255830ec21208) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 33ccb6c1b7..7397c88d95 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -357,7 +357,7 @@ static BOOL write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, for ( i=0; inum_values; i++ ) { regval_ctr_addvalue( values, nk->values[i].valuename, nk->values[i].type, - nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) ); + (const char *)nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) ); } /* copy subkeys into the REGSUBKEY_CTR */ -- cgit From 77460a90756dcaa54ec12bbcd30a5266286103d7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 8 Nov 2005 16:33:45 +0000 Subject: r11579: syncing up perf counter code cfrom trunk (This used to be commit 59c00924b67aa3d37a933731a56d03963ec7f1b5) --- source3/utils/net_rpc_registry.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 7397c88d95..289fb59fea 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -117,11 +117,14 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, return werror_to_ntstatus(result); } - result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); - if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to open [%s]\n", argv[0]); - return werror_to_ntstatus(result); + if ( strlen( subpath ) != 0 ) { + result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); + if ( !W_ERROR_IS_OK(result) ) { + d_printf("Unable to open [%s]\n", argv[0]); + return werror_to_ntstatus(result); + } } + memcpy( &pol_key, &pol_hive, sizeof(POLICY_HND) ); /* get the subkeys */ @@ -183,7 +186,8 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, out: /* cleanup */ - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key ); + if ( strlen( subpath ) != 0 ) + rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key ); rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive ); return werror_to_ntstatus(result); -- cgit From 10b182fe731b48592135e1adf457d15c331aa5a1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 12 Jan 2006 17:37:25 +0000 Subject: r12870: fixing net rpc registry enumerate from overwritnig the open subkey handle (This used to be commit cc2e7052bd05a15f43268ce87dc29506bb5bb5bf) --- source3/utils/net_rpc_registry.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 289fb59fea..4ce0b44e4c 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -124,7 +124,6 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, return werror_to_ntstatus(result); } } - memcpy( &pol_key, &pol_hive, sizeof(POLICY_HND) ); /* get the subkeys */ -- cgit From c42be9fd38556a1cc2e16c8d763a592beb863806 Mon Sep 17 00:00:00 2001 From: Lars Müller Date: Tue, 17 Jan 2006 21:22:00 +0000 Subject: r12986: Use d_fprintf(stderr, ...) for any error message in net. All 'usage' messages are still printed to stdout. Fix some compiler warnings for system() calls where we didn't used the return code. Add appropriate error messages and return with the error code we got from system() or NT_STATUS_UNSUCCESSFUL. (This used to be commit f650e3bdafc4c6bcd7eb4bcf8b6b885b979919eb) --- source3/utils/net_rpc_registry.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 4ce0b44e4c..9852fe4a94 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -105,7 +105,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, } if ( !reg_split_hive( argv[0], &hive, subpath ) ) { - d_printf("invalid registry path\n"); + d_fprintf(stderr, "invalid registry path\n"); return NT_STATUS_OK; } @@ -113,14 +113,14 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to connect to remote registry\n"); + d_fprintf(stderr, "Unable to connect to remote registry\n"); return werror_to_ntstatus(result); } if ( strlen( subpath ) != 0 ) { result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to open [%s]\n", argv[0]); + d_fprintf(stderr, "Unable to open [%s]\n", argv[0]); return werror_to_ntstatus(result); } } @@ -223,7 +223,7 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, } if ( !reg_split_hive( argv[0], &hive, subpath ) ) { - d_printf("invalid registry path\n"); + d_fprintf(stderr, "invalid registry path\n"); return NT_STATUS_OK; } @@ -231,19 +231,19 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to connect to remote registry\n"); + d_fprintf(stderr, "Unable to connect to remote registry\n"); return werror_to_ntstatus(result); } result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to open [%s]\n", argv[0]); + d_fprintf(stderr, "Unable to open [%s]\n", argv[0]); return werror_to_ntstatus(result); } result = rpccli_reg_save_key(pipe_hnd, 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]); + d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); } @@ -329,7 +329,7 @@ static BOOL dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa d_printf("\n"); dump_registry_tree( file, key, regpath ); } - + return True; } @@ -401,7 +401,7 @@ static int rpc_registry_dump( int argc, const char **argv ) d_printf("Opening %s....", argv[0]); if ( !(registry = regfio_open( argv[0], O_RDONLY, 0)) ) { - d_printf("Failed to open %s for reading\n", argv[0]); + d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]); return 1; } d_printf("ok\n"); @@ -432,6 +432,7 @@ static int rpc_registry_copy( int argc, const char **argv ) { REGF_FILE *infile, *outfile; REGF_NK_REC *nk; + int result = 1; if (argc != 2 ) { d_printf("Usage: net rpc copy \n"); @@ -440,15 +441,15 @@ static int rpc_registry_copy( int argc, const char **argv ) d_printf("Opening %s....", argv[0]); if ( !(infile = regfio_open( argv[0], O_RDONLY, 0 )) ) { - d_printf("Failed to open %s for reading\n", argv[0]); + d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]); return 1; } d_printf("ok\n"); d_printf("Opening %s....", argv[1]); if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) { - d_printf("Failed to open %s for writing\n", argv[1]); - return 1; + d_fprintf(stderr, "Failed to open %s for writing\n", argv[1]); + goto out_close_infile; } d_printf("ok\n"); @@ -459,15 +460,18 @@ static int rpc_registry_copy( int argc, const char **argv ) write_registry_tree( infile, nk, NULL, outfile, "" ); + result = 0; + d_printf("Closing %s...", argv[1]); regfio_close( outfile ); d_printf("ok\n"); +out_close_infile: d_printf("Closing %s...", argv[0]); regfio_close( infile ); d_printf("ok\n"); - return 0; + return( result); } /******************************************************************** -- cgit From c34e73cfcf29462de597edf9c96435f38635f7f9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 10 Mar 2006 13:14:01 +0000 Subject: r14146: Just some typos. Guenther (This used to be commit ade86cc787e266850fee982b008a9caf2c8ed7e7) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 9852fe4a94..33d5310698 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -100,7 +100,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, if (argc != 1 ) { d_printf("Usage: net rpc enumerate [recurse]\n"); - d_printf("Example:: net rpc enumerate 'HKLM\\Software\\Samba'\n"); + d_printf("Example: net rpc enumerate 'HKLM\\Software\\Samba'\n"); return NT_STATUS_OK; } -- cgit From e7fc37cf0f4bd2c0f25865fb07d1bff27b239130 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 19 Jun 2006 19:07:39 +0000 Subject: r16360: Fix Klocwork ID 136 520 521 522 523 542 574 575 576 607 in net_rpc.c: 715 716 732 734 735 736 737 738 739 749 in net_rpc_audit.c: 754 755 756 in net_rpc_join.c: 757 in net_rpc_registry: 766 767 in net_rpc_samsync.c: 771 773 in net_sam.c: 797 798 Volker (This used to be commit 3df0bf7d6050fd7c9ace72487d4f74d92e30a584) --- source3/utils/net_rpc_registry.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 33d5310698..10ba28e023 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -408,7 +408,10 @@ static int rpc_registry_dump( int argc, const char **argv ) /* get the root of the registry file */ - nk = regfio_rootkey( registry ); + if ((nk = regfio_rootkey( registry )) == NULL) { + d_fprintf(stderr, "Could not get rootkey\n"); + return 1; + } d_printf("[%s]\n", nk->keyname); dump_values( nk ); d_printf("\n"); @@ -455,7 +458,10 @@ static int rpc_registry_copy( int argc, const char **argv ) /* get the root of the registry file */ - nk = regfio_rootkey( infile ); + if ((nk = regfio_rootkey( infile )) == NULL) { + d_fprintf(stderr, "Could not get rootkey\n"); + goto out_close_infile; + } d_printf("RootKey: [%s]\n", nk->keyname); write_registry_tree( infile, nk, NULL, outfile, "" ); -- cgit From 8413a18a58a9f00f440b4252cb671976adcf8b7b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 04:51:23 +0000 Subject: r16612: Klocwork fix #2011. memleak on error path. Jeremy. (This used to be commit b4e9475d2ac65f72cab0d5c8276da27cf1aeb791) --- source3/utils/net_rpc_registry.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 10ba28e023..1b62adc60f 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -433,7 +433,7 @@ static int rpc_registry_dump( int argc, const char **argv ) static int rpc_registry_copy( int argc, const char **argv ) { - REGF_FILE *infile, *outfile; + REGF_FILE *infile = NULL, *outfile = NULL; REGF_NK_REC *nk; int result = 1; @@ -452,7 +452,7 @@ static int rpc_registry_copy( int argc, const char **argv ) d_printf("Opening %s....", argv[1]); if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) { d_fprintf(stderr, "Failed to open %s for writing\n", argv[1]); - goto out_close_infile; + goto out; } d_printf("ok\n"); @@ -460,7 +460,7 @@ static int rpc_registry_copy( int argc, const char **argv ) if ((nk = regfio_rootkey( infile )) == NULL) { d_fprintf(stderr, "Could not get rootkey\n"); - goto out_close_infile; + goto out; } d_printf("RootKey: [%s]\n", nk->keyname); @@ -468,13 +468,18 @@ static int rpc_registry_copy( int argc, const char **argv ) result = 0; +out: + d_printf("Closing %s...", argv[1]); - regfio_close( outfile ); + if (outfile) { + regfio_close( outfile ); + } d_printf("ok\n"); -out_close_infile: d_printf("Closing %s...", argv[0]); - regfio_close( infile ); + if (infile) { + regfio_close( infile ); + } d_printf("ok\n"); return( result); -- cgit From 2ef834cdd8a498a4cf54445fd9e291d86daaad18 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 04:56:23 +0000 Subject: r16614: Klocwork #2012. memleak on error path. Jeremy. (This used to be commit 58b9adb849854610e7167e8aa02a02bd15b0bf00) --- source3/utils/net_rpc_registry.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 1b62adc60f..873cb7b459 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -410,6 +410,7 @@ static int rpc_registry_dump( int argc, const char **argv ) if ((nk = regfio_rootkey( registry )) == NULL) { d_fprintf(stderr, "Could not get rootkey\n"); + regfio_close( registry ); return 1; } d_printf("[%s]\n", nk->keyname); -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/utils/net_rpc_registry.c | 67 +++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 39 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 873cb7b459..3eaff90155 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -25,35 +25,6 @@ /******************************************************************** ********************************************************************/ -char* dump_regval_type( uint32 type ) -{ - static fstring string; - - switch (type) { - case REG_SZ: - fstrcpy( string, "REG_SZ" ); - break; - case REG_MULTI_SZ: - fstrcpy( string, "REG_MULTI_SZ" ); - break; - case REG_EXPAND_SZ: - fstrcpy( string, "REG_EXPAND_SZ" ); - break; - case REG_DWORD: - fstrcpy( string, "REG_DWORD" ); - break; - case REG_BINARY: - fstrcpy( string, "REG_BINARY" ); - break; - default: - fstr_sprintf( string, "UNKNOWN [%d]", type ); - } - - return string; -} -/******************************************************************** -********************************************************************/ - void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer ) { pstring string; @@ -64,9 +35,26 @@ void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer ) rpcstr_pull( string, buffer->buffer, sizeof(string), -1, STR_TERMINATE ); d_printf("%s\n", string); break; - case REG_MULTI_SZ: + case REG_MULTI_SZ: { + int i, num_values; + char **values; + d_printf("\n"); + + if (!NT_STATUS_IS_OK(reg_pull_multi_sz(NULL, buffer->buffer, + buffer->buf_len, + &num_values, + &values))) { + d_printf("reg_pull_multi_sz failed\n"); + break; + } + + for (i=0; ibuffer, 0 ); d_printf( "0x%x\n", value ); @@ -113,16 +101,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); if ( !W_ERROR_IS_OK(result) ) { - d_fprintf(stderr, "Unable to connect to remote registry\n"); + d_fprintf(stderr, "Unable to connect to remote registry: " + "%s\n", dos_errstr(result)); return werror_to_ntstatus(result); } - if ( strlen( subpath ) != 0 ) { - result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); - if ( !W_ERROR_IS_OK(result) ) { - d_fprintf(stderr, "Unable to open [%s]\n", argv[0]); - return werror_to_ntstatus(result); - } + result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, + MAXIMUM_ALLOWED_ACCESS, &pol_key ); + if ( !W_ERROR_IS_OK(result) ) { + d_fprintf(stderr, "Unable to open [%s]: %s\n", argv[0], + dos_errstr(result)); + return werror_to_ntstatus(result); } /* get the subkeys */ @@ -173,7 +162,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, } d_printf("Valuename = %s\n", name ); - d_printf("Type = %s\n", dump_regval_type(type) ); + d_printf("Type = %s\n", reg_type_lookup(type)); d_printf("Data = " ); dump_regval_buffer( type, &value ); d_printf("\n" ); @@ -279,7 +268,7 @@ static void dump_values( REGF_NK_REC *nk ) for ( i=0; inum_values; i++ ) { d_printf( "\"%s\" = ", nk->values[i].valuename ? nk->values[i].valuename : "(default)" ); - d_printf( "(%s) ", dump_regval_type( nk->values[i].type ) ); + d_printf( "(%s) ", reg_type_lookup( nk->values[i].type ) ); data_size = nk->values[i].data_size & ~VK_DATA_IN_OFFSET; switch ( nk->values[i].type ) { -- cgit From bbaa0b178d834f4962ab440dff0e1837029369df Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 26 Sep 2006 15:15:26 +0000 Subject: r18919: * Get the new rpccli_winreg_XXXX() functions into the tree There some broken functionality here that I'm still working on. * remove unneeded parsing routines (This used to be commit cbfe1a4b498593a48fc34f584754ed4a9ef72cc5) --- source3/utils/net_rpc_registry.c | 72 ++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 29 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 3eaff90155..36a925ae13 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -85,6 +85,8 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, pstring subpath; POLICY_HND pol_hive, pol_key; uint32 idx; + NTSTATUS status; + struct winreg_String subkeyname; if (argc != 1 ) { d_printf("Usage: net rpc enumerate [recurse]\n"); @@ -99,16 +101,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, /* open the top level hive and then the registry key */ - result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); - if ( !W_ERROR_IS_OK(result) ) { + 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", dos_errstr(result)); - return werror_to_ntstatus(result); + return status; } - result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, - MAXIMUM_ALLOWED_ACCESS, &pol_key ); - if ( !W_ERROR_IS_OK(result) ) { + 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], dos_errstr(result)); return werror_to_ntstatus(result); @@ -116,17 +119,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, /* get the subkeys */ - result = WERR_OK; + status = NT_STATUS_OK; idx = 0; - while ( W_ERROR_IS_OK(result) ) { + while ( NT_STATUS_IS_OK(status) ) { time_t modtime; fstring keyname, classname; - result = rpccli_reg_enum_key(pipe_hnd, mem_ctx, &pol_key, idx, + status = rpccli_winreg_enum_key(pipe_hnd, mem_ctx, &pol_key, idx, keyname, classname, &modtime ); - if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) { - result = WERR_OK; + if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { + status = NT_STATUS_OK; break; } @@ -138,14 +141,14 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, idx++; } - if ( !W_ERROR_IS_OK(result) ) + if ( !NT_STATUS_IS_OK(status) ) goto out; /* get the values */ - result = WERR_OK; + status = NT_STATUS_OK; idx = 0; - while ( W_ERROR_IS_OK(result) ) { + while ( NT_STATUS_IS_OK(status) ) { uint32 type; fstring name; REGVAL_BUFFER value; @@ -153,11 +156,11 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, fstrcpy( name, "" ); ZERO_STRUCT( value ); - result = rpccli_reg_enum_val(pipe_hnd, mem_ctx, &pol_key, idx, + status = rpccli_winreg_enum_val(pipe_hnd, mem_ctx, &pol_key, idx, name, &type, &value ); - if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) { - result = WERR_OK; + if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { + status = NT_STATUS_OK; break; } @@ -175,10 +178,10 @@ out: /* cleanup */ if ( strlen( subpath ) != 0 ) - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key ); - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); - return werror_to_ntstatus(result); + return status; } /******************************************************************** @@ -205,6 +208,8 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, uint32 hive; pstring subpath; POLICY_HND pol_hive, pol_key; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + struct winreg_String subkeyname; if (argc != 2 ) { d_printf("Usage: net rpc backup \n"); @@ -218,30 +223,39 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, /* open the top level hive and then the registry key */ - result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); - if ( !W_ERROR_IS_OK(result) ) { + 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"); - return werror_to_ntstatus(result); + return status; } - result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); - if ( !W_ERROR_IS_OK(result) ) { + 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); } - result = rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] ); +#if 0 /* IDL not implemented */ + /* original call was: rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] ); */ + + status = rpccli_winreg_SaveKey( cli, mem_ctx ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); } +#else + d_printf("Call not implemented.\n"); + status = NT_STATUS_NOT_IMPLEMENTED; +#endif /* cleanup */ - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key ); - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); - return werror_to_ntstatus(result); + return status; } /******************************************************************** -- cgit From 95e4091596324e3f36ed95cdb13a6e179cb9de08 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 27 Sep 2006 21:37:43 +0000 Subject: r18964: fix 'net rpc registry save' to use the new wnireg client code (This used to be commit f2747daafc2f1cd515570c676b2660ab6fcba740) --- source3/utils/net_rpc_registry.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 36a925ae13..57d1f14d06 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -1,7 +1,8 @@ /* Samba Unix/Linux SMB client library Distributed SMB/CIFS Server Management Utility - Copyright (C) Gerald (Jerry) Carter 2005 + + Copyright (C) Gerald (Jerry) Carter 2005-2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -210,6 +211,7 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, POLICY_HND pol_hive, pol_key; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; struct winreg_String subkeyname; + struct winreg_String filename; if (argc != 2 ) { d_printf("Usage: net rpc backup \n"); @@ -237,18 +239,11 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, return werror_to_ntstatus(result); } -#if 0 /* IDL not implemented */ - /* original call was: rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] ); */ - - status = rpccli_winreg_SaveKey( cli, mem_ctx ); + filename.name = argv[1]; + status = rpccli_winreg_SaveKey( pipe_hnd, mem_ctx, &pol_key, &filename, NULL ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); } -#else - d_printf("Call not implemented.\n"); - status = NT_STATUS_NOT_IMPLEMENTED; -#endif - /* cleanup */ -- cgit From 18d417663395febe60b23f376b2e92c9869e1126 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 28 Sep 2006 21:19:08 +0000 Subject: r18981: * cleanup some vestiges of old cli_reg.c code and mark some TODO items in cac_winreg.c * Get 'net rpc registry enumerate' to list values again * Fix winreg.idl QueryInfoKey(). The max_subkeysize is the max_classlen (we previously had this correct in Samba3") * fix valgrind error about uninitialized memory and use-before-set on size value inmemset() call * Fix key enumeration in 'net rpc registry enumerate' * regenerate gen_dir files based on local pidl patches Please note that the generated ndr files are from my local copy of pidl. If you need to regenerate, please apply the patch that I posted to the samba-technical list earlier today. (This used to be commit 5d843612a1b9d92022f76626f1c7473faebec4ba) --- source3/utils/net_rpc_registry.c | 119 ++++++++++++++++++++++++++++++++------- 1 file changed, 99 insertions(+), 20 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 57d1f14d06..aacf97445c 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -88,6 +88,14 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, uint32 idx; NTSTATUS status; struct winreg_String subkeyname; + struct winreg_String classname; + uint32 num_subkeys, max_subkeylen, max_classlen; + uint32 num_values, max_valnamelen, max_valbufsize; + uint32 secdescsize; + NTTIME last_changed_time; + struct winreg_StringBuf subkey_namebuf; + char *name_buffer; + uint8 *value_buffer; if (argc != 1 ) { d_printf("Usage: net rpc enumerate [recurse]\n"); @@ -102,10 +110,10 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, /* open the top level hive and then the registry key */ - status = rpccli_winreg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); + 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", dos_errstr(result)); + "%s\n", nt_errstr(status)); return status; } @@ -114,29 +122,68 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, 0, MAXIMUM_ALLOWED_ACCESS, &pol_key ); if ( !NT_STATUS_IS_OK(status) ) { d_fprintf(stderr, "Unable to open [%s]: %s\n", argv[0], - dos_errstr(result)); + nt_errstr(status)); return werror_to_ntstatus(result); } - + + classname.name = NULL; + status = rpccli_winreg_QueryInfoKey( pipe_hnd, mem_ctx, &pol_key, + &classname, &num_subkeys, &max_subkeylen, + &max_classlen, &num_values, &max_valnamelen, + &max_valbufsize, &secdescsize, &last_changed_time ); + + if ( !NT_STATUS_IS_OK(status) ) { + d_fprintf(stderr, "Unable to determine subkeys (%s)\n", + nt_errstr(status)); + return status; + } + + /* values do not include the terminating NULL */ + + max_subkeylen += 2; + max_valnamelen += 2; + + if ( (name_buffer = TALLOC_ARRAY( mem_ctx, char, max_subkeylen )) == NULL ) { + d_fprintf(stderr, "Memory allocation error.\n"); + return NT_STATUS_NO_MEMORY; + } + /* get the subkeys */ status = NT_STATUS_OK; idx = 0; while ( NT_STATUS_IS_OK(status) ) { - time_t modtime; - fstring keyname, classname; - - status = rpccli_winreg_enum_key(pipe_hnd, mem_ctx, &pol_key, idx, - keyname, classname, &modtime ); + struct winreg_StringBuf class_namebuf; + fstring kname; + NTTIME modtime; + + class_namebuf.name = NULL; + class_namebuf.size = 0; + class_namebuf.length = 0; + + /* zero out each time */ + + subkey_namebuf.length = 0; + subkey_namebuf.size = max_subkeylen; + memset( name_buffer, 0x0, max_subkeylen ); + subkey_namebuf.name = name_buffer; + + status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, &pol_key, idx, + &subkey_namebuf, &class_namebuf, &modtime); if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { status = NT_STATUS_OK; break; } - - d_printf("Keyname = %s\n", keyname ); - d_printf("Classname = %s\n", classname ); - d_printf("Modtime = %s\n", http_timestring(modtime) ); + + if ( !NT_STATUS_IS_OK(status) ) + goto out; + + StrnCpy( kname, subkey_namebuf.name, MIN(subkey_namebuf.length,sizeof(kname))-1 ); + kname[MIN(subkey_namebuf.length,sizeof(kname))-1] = '\0'; + d_printf("Keyname = %s\n", kname); + d_printf("Modtime = %s\n", + http_timestring(nt_time_to_unix(modtime)) ); d_printf("\n" ); idx++; @@ -144,27 +191,60 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, if ( !NT_STATUS_IS_OK(status) ) goto out; - + + /* TALLOC_FREE( name_buffer ); */ + + if ( (name_buffer = TALLOC_ARRAY( mem_ctx, char, max_valnamelen )) == NULL ) { + d_fprintf(stderr, "Memory allocation error.\n"); + return NT_STATUS_NO_MEMORY; + } + + if ( (value_buffer = TALLOC_ARRAY( mem_ctx, uint8, max_valbufsize )) == NULL ) { + d_fprintf(stderr, "Memory allocation error.\n"); + return NT_STATUS_NO_MEMORY; + } + /* get the values */ status = NT_STATUS_OK; idx = 0; while ( NT_STATUS_IS_OK(status) ) { - uint32 type; + enum winreg_Type type; fstring name; + uint8 *data; + uint32 data_size, value_length; + struct winreg_StringBuf value_namebuf; REGVAL_BUFFER value; fstrcpy( name, "" ); ZERO_STRUCT( value ); - - status = rpccli_winreg_enum_val(pipe_hnd, mem_ctx, &pol_key, idx, - name, &type, &value ); + + memset( name_buffer, 0x0, max_valnamelen ); + value_namebuf.name = name_buffer; + value_namebuf.length = 0; + value_namebuf.size = max_valnamelen; + + memset( value_buffer, 0x0, max_valbufsize ); + data = value_buffer; + data_size = max_valbufsize; + value_length = 0; + + status = rpccli_winreg_EnumValue(pipe_hnd, mem_ctx, &pol_key, idx, + &value_namebuf, &type, data, &data_size, &value_length ); if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { status = NT_STATUS_OK; break; } + + if ( !NT_STATUS_IS_OK(status) ) + goto out; + + init_regval_buffer( &value, data, value_length ); + StrnCpy( name, value_namebuf.name, MIN(max_valnamelen, sizeof(name)-1) ); + name[MIN(max_valnamelen, sizeof(name)-1)] = '\0'; + d_printf("Valuename = %s\n", name ); d_printf("Type = %s\n", reg_type_lookup(type)); d_printf("Data = " ); @@ -174,7 +254,6 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, idx++; } - out: /* cleanup */ @@ -225,7 +304,7 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, /* open the top level hive and then the registry key */ - status = rpccli_winreg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); + 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"); return status; -- cgit From 9849f048680dfdcb6db0f5dcb66a58fc01c8a281 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 19 Nov 2006 17:56:35 +0000 Subject: r19790: Check in the PIDL change and the converted unixinfo and winbind pipes without waiting for comments. This is what version control is for, and it does fix a segfault I ran into ;-) Nevertheless, Jelmer & Jerry, please take a look! Thanks, Volker (This used to be commit 95c14a822cae2ddc2e6ed87f5f5505fa7b98e4f0) --- source3/utils/net_rpc_registry.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index aacf97445c..776a49f99c 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -154,8 +154,10 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, idx = 0; while ( NT_STATUS_IS_OK(status) ) { struct winreg_StringBuf class_namebuf; + struct winreg_StringBuf *p_class_namebuf = &class_namebuf; fstring kname; NTTIME modtime; + NTTIME *p_modtime = &modtime; class_namebuf.name = NULL; class_namebuf.size = 0; @@ -168,8 +170,9 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, memset( name_buffer, 0x0, max_subkeylen ); subkey_namebuf.name = name_buffer; - status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, &pol_key, idx, - &subkey_namebuf, &class_namebuf, &modtime); + status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, &pol_key, + idx, &subkey_namebuf, + &p_class_namebuf, &p_modtime); if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { status = NT_STATUS_OK; @@ -209,10 +212,13 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, status = NT_STATUS_OK; idx = 0; while ( NT_STATUS_IS_OK(status) ) { - enum winreg_Type type; + enum winreg_Type type = REG_NONE; + enum winreg_Type *ptype = &type; fstring name; uint8 *data; uint32 data_size, value_length; + uint32 *pdata_size = &data_size; + uint32 *pvalue_length = &value_length; struct winreg_StringBuf value_namebuf; REGVAL_BUFFER value; @@ -229,8 +235,10 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, data_size = max_valbufsize; value_length = 0; - status = rpccli_winreg_EnumValue(pipe_hnd, mem_ctx, &pol_key, idx, - &value_namebuf, &type, data, &data_size, &value_length ); + status = rpccli_winreg_EnumValue(pipe_hnd, mem_ctx, &pol_key, + idx, &value_namebuf, &ptype, + &data, &pdata_size, + &pvalue_length ); if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { status = NT_STATUS_OK; -- cgit From ef012f8e7a296a99786e568f844c0aef53bc673d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 20 Nov 2006 18:51:00 +0000 Subject: r19804: Fix a valgrind error (This used to be commit cb9e16c8389f25f487e627bbeb06ec45f25aef6b) --- source3/utils/net_rpc_registry.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 776a49f99c..9bcf1ce244 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -156,8 +156,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, struct winreg_StringBuf class_namebuf; struct winreg_StringBuf *p_class_namebuf = &class_namebuf; fstring kname; - NTTIME modtime; - NTTIME *p_modtime = &modtime; + NTTIME *modtime = NULL; class_namebuf.name = NULL; class_namebuf.size = 0; @@ -172,7 +171,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, &pol_key, idx, &subkey_namebuf, - &p_class_namebuf, &p_modtime); + &p_class_namebuf, &modtime); if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { status = NT_STATUS_OK; @@ -185,8 +184,8 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, StrnCpy( kname, subkey_namebuf.name, MIN(subkey_namebuf.length,sizeof(kname))-1 ); kname[MIN(subkey_namebuf.length,sizeof(kname))-1] = '\0'; d_printf("Keyname = %s\n", kname); - d_printf("Modtime = %s\n", - http_timestring(nt_time_to_unix(modtime)) ); + d_printf("Modtime = %s\n", modtime + ? http_timestring(nt_time_to_unix(*modtime)):"None"); d_printf("\n" ); idx++; -- cgit From 515dea007a20574c0227be9c59bdb5c5241e49da Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 20 Nov 2006 23:20:07 +0000 Subject: r19807: First attempt at wrapping something sane around the registry API. Will be extended. Volker (This used to be commit 40922eb924a8e21f28720f2651f087eefc3e3aed) --- source3/utils/net_rpc_registry.c | 480 ++++++++++++++++++++++++++++----------- 1 file changed, 345 insertions(+), 135 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 9bcf1ce244..a04c527502 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -26,6 +26,7 @@ /******************************************************************** ********************************************************************/ +#if 0 void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer ) { pstring string; @@ -69,6 +70,311 @@ void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer ) d_printf( "\tUnknown type [%d]\n", type ); } } +#endif + +static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, + struct rpc_pipe_client *pipe_hnd, + struct policy_handle *key_hnd, + uint32 *pnum_keys, char ***pnames, + char ***pclasses, NTTIME ***pmodtimes) +{ + TALLOC_CTX *mem_ctx; + NTSTATUS status; + uint32 num_subkeys, max_subkeylen, max_classlen; + uint32 num_values, max_valnamelen, max_valbufsize; + uint32 i; + NTTIME last_changed_time; + uint32 secdescsize; + struct winreg_String classname; + char **names, **classes; + NTTIME **modtimes; + + if (!(mem_ctx = talloc_new(ctx))) { + return NT_STATUS_NO_MEMORY; + } + + ZERO_STRUCT(classname); + status = rpccli_winreg_QueryInfoKey( + pipe_hnd, mem_ctx, key_hnd, &classname, &num_subkeys, + &max_subkeylen, &max_classlen, &num_values, &max_valnamelen, + &max_valbufsize, &secdescsize, &last_changed_time ); + + if (!NT_STATUS_IS_OK(status)) { + goto error; + } + + if (num_subkeys == 0) { + *pnum_keys = 0; + TALLOC_FREE(mem_ctx); + return NT_STATUS_OK; + } + + if ((!(names = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_subkeys))) || + (!(classes = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_subkeys))) || + (!(modtimes = TALLOC_ZERO_ARRAY(mem_ctx, NTTIME *, + num_subkeys)))) { + status = NT_STATUS_NO_MEMORY; + goto error; + } + + for (i=0; iname)))) { + status = NT_STATUS_NO_MEMORY; + goto error; + } + + if (!(names[i] = talloc_strdup(names, name_buf.name))) { + status = NT_STATUS_NO_MEMORY; + goto error; + } + + if ((pmodtime) && + (!(modtimes[i] = (NTTIME *)talloc_memdup( + modtimes, pmodtime, sizeof(*pmodtime))))) { + status = NT_STATUS_NO_MEMORY; + goto error; + } + } + + *pnum_keys = num_subkeys; + + if (pnames) { + *pnames = talloc_move(ctx, &names); + } + if (pclasses) { + *pclasses = talloc_move(ctx, &classes); + } + if (pmodtimes) { + *pmodtimes = talloc_move(ctx, &modtimes); + } + + status = NT_STATUS_OK; + + error: + TALLOC_FREE(mem_ctx); + return status; +} + +static NTSTATUS registry_pull_value(TALLOC_CTX *mem_ctx, + struct registry_value **pvalue, + enum winreg_Type type, uint8 *data, + uint32 size, uint32 length) +{ + struct registry_value *value; + NTSTATUS status; + + if (!(value = TALLOC_P(mem_ctx, struct registry_value))) { + return NT_STATUS_NO_MEMORY; + } + + value->type = type; + + switch (type) { + case REG_DWORD: + if ((size != 4) || (length != 4)) { + status = NT_STATUS_INVALID_PARAMETER; + goto error; + } + value->v.dword = IVAL(data, 0); + break; + case REG_SZ: + case REG_EXPAND_SZ: + { + /* + * Make sure we get a NULL terminated string for + * convert_string_talloc(). + */ + + smb_ucs2_t *tmp; + uint32 num_ucs2 = length / 2; + + if ((length % 2) != 0) { + status = NT_STATUS_INVALID_PARAMETER; + goto error; + } + + if (!(tmp = SMB_MALLOC_ARRAY(smb_ucs2_t, num_ucs2+1))) { + status = NT_STATUS_NO_MEMORY; + goto error; + } + + memcpy((void *)tmp, (const void *)data, length); + tmp[num_ucs2] = 0; + + value->v.sz.len = convert_string_talloc( + value, CH_UTF16LE, CH_UNIX, tmp, length+2, + &value->v.sz.str, False); + + SAFE_FREE(tmp); + + if (value->v.sz.len == (size_t)-1) { + status = NT_STATUS_INVALID_PARAMETER; + goto error; + } + break; + } + default: + status = NT_STATUS_INVALID_PARAMETER; + goto error; + } + + *pvalue = value; + return NT_STATUS_OK; + + error: + TALLOC_FREE(value); + return status; +} + +static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, + struct rpc_pipe_client *pipe_hnd, + struct policy_handle *key_hnd, + uint32 *pnum_values, char ***pvalnames, + struct registry_value ***pvalues) +{ + TALLOC_CTX *mem_ctx; + NTSTATUS status; + uint32 num_subkeys, max_subkeylen, max_classlen; + uint32 num_values, max_valnamelen, max_valbufsize; + uint32 i; + NTTIME last_changed_time; + uint32 secdescsize; + struct winreg_String classname; + struct registry_value **values; + char **names; + + if (!(mem_ctx = talloc_new(ctx))) { + return NT_STATUS_NO_MEMORY; + } + + ZERO_STRUCT(classname); + status = rpccli_winreg_QueryInfoKey( + pipe_hnd, mem_ctx, key_hnd, &classname, &num_subkeys, + &max_subkeylen, &max_classlen, &num_values, &max_valnamelen, + &max_valbufsize, &secdescsize, &last_changed_time ); + + if (!NT_STATUS_IS_OK(status)) { + goto error; + } + + if (num_values == 0) { + *pnum_values = 0; + TALLOC_FREE(mem_ctx); + return NT_STATUS_OK; + } + + if ((!(names = TALLOC_ARRAY(mem_ctx, char *, num_values))) || + (!(values = TALLOC_ARRAY(mem_ctx, struct registry_value *, + num_values)))) { + status = NT_STATUS_NO_MEMORY; + goto error; + } + + for (i=0; i [recurse]\n"); @@ -126,144 +429,51 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, return werror_to_ntstatus(result); } - classname.name = NULL; - status = rpccli_winreg_QueryInfoKey( pipe_hnd, mem_ctx, &pol_key, - &classname, &num_subkeys, &max_subkeylen, - &max_classlen, &num_values, &max_valnamelen, - &max_valbufsize, &secdescsize, &last_changed_time ); - - if ( !NT_STATUS_IS_OK(status) ) { - d_fprintf(stderr, "Unable to determine subkeys (%s)\n", - nt_errstr(status)); + status = registry_enumkeys(mem_ctx, pipe_hnd, &pol_key, &num_subkeys, + &names, &classes, &modtimes); + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "enumerating keys failed: %s\n", + nt_errstr(status)); return status; } - /* values do not include the terminating NULL */ - - max_subkeylen += 2; - max_valnamelen += 2; - - if ( (name_buffer = TALLOC_ARRAY( mem_ctx, char, max_subkeylen )) == NULL ) { - d_fprintf(stderr, "Memory allocation error.\n"); - return NT_STATUS_NO_MEMORY; - } - - /* get the subkeys */ - - status = NT_STATUS_OK; - idx = 0; - while ( NT_STATUS_IS_OK(status) ) { - struct winreg_StringBuf class_namebuf; - struct winreg_StringBuf *p_class_namebuf = &class_namebuf; - fstring kname; - NTTIME *modtime = NULL; - - class_namebuf.name = NULL; - class_namebuf.size = 0; - class_namebuf.length = 0; - - /* zero out each time */ - - subkey_namebuf.length = 0; - subkey_namebuf.size = max_subkeylen; - memset( name_buffer, 0x0, max_subkeylen ); - subkey_namebuf.name = name_buffer; - - status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, &pol_key, - idx, &subkey_namebuf, - &p_class_namebuf, &modtime); - - if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { - status = NT_STATUS_OK; - break; - } - - if ( !NT_STATUS_IS_OK(status) ) - goto out; - - StrnCpy( kname, subkey_namebuf.name, MIN(subkey_namebuf.length,sizeof(kname))-1 ); - kname[MIN(subkey_namebuf.length,sizeof(kname))-1] = '\0'; - d_printf("Keyname = %s\n", kname); - d_printf("Modtime = %s\n", modtime - ? http_timestring(nt_time_to_unix(*modtime)):"None"); + for (i=0; itype)); + switch(v->type) { + case REG_DWORD: + d_printf("Value = %d\n", v->v.dword); + break; + case REG_SZ: + case REG_EXPAND_SZ: + d_printf("Value = \"%s\"\n", v->v.sz.str); + break; + default: + d_printf("Value = \n"); break; } - - if ( !NT_STATUS_IS_OK(status) ) - goto out; - - init_regval_buffer( &value, data, value_length ); - StrnCpy( name, value_namebuf.name, MIN(max_valnamelen, sizeof(name)-1) ); - name[MIN(max_valnamelen, sizeof(name)-1)] = '\0'; - - d_printf("Valuename = %s\n", name ); - d_printf("Type = %s\n", reg_type_lookup(type)); - d_printf("Data = " ); - dump_regval_buffer( type, &value ); - d_printf("\n" ); - - idx++; + d_printf("\n"); } - -out: - /* cleanup */ - + if ( strlen( subpath ) != 0 ) rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); -- cgit From 202f63e476fc1dc60d9f1271673b292288cfb436 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 02:21:45 +0000 Subject: r19811: Decode REG_MULTI_SZ and REG_BINARY (This used to be commit 679330175185f8504bb5968339dcc7cb20d9140c) --- source3/utils/net_rpc_registry.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index a04c527502..45598c49f5 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -197,7 +197,7 @@ static NTSTATUS registry_pull_value(TALLOC_CTX *mem_ctx, struct registry_value *value; NTSTATUS status; - if (!(value = TALLOC_P(mem_ctx, struct registry_value))) { + if (!(value = TALLOC_ZERO_P(mem_ctx, struct registry_value))) { return NT_STATUS_NO_MEMORY; } @@ -247,6 +247,18 @@ static NTSTATUS registry_pull_value(TALLOC_CTX *mem_ctx, } break; } + case REG_MULTI_SZ: + status = reg_pull_multi_sz(value, (void *)data, length, + &value->v.multi_sz.num_strings, + &value->v.multi_sz.strings); + if (!(NT_STATUS_IS_OK(status))) { + goto error; + } + break; + case REG_BINARY: + value->v.binary.data = talloc_move(value, &data); + value->v.binary.length = length; + break; default: status = NT_STATUS_INVALID_PARAMETER; goto error; @@ -466,6 +478,18 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, case REG_EXPAND_SZ: d_printf("Value = \"%s\"\n", v->v.sz.str); break; + case REG_MULTI_SZ: { + uint32 j; + for (j = 0; j < v->v.multi_sz.num_strings; j++) { + d_printf("Value[%3.3d] = \"%s\"\n", j, + v->v.multi_sz.strings[j]); + } + break; + } + case REG_BINARY: + d_printf("Value = %d bytes\n", + v->v.binary.length); + break; default: d_printf("Value = \n"); break; -- cgit From 3b5d82cedd28f872e23564175f87bb8e7e4330fb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 02:23:43 +0000 Subject: r19812: dump_regval_buf is not needed anymore (This used to be commit f24e64160dc7d7b7434cbed15677c105fa7b60de) --- source3/utils/net_rpc_registry.c | 49 ---------------------------------------- 1 file changed, 49 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 45598c49f5..3401134488 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -23,55 +23,6 @@ #include "regfio.h" #include "reg_objects.h" -/******************************************************************** -********************************************************************/ - -#if 0 -void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer ) -{ - pstring string; - uint32 value; - - switch (type) { - case REG_SZ: - rpcstr_pull( string, buffer->buffer, sizeof(string), -1, STR_TERMINATE ); - d_printf("%s\n", string); - break; - case REG_MULTI_SZ: { - int i, num_values; - char **values; - - d_printf("\n"); - - if (!NT_STATUS_IS_OK(reg_pull_multi_sz(NULL, buffer->buffer, - buffer->buf_len, - &num_values, - &values))) { - d_printf("reg_pull_multi_sz failed\n"); - break; - } - - for (i=0; ibuffer, 0 ); - d_printf( "0x%x\n", value ); - break; - case REG_BINARY: - d_printf("\n"); - break; - - - default: - d_printf( "\tUnknown type [%d]\n", type ); - } -} -#endif - static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, struct rpc_pipe_client *pipe_hnd, struct policy_handle *key_hnd, -- cgit From 28bbef032fa86f2346639ee8e5d5efdd3fd67d1b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 10:32:08 +0000 Subject: r19817: Implement net rpc registry setvalue (only dword and sz so far) (This used to be commit 9ecb69c075060d199133520ac6a7627a5faba7f3) --- source3/utils/net_rpc_registry.c | 191 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 3401134488..10848d0afd 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -23,6 +23,74 @@ #include "regfio.h" #include "reg_objects.h" +static BOOL reg_hive_key(const char *fullname, uint32 *reg_type, + const char **key_name) +{ + const char *sep; + ptrdiff_t len; + + sep = strchr_m(fullname, '\\'); + + if (sep != NULL) { + len = sep - fullname; + *key_name = sep+1; + } + else { + len = strlen(fullname); + *key_name = ""; + } + + if (strnequal(fullname, "HKLM", len) || + strnequal(fullname, "HKEY_LOCAL_MACHINE", len)) + (*reg_type) = HKEY_LOCAL_MACHINE; + else if (strnequal(fullname, "HKCR", len) || + strnequal(fullname, "HKEY_CLASSES_ROOT", len)) + (*reg_type) = HKEY_CLASSES_ROOT; + else if (strnequal(fullname, "HKU", len) || + strnequal(fullname, "HKEY_USERS", len)) + (*reg_type) = HKEY_USERS; + else if (strnequal(fullname, "HKPD", len) || + strnequal(fullname, "HKEY_PERFORMANCE_DATA", len)) + (*reg_type) = HKEY_PERFORMANCE_DATA; + else { + DEBUG(10,("reg_hive_key: unrecognised hive key %s\n", + fullname)); + return False; + } + + return True; +} + +static NTSTATUS registry_openkey(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *pipe_hnd, + const char *name, uint32 access_mask, + struct policy_handle *hive_hnd, + struct policy_handle *key_hnd) +{ + uint32 hive; + NTSTATUS status; + struct winreg_String key; + + if (!reg_hive_key(name, &hive, &key.name)) { + return NT_STATUS_INVALID_PARAMETER; + } + + status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, access_mask, + hive_hnd); + if (!(NT_STATUS_IS_OK(status))) { + return status; + } + + status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, hive_hnd, key, 0, + access_mask, key_hnd); + if (!(NT_STATUS_IS_OK(status))) { + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, hive_hnd); + return status; + } + + return NT_STATUS_OK; +} + static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, struct rpc_pipe_client *pipe_hnd, struct policy_handle *key_hnd, @@ -223,6 +291,38 @@ static NTSTATUS registry_pull_value(TALLOC_CTX *mem_ctx, return status; } +static NTSTATUS registry_push_value(TALLOC_CTX *mem_ctx, + const struct registry_value *value, + DATA_BLOB *presult) +{ + switch (value->type) { + case REG_DWORD: { + char buf[4]; + SIVAL(buf, 0, value->v.dword); + *presult = data_blob_talloc(mem_ctx, (void *)buf, 4); + if (presult->data == NULL) { + return NT_STATUS_NO_MEMORY; + } + break; + } + case REG_SZ: + case REG_EXPAND_SZ: { + presult->length = convert_string_talloc( + mem_ctx, CH_UNIX, CH_UTF16LE, value->v.sz.str, + MIN(value->v.sz.len, strlen(value->v.sz.str)+1), + (void *)&(presult->data), False); + if (presult->length == (size_t)-1) { + return NT_STATUS_NO_MEMORY; + } + break; + } + default: + return NT_STATUS_INVALID_PARAMETER; + } + + return NT_STATUS_OK; +} + static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, struct rpc_pipe_client *pipe_hnd, struct policy_handle *key_hnd, @@ -339,6 +439,96 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, return status; } +static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *pipe_hnd, + struct policy_handle *key_hnd, + const char *name, + const struct registry_value *value) +{ + struct winreg_String name_string; + DATA_BLOB blob; + NTSTATUS result; + + result = registry_push_value(mem_ctx, value, &blob); + if (!NT_STATUS_IS_OK(result)) { + return result; + } + + name_string.name = name; + result = rpccli_winreg_SetValue(pipe_hnd, blob.data, key_hnd, + name_string, value->type, + blob.data, blob.length); + TALLOC_FREE(blob.data); + return result; +} + +static NTSTATUS rpc_registry_setvalue_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; + struct registry_value value; + + if (argc < 4) { + d_fprintf(stderr, "usage: net rpc registry setvalue " + " []+\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)) { + d_fprintf(stderr, "registry_openkey failed: %s\n", + nt_errstr(status)); + return status; + } + + if (!strequal(argv[2], "multi_sz") && (argc != 4)) { + d_fprintf(stderr, "Too many args for type %s\n", argv[2]); + return NT_STATUS_NOT_IMPLEMENTED; + } + + if (strequal(argv[2], "dword")) { + value.type = REG_DWORD; + value.v.dword = strtoul(argv[3], NULL, 10); + } + else if (strequal(argv[2], "sz")) { + value.type = REG_SZ; + value.v.sz.len = strlen(argv[3])+1; + value.v.sz.str = CONST_DISCARD(char *, argv[3]); + } + else { + d_fprintf(stderr, "type \"%s\" not implemented\n", argv[3]); + status = NT_STATUS_NOT_IMPLEMENTED; + goto error; + } + + status = registry_setvalue(mem_ctx, pipe_hnd, &key_hnd, + argv[1], &value); + + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "registry_setvalue failed: %s\n", + nt_errstr(status)); + } + + error: + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + + return NT_STATUS_OK; +} + +static int rpc_registry_setvalue( int argc, const char **argv ) +{ + return run_rpc_command( NULL, PI_WINREG, 0, + rpc_registry_setvalue_internal, argc, argv ); +} + /******************************************************************** ********************************************************************/ @@ -774,6 +964,7 @@ int net_rpc_registry(int argc, const char **argv) { struct functable func[] = { {"enumerate", rpc_registry_enumerate}, + {"setvalue", rpc_registry_setvalue}, {"save", rpc_registry_save}, {"dump", rpc_registry_dump}, {"copy", rpc_registry_copy}, -- cgit From c63be3a4e7909cc3f71fcad6d134a7bb2fc19529 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 10:48:11 +0000 Subject: r19818: Remove reg_split_hive, make use of registry_openkey (This used to be commit 7fd1578a905d3c974cb88cc93452d43a03038d30) --- source3/utils/net_rpc_registry.c | 74 +++++++++++----------------------------- 1 file changed, 19 insertions(+), 55 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') 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 " - " []+\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 " + " []+\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) ) { -- cgit From e56be1deade10ffb736e4b580aef8ddaff4e9e59 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 14:01:03 +0000 Subject: r19821: Make net_rpc_registry use net_run_function2. Fix an erroneous NT_STATUS_NO_MEMORY found by Chetan S . Thanks :-) Volker (This used to be commit 30f02e73fd85faa89186511edab4d5396d5efb6a) --- source3/utils/net_rpc_registry.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 65af269c02..4c740be44d 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -169,7 +169,7 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, classes[i] = NULL; - if ((pclass_buf) && + if (pclass_buf && pclass_buf->name && (!(classes[i] = talloc_strdup(classes, pclass_buf->name)))) { status = NT_STATUS_NO_MEMORY; @@ -912,31 +912,21 @@ out: /******************************************************************** ********************************************************************/ -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 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; -} - -/******************************************************************** -********************************************************************/ - int net_rpc_registry(int argc, const char **argv) { - struct functable func[] = { - {"enumerate", rpc_registry_enumerate}, - {"setvalue", rpc_registry_setvalue}, - {"save", rpc_registry_save}, - {"dump", rpc_registry_dump}, - {"copy", rpc_registry_copy}, - {NULL, NULL} + struct functable2 func[] = { + { "enumerate", rpc_registry_enumerate, + "Enumerate registry keys and values" }, + { "setvalue", rpc_registry_setvalue, + "Set a new registry value" }, + { "save", rpc_registry_save, + "Save a registry file" }, + { "dump", rpc_registry_dump, + "Dump a registry file" }, + { "copy", rpc_registry_copy, + "Copy a registry file" }, + {NULL, NULL, NULL} }; - if ( argc ) - return net_run_function( argc, argv, func, net_help_registry ); - - return net_help_registry( argc, argv ); + return net_run_function2(argc, argv, "net rpc registry", func); } -- cgit From ef4112922ab5d7b40b390356b55816659b9bd446 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 15:33:55 +0000 Subject: r19822: Implement net rpc registry createkey, deletekey and deletevalue (This used to be commit 419ebc92f02c9a927295ec7c54844bd5666e3f17) --- source3/utils/net_rpc_registry.c | 168 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 4c740be44d..5d399b4b96 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -529,6 +529,168 @@ static int rpc_registry_setvalue( int argc, const char **argv ) rpc_registry_setvalue_internal, argc, argv ); } +static NTSTATUS rpc_registry_deletevalue_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; + struct winreg_String valuename; + + status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_WRITE, + &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]; + + status = rpccli_winreg_DeleteValue(pipe_hnd, mem_ctx, &key_hnd, + valuename); + + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "registry_deletevalue failed: %s\n", + nt_errstr(status)); + } + + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + + return NT_STATUS_OK; +} + +static int rpc_registry_deletevalue( int argc, const char **argv ) +{ + if (argc != 2) { + d_fprintf(stderr, "usage: net rpc registry deletevalue " + "\n"); + return -1; + } + + return run_rpc_command( NULL, PI_WINREG, 0, + rpc_registry_deletevalue_internal, argc, argv ); +} + +static NTSTATUS rpc_registry_createkey_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 ) +{ + uint32 hive; + struct policy_handle hive_hnd, key_hnd; + struct winreg_String key, keyclass; + enum winreg_CreateAction action; + enum winreg_CreateAction *paction = &action; + NTSTATUS status; + + if (!reg_hive_key(argv[0], &hive, &key.name)) { + return NT_STATUS_INVALID_PARAMETER; + } + + status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, REG_KEY_WRITE, + &hive_hnd); + if (!(NT_STATUS_IS_OK(status))) { + return status; + } + + action = REG_ACTION_NONE; + keyclass.name = ""; + + status = rpccli_winreg_CreateKey(pipe_hnd, mem_ctx, &hive_hnd, key, + keyclass, 0, REG_KEY_READ, NULL, + &key_hnd, &paction); + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "createkey returned %s\n", + nt_errstr(status)); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + return status; + } + + if (paction) { + switch (*paction) { + case REG_ACTION_NONE: + d_printf("createkey did nothing -- huh?\n"); + break; + case REG_CREATED_NEW_KEY: + d_printf("createkey created %s\n", argv[0]); + break; + case REG_OPENED_EXISTING_KEY: + d_printf("createkey opened existing %s\n", argv[0]); + break; + } + } + + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + + return status; +} + +static int rpc_registry_createkey( int argc, const char **argv ) +{ + if (argc != 1) { + d_fprintf(stderr, "usage: net rpc registry createkey \n"); + return -1; + } + + return run_rpc_command( NULL, PI_WINREG, 0, + rpc_registry_createkey_internal, argc, argv ); +} + +static NTSTATUS rpc_registry_deletekey_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 ) +{ + uint32 hive; + struct policy_handle hive_hnd; + struct winreg_String key; + NTSTATUS status; + + if (!reg_hive_key(argv[0], &hive, &key.name)) { + return NT_STATUS_INVALID_PARAMETER; + } + + status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, REG_KEY_WRITE, + &hive_hnd); + if (!(NT_STATUS_IS_OK(status))) { + return status; + } + + status = rpccli_winreg_DeleteKey(pipe_hnd, mem_ctx, &hive_hnd, key); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "deletekey returned %s\n", + nt_errstr(status)); + } + + return status; +} + +static int rpc_registry_deletekey( int argc, const char **argv ) +{ + if (argc != 1) { + d_fprintf(stderr, "usage: net rpc registry deletekey \n"); + return -1; + } + + return run_rpc_command( NULL, PI_WINREG, 0, + rpc_registry_deletekey_internal, argc, argv ); +} + /******************************************************************** ********************************************************************/ @@ -917,8 +1079,14 @@ int net_rpc_registry(int argc, const char **argv) struct functable2 func[] = { { "enumerate", rpc_registry_enumerate, "Enumerate registry keys and values" }, + { "createkey", rpc_registry_createkey, + "Create a new registry key" }, + { "deletekey", rpc_registry_deletekey, + "Delete a registry key" }, { "setvalue", rpc_registry_setvalue, "Set a new registry value" }, + { "deletevalue", rpc_registry_deletevalue, + "Delete a registry value" }, { "save", rpc_registry_save, "Save a registry file" }, { "dump", rpc_registry_dump, -- cgit From 6fad55ff89965c7a6a9cbe0da6a2dea5bb635434 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 20:10:39 +0000 Subject: r19825: To create a key, smbd also needs read privs assigned (This used to be commit b2866b1318f2fa521ff93ec5ed58413b9145385a) --- source3/utils/net_rpc_registry.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 5d399b4b96..8bdea0ffd4 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -596,7 +596,8 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, return NT_STATUS_INVALID_PARAMETER; } - status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, REG_KEY_WRITE, + status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, + REG_KEY_READ|REG_KEY_WRITE, &hive_hnd); if (!(NT_STATUS_IS_OK(status))) { return status; -- cgit From 334c868b83f84130907dd2c9ed58cfeb6b9bb41c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 21:18:53 +0000 Subject: r19827: Move registry_push/pull_value to lib/util_reg.c (This used to be commit 3047a4b92c7d5391a8f162f26ccc92ce30c35cee) --- source3/utils/net_rpc_registry.c | 115 --------------------------------------- 1 file changed, 115 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 8bdea0ffd4..49149db19e 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -208,121 +208,6 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, return status; } -static NTSTATUS registry_pull_value(TALLOC_CTX *mem_ctx, - struct registry_value **pvalue, - enum winreg_Type type, uint8 *data, - uint32 size, uint32 length) -{ - struct registry_value *value; - NTSTATUS status; - - if (!(value = TALLOC_ZERO_P(mem_ctx, struct registry_value))) { - return NT_STATUS_NO_MEMORY; - } - - value->type = type; - - switch (type) { - case REG_DWORD: - if ((size != 4) || (length != 4)) { - status = NT_STATUS_INVALID_PARAMETER; - goto error; - } - value->v.dword = IVAL(data, 0); - break; - case REG_SZ: - case REG_EXPAND_SZ: - { - /* - * Make sure we get a NULL terminated string for - * convert_string_talloc(). - */ - - smb_ucs2_t *tmp; - uint32 num_ucs2 = length / 2; - - if ((length % 2) != 0) { - status = NT_STATUS_INVALID_PARAMETER; - goto error; - } - - if (!(tmp = SMB_MALLOC_ARRAY(smb_ucs2_t, num_ucs2+1))) { - status = NT_STATUS_NO_MEMORY; - goto error; - } - - memcpy((void *)tmp, (const void *)data, length); - tmp[num_ucs2] = 0; - - value->v.sz.len = convert_string_talloc( - value, CH_UTF16LE, CH_UNIX, tmp, length+2, - &value->v.sz.str, False); - - SAFE_FREE(tmp); - - if (value->v.sz.len == (size_t)-1) { - status = NT_STATUS_INVALID_PARAMETER; - goto error; - } - break; - } - case REG_MULTI_SZ: - status = reg_pull_multi_sz(value, (void *)data, length, - &value->v.multi_sz.num_strings, - &value->v.multi_sz.strings); - if (!(NT_STATUS_IS_OK(status))) { - goto error; - } - break; - case REG_BINARY: - value->v.binary.data = talloc_move(value, &data); - value->v.binary.length = length; - break; - default: - status = NT_STATUS_INVALID_PARAMETER; - goto error; - } - - *pvalue = value; - return NT_STATUS_OK; - - error: - TALLOC_FREE(value); - return status; -} - -static NTSTATUS registry_push_value(TALLOC_CTX *mem_ctx, - const struct registry_value *value, - DATA_BLOB *presult) -{ - switch (value->type) { - case REG_DWORD: { - char buf[4]; - SIVAL(buf, 0, value->v.dword); - *presult = data_blob_talloc(mem_ctx, (void *)buf, 4); - if (presult->data == NULL) { - return NT_STATUS_NO_MEMORY; - } - break; - } - case REG_SZ: - case REG_EXPAND_SZ: { - presult->length = convert_string_talloc( - mem_ctx, CH_UNIX, CH_UTF16LE, value->v.sz.str, - MIN(value->v.sz.len, strlen(value->v.sz.str)+1), - (void *)&(presult->data), False); - if (presult->length == (size_t)-1) { - return NT_STATUS_NO_MEMORY; - } - break; - } - default: - return NT_STATUS_INVALID_PARAMETER; - } - - return NT_STATUS_OK; -} - static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, struct rpc_pipe_client *pipe_hnd, struct policy_handle *key_hnd, -- cgit From f57cd1f63c900a7b17955cc7e11cd1f6b6b12474 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 27 Nov 2006 07:52:46 +0000 Subject: r19914: The "default" value with the name "" need different 0-length treatment as the other StringBufs, otherwise clicking on a key with this value being set leads to regedit.exe on w2k3 chew all memory. (This used to be commit b148cde7f39859102288a87b6f0bd2b250947a85) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 49149db19e..c684b04b8e 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -265,7 +265,7 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, uint32 *pvalue_length = &value_length; char n; - struct winreg_StringBuf name_buf; + struct winreg_ValNameBuf name_buf; n = '\0'; name_buf.name = &n; -- cgit From ecf90c495eb850cd6f376fb4e090640b69f0c029 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 1 Dec 2006 20:01:09 +0000 Subject: r19991: Sorry for this 2000-liner... The main thing here is a rewrite of srv_winreg_nt.c. The core functionality has moved to registry/reg_api.c which is then usable by the rest of Samba as well. On that way it fixes creating keys with more than one element in the path. This did not work before. Two things that sneaked in (sorry :-) is the change of some routines from NTSTATUS to WERROR the removed "parent" argument to regkey_open_internal. Volker (This used to be commit fea52801de8c7b85c578d200c599475680c5339f) --- source3/utils/net_rpc_registry.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index c684b04b8e..3634b0a4f2 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -266,6 +266,7 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, char n; struct winreg_ValNameBuf name_buf; + WERROR err; n = '\0'; name_buf.name = &n; @@ -301,9 +302,10 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, goto error; } - status = registry_pull_value(values, &values[i], *ptype, data, - *pdata_size, *pvalue_length); - if (!(NT_STATUS_IS_OK(status))) { + err = registry_pull_value(values, &values[i], *ptype, data, + *pdata_size, *pvalue_length); + if (!W_ERROR_IS_OK(err)) { + status = werror_to_ntstatus(err); goto error; } } @@ -333,10 +335,11 @@ static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx, struct winreg_String name_string; DATA_BLOB blob; NTSTATUS result; + WERROR err; - result = registry_push_value(mem_ctx, value, &blob); - if (!NT_STATUS_IS_OK(result)) { - return result; + err = registry_push_value(mem_ctx, value, &blob); + if (!W_ERROR_IS_OK(err)) { + return werror_to_ntstatus(err); } name_string.name = name; @@ -590,12 +593,12 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, { POLICY_HND pol_hive, pol_key; NTSTATUS status; - uint32 num_subkeys; - uint32 num_values; - char **names, **classes; - NTTIME **modtimes; + uint32 num_subkeys = 0; + uint32 num_values = 0; + char **names = NULL, **classes = NULL; + NTTIME **modtimes = NULL; uint32 i; - struct registry_value **values; + struct registry_value **values = NULL; if (argc != 1 ) { d_printf("Usage: net rpc enumerate [recurse]\n"); -- cgit From 38cc572b1eef9b9ccb020eeea67a3881ff0f6664 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 2 Dec 2006 10:51:21 +0000 Subject: r20003: Fix error message (This used to be commit de053583510999658b2969b244b43ae85fb87737) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 3634b0a4f2..ea160b201c 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -385,7 +385,7 @@ static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid, value.v.sz.str = CONST_DISCARD(char *, argv[3]); } else { - d_fprintf(stderr, "type \"%s\" not implemented\n", argv[3]); + d_fprintf(stderr, "type \"%s\" not implemented\n", argv[2]); status = NT_STATUS_NOT_IMPLEMENTED; goto error; } -- cgit From 8cc702bf5aeb0bedf012affb0c476cfc5f3dfa80 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 3 Jan 2007 06:39:18 +0000 Subject: r20498: Two 64-bit warnings (This used to be commit 382827ebac61646ec31fe1d56ccde2ea337e8f9e) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index ea160b201c..e63471f176 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -661,7 +661,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, } case REG_BINARY: d_printf("Value = %d bytes\n", - v->v.binary.length); + (int)v->v.binary.length); break; default: d_printf("Value = \n"); -- cgit From 62e11c4f1748d98f479110c8c0e656a8f65dca4d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 16 Jan 2007 15:42:03 +0000 Subject: r20832: Remove extra pointers previously added to unique [out] pointers. Instead, add [ref] pointers where necessary (top-level [ref] pointers, by spec, don't appear on the wire). This brings us closer to the DCE/RPC standard again. (This used to be commit 580f2a7197b1bc9db14a643fdd112b40ef37aaef) --- source3/utils/net_rpc_registry.c | 45 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index e63471f176..0a3ceb2233 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -139,10 +139,8 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, for (i=0; iname && - (!(classes[i] = talloc_strdup(classes, - pclass_buf->name)))) { + if (class_buf.name && + (!(classes[i] = talloc_strdup(classes, class_buf.name)))) { status = NT_STATUS_NO_MEMORY; goto error; } @@ -181,9 +178,8 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, goto error; } - if ((pmodtime) && - (!(modtimes[i] = (NTTIME *)talloc_memdup( - modtimes, pmodtime, sizeof(*pmodtime))))) { + if ((!(modtimes[i] = (NTTIME *)talloc_memdup( + modtimes, &modtime, sizeof(modtime))))) { status = NT_STATUS_NO_MEMORY; goto error; } @@ -254,15 +250,9 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, for (i=0; i Date: Tue, 20 Feb 2007 13:43:41 +0000 Subject: r21462: Fix EnumValue (?) (This used to be commit e73a418b5b0100936efb4c1133da3cfe3fcb61cd) --- source3/utils/net_rpc_registry.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 0a3ceb2233..f1c046c181 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -263,11 +263,12 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, name_buf.size = max_valnamelen + 2; data_size = max_valbufsize; + data = TALLOC(mem_ctx, data_size); value_length = 0; status = rpccli_winreg_EnumValue(pipe_hnd, mem_ctx, key_hnd, i, &name_buf, &type, - &data, &data_size, + data, &data_size, &value_length ); if ( W_ERROR_EQUAL(ntstatus_to_werror(status), -- cgit From 71921605995fa95d84301534760a6bc2db3fa74b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 7 May 2007 15:07:49 +0000 Subject: r22747: Fix some C++ warnings (This used to be commit a66a04e9f11f6c4462f2b56b447bae4eca7b177c) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index f1c046c181..b439f50ee4 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -263,7 +263,7 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, name_buf.size = max_valnamelen + 2; data_size = max_valbufsize; - data = TALLOC(mem_ctx, data_size); + data = (uint8 *)TALLOC(mem_ctx, data_size); value_length = 0; status = rpccli_winreg_EnumValue(pipe_hnd, mem_ctx, key_hnd, -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index b439f50ee4..b7eb3a7486 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/utils/net_rpc_registry.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index b7eb3a7486..aac49dd7f9 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + along with this program. If not, see . */ #include "includes.h" #include "utils/net.h" -- cgit From 6e419551ae06abff4b19abb6ceb1978f8c58e353 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 26 Jul 2007 16:39:48 +0000 Subject: r24057: Fix some uninitialized variables found by the IBM checker (This used to be commit d74bbc53c2cf41e7e92309e81bb9c1b3f805cdd1) --- source3/utils/net_rpc_registry.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index aac49dd7f9..0d54ff3907 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -70,6 +70,8 @@ static NTSTATUS registry_openkey(TALLOC_CTX *mem_ctx, NTSTATUS status; struct winreg_String key; + ZERO_STRUCT(key); + if (!reg_hive_key(name, &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } @@ -330,6 +332,8 @@ static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx, return werror_to_ntstatus(err); } + ZERO_STRUCT(name_string); + name_string.name = name; result = rpccli_winreg_SetValue(pipe_hnd, blob.data, key_hnd, name_string, value->type, @@ -417,6 +421,8 @@ static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid, NTSTATUS status; struct winreg_String valuename; + ZERO_STRUCT(valuename); + status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_WRITE, &hive_hnd, &key_hnd); if (!NT_STATUS_IS_OK(status)) { @@ -467,6 +473,9 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, enum winreg_CreateAction action; NTSTATUS status; + ZERO_STRUCT(key); + ZERO_STRUCT(keyclass); + if (!reg_hive_key(argv[0], &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } @@ -533,6 +542,8 @@ static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid, struct winreg_String key; NTSTATUS status; + ZERO_STRUCT(key); + if (!reg_hive_key(argv[0], &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } -- cgit From 46f199961fc91b00a19c4132f46c2cb2586e7a8a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 23 Aug 2007 15:33:25 +0000 Subject: r24637: In order for "net rpc registry" to be able to write to Samba's own registry, the access mask for opening the registry for the write operations needs to be SEC_RIGHTS_MAXIMUM_ALLOWED instead of REG_WRITE: we can not open e.g. HKLM read write explicitly, since we can not write to this virtual part of the registry, only to the subkeys like 'HKLM\Software\Samba\smbconf' that are stored on disk. Note that MAXIMUM_ALLOWED is also what windows' regedit passed to the open calls. Michael (This used to be commit 57c30f7319b35fa452e8a6c585810e55c7e934b2) --- source3/utils/net_rpc_registry.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 0d54ff3907..459e7f9f85 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -354,7 +354,8 @@ static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid, NTSTATUS status; struct registry_value value; - status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_WRITE, + status = registry_openkey(mem_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", @@ -423,7 +424,8 @@ static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid, ZERO_STRUCT(valuename); - status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_WRITE, + status = registry_openkey(mem_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", @@ -481,7 +483,7 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, } status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, - REG_KEY_READ|REG_KEY_WRITE, + SEC_RIGHTS_MAXIMUM_ALLOWED, &hive_hnd); if (!(NT_STATUS_IS_OK(status))) { return status; @@ -548,7 +550,8 @@ static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid, return NT_STATUS_INVALID_PARAMETER; } - status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, REG_KEY_WRITE, + status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, + SEC_RIGHTS_MAXIMUM_ALLOWED, &hive_hnd); if (!(NT_STATUS_IS_OK(status))) { return status; -- cgit From c32358d001ec1181a40a9f8dd0c7ef3770f3f020 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 25 Sep 2007 04:54:20 +0000 Subject: r25314: Add HKEY_CURRENT_USER to reg_hive_key(). Guenther (This used to be commit 693b3c26c0643028e861b78068c2bcda0add1105) --- source3/utils/net_rpc_registry.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 459e7f9f85..64aad1f4dd 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -48,6 +48,9 @@ static BOOL reg_hive_key(const char *fullname, uint32 *reg_type, else if (strnequal(fullname, "HKU", len) || strnequal(fullname, "HKEY_USERS", len)) (*reg_type) = HKEY_USERS; + else if (strnequal(fullname, "HKCU", len) || + strnequal(fullname, "HKEY_CURRENT_USER", len)) + (*reg_type) = HKEY_CURRENT_USER; else if (strnequal(fullname, "HKPD", len) || strnequal(fullname, "HKEY_PERFORMANCE_DATA", len)) (*reg_type) = HKEY_PERFORMANCE_DATA; -- cgit From 70001d310643d9e257e6ee1adbb114347ee01552 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 5 Oct 2007 20:07:18 +0000 Subject: r25525: Add "net rpc registry getsd " to display security descriptors. Guenther (This used to be commit 550ae11ad1243c4c2af68345349c96d38a5e1ef8) --- source3/utils/net_rpc_registry.c | 83 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 64aad1f4dd..b228cc1478 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -319,6 +319,17 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, return status; } +static NTSTATUS registry_getsd(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *pipe_hnd, + struct policy_handle *key_hnd, + uint32_t sec_info, + struct KeySecurityData *sd) +{ + return rpccli_winreg_GetKeySecurity(pipe_hnd, mem_ctx, key_hnd, + sec_info, sd); +} + + static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *pipe_hnd, struct policy_handle *key_hnd, @@ -965,6 +976,76 @@ out: /******************************************************************** ********************************************************************/ +static NTSTATUS rpc_registry_getsd_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) +{ + POLICY_HND pol_hive, pol_key; + NTSTATUS status; + struct KeySecurityData *sd = NULL; + uint32_t sec_info; + DATA_BLOB blob; + struct security_descriptor sec_desc; + + if (argc != 1) { + d_printf("Usage: net rpc registry getsd \n"); + d_printf("Example: net rpc registry getsd 'HKLM\\Software\\Samba'\n"); + return NT_STATUS_OK; + } + + 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 status; + } + + sd = TALLOC_ZERO_P(mem_ctx, struct KeySecurityData); + if (!sd) { + status = NT_STATUS_NO_MEMORY; + goto out; + } + + sd->size = 0x1000; + sec_info = SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL; + + status = registry_getsd(mem_ctx, pipe_hnd, &pol_key, sec_info, sd); + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "getting sd failed: %s\n", + nt_errstr(status)); + goto out; + } + + blob.data = sd->data; + blob.length = sd->size; + + ndr_pull_struct_blob(&blob, mem_ctx, &sec_desc, + (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); + + display_sec_desc(&sec_desc); + + out: + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); + + return status; +} + + +static int rpc_registry_getsd(int argc, const char **argv) +{ + return run_rpc_command(NULL, PI_WINREG, 0, + rpc_registry_getsd_internal, argc, argv ); +} + +/******************************************************************** +********************************************************************/ + int net_rpc_registry(int argc, const char **argv) { struct functable2 func[] = { @@ -984,6 +1065,8 @@ int net_rpc_registry(int argc, const char **argv) "Dump a registry file" }, { "copy", rpc_registry_copy, "Copy a registry file" }, + { "getsd", rpc_registry_getsd, + "Get security descriptor" }, {NULL, NULL, NULL} }; -- cgit From ffd91e763ec3da1b9dd8104b2a502dbdcdfd1875 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 5 Oct 2007 20:08:48 +0000 Subject: r25526: Fix usage output. Guenther (This used to be commit 31a0bf7b8cae3322a379dc147be6493441c2f13d) --- source3/utils/net_rpc_registry.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index b228cc1478..03a773225e 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -614,8 +614,8 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, struct registry_value **values = NULL; if (argc != 1 ) { - d_printf("Usage: net rpc enumerate [recurse]\n"); - d_printf("Example: net rpc enumerate 'HKLM\\Software\\Samba'\n"); + d_printf("Usage: net rpc registry enumerate [recurse]\n"); + d_printf("Example: net rpc registry enumerate 'HKLM\\Software\\Samba'\n"); return NT_STATUS_OK; } @@ -716,7 +716,7 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, struct winreg_String filename; if (argc != 2 ) { - d_printf("Usage: net rpc backup \n"); + d_printf("Usage: net rpc registry backup \n"); return NT_STATUS_OK; } @@ -882,7 +882,7 @@ static int rpc_registry_dump( int argc, const char **argv ) REGF_NK_REC *nk; if (argc != 1 ) { - d_printf("Usage: net rpc dump \n"); + d_printf("Usage: net rpc registry dump \n"); return 0; } @@ -926,7 +926,7 @@ static int rpc_registry_copy( int argc, const char **argv ) int result = 1; if (argc != 2 ) { - d_printf("Usage: net rpc copy \n"); + d_printf("Usage: net rpc registry copy \n"); return 0; } -- cgit From 5de28a07cc3195d13626a3bf4579a565dcf8b9d1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 9 Oct 2007 13:53:40 +0000 Subject: r25592: Allow to set sec_info for registry security descriptor queries. Guenther (This used to be commit 09e10d1d2936fd8c841de2a3323a1d0a1f6bd815) --- source3/utils/net_rpc_registry.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 03a773225e..c43b5334e8 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -991,8 +991,8 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, DATA_BLOB blob; struct security_descriptor sec_desc; - if (argc != 1) { - d_printf("Usage: net rpc registry getsd \n"); + if (argc <1 || argc > 2) { + d_printf("Usage: net rpc registry getsd \n"); d_printf("Example: net rpc registry getsd 'HKLM\\Software\\Samba'\n"); return NT_STATUS_OK; } @@ -1012,7 +1012,12 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, } sd->size = 0x1000; - sec_info = SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL; + + if (argc >= 2) { + sscanf(argv[1], "%x", &sec_info); + } else { + sec_info = SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL; + } status = registry_getsd(mem_ctx, pipe_hnd, &pol_key, sec_info, sd); if (!NT_STATUS_IS_OK(status)) { @@ -1024,14 +1029,17 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, blob.data = sd->data; blob.length = sd->size; - ndr_pull_struct_blob(&blob, mem_ctx, &sec_desc, - (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); + status = ndr_pull_struct_blob(&blob, mem_ctx, &sec_desc, + (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); + if (!NT_STATUS_IS_OK(status)) { + goto out; + } display_sec_desc(&sec_desc); out: - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive); return status; } @@ -1040,7 +1048,7 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, static int rpc_registry_getsd(int argc, const char **argv) { return run_rpc_command(NULL, PI_WINREG, 0, - rpc_registry_getsd_internal, argc, argv ); + rpc_registry_getsd_internal, argc, argv); } /******************************************************************** -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/utils/net_rpc_registry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index c43b5334e8..915ce5f9aa 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -22,7 +22,7 @@ #include "regfio.h" #include "reg_objects.h" -static BOOL reg_hive_key(const char *fullname, uint32 *reg_type, +static bool reg_hive_key(const char *fullname, uint32 *reg_type, const char **key_name) { const char *sep; @@ -802,7 +802,7 @@ static void dump_values( REGF_NK_REC *nk ) /******************************************************************** ********************************************************************/ -static BOOL dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *parent ) +static bool dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *parent ) { REGF_NK_REC *key; pstring regpath; @@ -823,7 +823,7 @@ static BOOL dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa /******************************************************************** ********************************************************************/ -static BOOL write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, +static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, REGF_NK_REC *parent, REGF_FILE *outfile, const char *parentpath ) { -- cgit From fc22f295d06f243c86acc6a9ef042417007677e5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 5 Nov 2007 02:33:58 +0100 Subject: Make sure we can read SACLs from the registry. Guenther (This used to be commit 62d4cce4562b77403f9353d333b9553352bdf1d8) --- source3/utils/net_rpc_registry.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 915ce5f9aa..e1d65fb06b 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -990,6 +990,9 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, uint32_t sec_info; DATA_BLOB blob; struct security_descriptor sec_desc; + uint32_t access_mask = REG_KEY_READ | + SEC_RIGHT_MAXIMUM_ALLOWED | + SEC_RIGHT_SYSTEM_SECURITY; if (argc <1 || argc > 2) { d_printf("Usage: net rpc registry getsd \n"); @@ -997,7 +1000,8 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, return NT_STATUS_OK; } - status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_READ, + status = registry_openkey(mem_ctx, pipe_hnd, argv[0], + access_mask, &pol_hive, &pol_key); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "registry_openkey failed: %s\n", -- cgit From f9578af966c1c1b5b5df4acac9977472d2896bea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 14:39:45 +0100 Subject: ndr: change NTSTAUS into enum ndr_err_code (samba3 callers) lib/messages_local.c rpc_client/ndr.c smbd/notify_internal.c utils/net_rpc_registry.c metze (This used to be commit c2645d2164c05976a98bafed980b6029baf89977) --- source3/utils/net_rpc_registry.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index e1d65fb06b..c2b9aced69 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -986,6 +986,7 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, { POLICY_HND pol_hive, pol_key; NTSTATUS status; + enum ndr_err_code ndr_err; struct KeySecurityData *sd = NULL; uint32_t sec_info; DATA_BLOB blob; @@ -1033,11 +1034,13 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, blob.data = sd->data; blob.length = sd->size; - status = ndr_pull_struct_blob(&blob, mem_ctx, &sec_desc, - (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &sec_desc, + (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); goto out; } + status = NT_STATUS_OK; display_sec_desc(&sec_desc); -- cgit From 82089a2e84ae818c483183a866e24b4e4522058a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 3 Dec 2007 18:21:40 +0100 Subject: Fix winreg callers. Guenther (This used to be commit 677d9e6d86997a1ae10266e9bab3b18c3fdd2890) --- source3/utils/net_rpc_registry.c | 57 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index c2b9aced69..a6d29946cd 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -86,9 +86,9 @@ static NTSTATUS registry_openkey(TALLOC_CTX *mem_ctx, } status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, hive_hnd, key, 0, - access_mask, key_hnd); + access_mask, key_hnd, NULL); if (!(NT_STATUS_IS_OK(status))) { - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, hive_hnd); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, hive_hnd, NULL); return status; } @@ -120,7 +120,7 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, status = rpccli_winreg_QueryInfoKey( pipe_hnd, mem_ctx, key_hnd, &classname, &num_subkeys, &max_subkeylen, &max_classlen, &num_values, &max_valnamelen, - &max_valbufsize, &secdescsize, &last_changed_time ); + &max_valbufsize, &secdescsize, &last_changed_time, NULL ); if (!NT_STATUS_IS_OK(status)) { goto error; @@ -145,6 +145,7 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, struct winreg_StringBuf class_buf; struct winreg_StringBuf name_buf; NTTIME modtime; + WERROR werr; c = '\0'; class_buf.name = &c; @@ -158,9 +159,9 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, key_hnd, i, &name_buf, &class_buf, - &modtime); + &modtime, &werr); - if (W_ERROR_EQUAL(ntstatus_to_werror(status), + if (W_ERROR_EQUAL(werr, WERR_NO_MORE_ITEMS) ) { status = NT_STATUS_OK; break; @@ -233,7 +234,7 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, status = rpccli_winreg_QueryInfoKey( pipe_hnd, mem_ctx, key_hnd, &classname, &num_subkeys, &max_subkeylen, &max_classlen, &num_values, &max_valnamelen, - &max_valbufsize, &secdescsize, &last_changed_time ); + &max_valbufsize, &secdescsize, &last_changed_time, NULL ); if (!NT_STATUS_IS_OK(status)) { goto error; @@ -273,9 +274,9 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, status = rpccli_winreg_EnumValue(pipe_hnd, mem_ctx, key_hnd, i, &name_buf, &type, data, &data_size, - &value_length ); + &value_length, &err); - if ( W_ERROR_EQUAL(ntstatus_to_werror(status), + if ( W_ERROR_EQUAL(err, WERR_NO_MORE_ITEMS) ) { status = NT_STATUS_OK; break; @@ -326,7 +327,7 @@ static NTSTATUS registry_getsd(TALLOC_CTX *mem_ctx, struct KeySecurityData *sd) { return rpccli_winreg_GetKeySecurity(pipe_hnd, mem_ctx, key_hnd, - sec_info, sd); + sec_info, sd, NULL); } @@ -351,7 +352,7 @@ static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx, name_string.name = name; result = rpccli_winreg_SetValue(pipe_hnd, blob.data, key_hnd, name_string, value->type, - blob.data, blob.length); + blob.data, blob.length, NULL); TALLOC_FREE(blob.data); return result; } @@ -406,8 +407,8 @@ static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid, } error: - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd, NULL); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd, NULL); return NT_STATUS_OK; } @@ -450,15 +451,15 @@ static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid, valuename.name = argv[1]; status = rpccli_winreg_DeleteValue(pipe_hnd, mem_ctx, &key_hnd, - valuename); + valuename, NULL); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "registry_deletevalue failed: %s\n", nt_errstr(status)); } - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd, NULL); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd, NULL); return NT_STATUS_OK; } @@ -508,11 +509,11 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, status = rpccli_winreg_CreateKey(pipe_hnd, mem_ctx, &hive_hnd, key, keyclass, 0, REG_KEY_READ, NULL, - &key_hnd, &action); + &key_hnd, &action, NULL); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "createkey returned %s\n", nt_errstr(status)); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd, NULL); return status; } @@ -528,8 +529,8 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, break; } - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd, NULL); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd, NULL); return status; } @@ -571,8 +572,8 @@ static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid, return status; } - status = rpccli_winreg_DeleteKey(pipe_hnd, mem_ctx, &hive_hnd, key); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd); + status = rpccli_winreg_DeleteKey(pipe_hnd, mem_ctx, &hive_hnd, key, NULL); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd, NULL); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "deletekey returned %s\n", @@ -684,8 +685,8 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, d_printf("\n"); } - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key, NULL); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive, NULL); return status; } @@ -729,15 +730,15 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, } filename.name = argv[1]; - status = rpccli_winreg_SaveKey( pipe_hnd, mem_ctx, &pol_key, &filename, NULL ); + status = rpccli_winreg_SaveKey( pipe_hnd, mem_ctx, &pol_key, &filename, NULL, NULL); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); } /* cleanup */ - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key, NULL); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive, NULL); return status; } @@ -1045,8 +1046,8 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, display_sec_desc(&sec_desc); out: - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key); - rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key, NULL); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive, NULL); return status; } -- cgit From 5ea101f048483899d4a0a36c7eb6e768e408feec Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 4 Dec 2007 15:21:14 -0800 Subject: Allow STR_TERMINATE and -1 src_len for pull_ucs2_base_talloc(). Jeremy. (This used to be commit 063358d87ac9a1d948c8d4b6358e926dd14bb3ac) --- source3/utils/net_rpc_registry.c | 47 ++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index a6d29946cd..2d335942a2 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -759,7 +759,7 @@ static int rpc_registry_save( int argc, const char **argv ) static void dump_values( REGF_NK_REC *nk ) { int i, j; - pstring data_str; + char *data_str = NULL; uint32 data_size, data; if ( !nk->values ) @@ -772,7 +772,14 @@ static void dump_values( REGF_NK_REC *nk ) data_size = nk->values[i].data_size & ~VK_DATA_IN_OFFSET; switch ( nk->values[i].type ) { case REG_SZ: - rpcstr_pull( data_str, nk->values[i].data, sizeof(data_str), -1, STR_TERMINATE ); + rpcstr_pull_talloc(talloc_tos(), + &data_str, + nk->values[i].data, + -1, + STR_TERMINATE); + if (!data_str) { + break; + } d_printf( "%s", data_str ); break; case REG_MULTI_SZ: @@ -806,16 +813,19 @@ static void dump_values( REGF_NK_REC *nk ) static bool dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *parent ) { REGF_NK_REC *key; - pstring regpath; /* depth first dump of the registry tree */ while ( (key = regfio_fetch_subkey( file, nk )) ) { - pstr_sprintf( regpath, "%s\\%s", parent, key->keyname ); + char *regpath; + if (asprintf(®path, "%s\\%s", parent, key->keyname) < 0) { + break; + } d_printf("[%s]\n", regpath ); dump_values( key ); d_printf("\n"); dump_registry_tree( file, key, regpath ); + SAFE_FREE(regpath); } return True; @@ -829,10 +839,10 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, const char *parentpath ) { REGF_NK_REC *key, *subkey; - REGVAL_CTR *values; - REGSUBKEY_CTR *subkeys; + REGVAL_CTR *values = NULL; + REGSUBKEY_CTR *subkeys = NULL; int i; - pstring path; + char *path = NULL; if ( !( subkeys = TALLOC_ZERO_P( infile->mem_ctx, REGSUBKEY_CTR )) ) { DEBUG(0,("write_registry_tree: talloc() failed!\n")); @@ -841,36 +851,45 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) { DEBUG(0,("write_registry_tree: talloc() failed!\n")); + TALLOC_FREE(subkeys); return False; } /* copy values into the REGVAL_CTR */ - + for ( i=0; inum_values; i++ ) { regval_ctr_addvalue( values, nk->values[i].valuename, nk->values[i].type, (const char *)nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) ); } /* copy subkeys into the REGSUBKEY_CTR */ - + while ( (subkey = regfio_fetch_subkey( infile, nk )) ) { regsubkey_ctr_addkey( subkeys, subkey->keyname ); } - + key = regfio_write_key( outfile, nk->keyname, values, subkeys, nk->sec_desc->sec_desc, parent ); /* write each one of the subkeys out */ - pstr_sprintf( path, "%s%s%s", parentpath, parent ? "\\" : "", nk->keyname ); + path = talloc_asprintf(subkeys, + "%s%s%s", + parentpath, + parent ? "\\" : "", + nk->keyname); + if (!path) { + TALLOC_FREE(subkeys); + return false; + } + nk->subkey_index = 0; while ( (subkey = regfio_fetch_subkey( infile, nk )) ) { write_registry_tree( infile, subkey, key, outfile, path ); } - TALLOC_FREE( subkeys ); - d_printf("[%s]\n", path ); - + TALLOC_FREE(subkeys); + return True; } -- cgit From 2ce236cbaf605a6be05c6d0ffee2ba588f128a7e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 4 Apr 2008 13:26:03 +0200 Subject: net_rpc_registy: use function print_registry_key Michael (This used to be commit cc1da3ee2c369181efa6d150c966571d0aff0728) --- source3/utils/net_rpc_registry.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 2d335942a2..7643a7920b 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -19,6 +19,7 @@ #include "includes.h" #include "utils/net.h" +#include "utils/net_registry_util.h" #include "regfio.h" #include "reg_objects.h" @@ -637,11 +638,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, } for (i=0; i Date: Fri, 4 Apr 2008 13:30:49 +0200 Subject: net_rpc_registry: use utility function print_registry_value(). Michael (This used to be commit 3d039b518f04b9dd3c87b9af2ec816e049554e27) --- source3/utils/net_rpc_registry.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 7643a7920b..89cb265550 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -650,36 +650,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, } for (i=0; itype)); - switch(v->type) { - case REG_DWORD: - d_printf("Value = %d\n", v->v.dword); - break; - case REG_SZ: - case REG_EXPAND_SZ: - d_printf("Value = \"%s\"\n", v->v.sz.str); - break; - case REG_MULTI_SZ: { - uint32 j; - for (j = 0; j < v->v.multi_sz.num_strings; j++) { - d_printf("Value[%3.3d] = \"%s\"\n", j, - v->v.multi_sz.strings[j]); - } - break; - } - case REG_BINARY: - d_printf("Value = %d bytes\n", - (int)v->v.binary.length); - break; - default: - d_printf("Value = \n"); - break; - } - - d_printf("\n"); + print_registry_value(names[i], values[i]); } rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key, NULL); -- cgit From 65088387c061aebd8a847857a5fc87ca7a9257f3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 4 Apr 2008 16:46:01 +0200 Subject: net_rpc_registry: use split_hive_key to normalize hive befor open. THis allows to specify keys in the form "HKLM/Software/samba", i.e. "/" instead of "\\". Michael (This used to be commit 61d09caef340d2fee303e429f6f25d011cb3023c) --- source3/utils/net_rpc_registry.c | 67 +++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 28 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 89cb265550..0d1f068862 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -23,45 +23,56 @@ #include "regfio.h" #include "reg_objects.h" -static bool reg_hive_key(const char *fullname, uint32 *reg_type, - const char **key_name) +static bool reg_hive_key(TALLOC_CTX *ctx, const char *fullname, + uint32 *reg_type, const char **key_name) { - const char *sep; - ptrdiff_t len; + WERROR werr; + char *hivename = NULL; + const char *tmp_keyname = NULL; + bool ret = false; + TALLOC_CTX *tmp_ctx = talloc_stackframe(); - sep = strchr_m(fullname, '\\'); - - if (sep != NULL) { - len = sep - fullname; - *key_name = sep+1; + werr = split_hive_key(tmp_ctx, fullname, &hivename, &tmp_keyname); + if (!W_ERROR_IS_OK(werr)) { + goto done; } - else { - len = strlen(fullname); - *key_name = ""; + + *key_name = talloc_strdup(ctx, tmp_keyname); + if (*key_name == NULL) { + goto done; } - if (strnequal(fullname, "HKLM", len) || - strnequal(fullname, "HKEY_LOCAL_MACHINE", len)) + if (strequal(hivename, "HKLM") || + strequal(hivename, "HKEY_LOCAL_MACHINE")) + { (*reg_type) = HKEY_LOCAL_MACHINE; - else if (strnequal(fullname, "HKCR", len) || - strnequal(fullname, "HKEY_CLASSES_ROOT", len)) + } else if (strequal(hivename, "HKCR") || + strequal(hivename, "HKEY_CLASSES_ROOT")) + { (*reg_type) = HKEY_CLASSES_ROOT; - else if (strnequal(fullname, "HKU", len) || - strnequal(fullname, "HKEY_USERS", len)) + } else if (strequal(hivename, "HKU") || + strequal(hivename, "HKEY_USERS")) + { (*reg_type) = HKEY_USERS; - else if (strnequal(fullname, "HKCU", len) || - strnequal(fullname, "HKEY_CURRENT_USER", len)) + } else if (strequal(hivename, "HKCU") || + strequal(hivename, "HKEY_CURRENT_USER")) + { (*reg_type) = HKEY_CURRENT_USER; - else if (strnequal(fullname, "HKPD", len) || - strnequal(fullname, "HKEY_PERFORMANCE_DATA", len)) + } else if (strequal(hivename, "HKPD") || + strequal(hivename, "HKEY_PERFORMANCE_DATA")) + { (*reg_type) = HKEY_PERFORMANCE_DATA; - else { + } else { DEBUG(10,("reg_hive_key: unrecognised hive key %s\n", fullname)); - return False; + goto done; } - return True; + ret = true; + +done: + TALLOC_FREE(tmp_ctx); + return ret; } static NTSTATUS registry_openkey(TALLOC_CTX *mem_ctx, @@ -76,7 +87,7 @@ static NTSTATUS registry_openkey(TALLOC_CTX *mem_ctx, ZERO_STRUCT(key); - if (!reg_hive_key(name, &hive, &key.name)) { + if (!reg_hive_key(mem_ctx, name, &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } @@ -494,7 +505,7 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, ZERO_STRUCT(key); ZERO_STRUCT(keyclass); - if (!reg_hive_key(argv[0], &hive, &key.name)) { + if (!reg_hive_key(mem_ctx, argv[0], &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } @@ -562,7 +573,7 @@ static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid, ZERO_STRUCT(key); - if (!reg_hive_key(argv[0], &hive, &key.name)) { + if (!reg_hive_key(mem_ctx, argv[0], &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } -- cgit From ae790f9b89779a0fa1ba4ecfb5b99df160d222fd Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 4 Apr 2008 17:24:53 +0200 Subject: net: change split_hive_key() to properly allocate subkeyname instead of returning a pointer into another string. Michael (This used to be commit 68d08ecf92be3444b759300237b2b7cf5238d022) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 0d1f068862..92aaf06411 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -28,7 +28,7 @@ static bool reg_hive_key(TALLOC_CTX *ctx, const char *fullname, { WERROR werr; char *hivename = NULL; - const char *tmp_keyname = NULL; + char *tmp_keyname = NULL; bool ret = false; TALLOC_CTX *tmp_ctx = talloc_stackframe(); -- cgit From c7aa3dd3c052dd62e8dc9abdd033a8653ae27fbc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 4 Apr 2008 17:50:41 +0200 Subject: net_rpc_registry: consistently return error upon wrong use. Michael (This used to be commit 26e3d71cd0b2d1bb31c50627ea71267328d52448) --- source3/utils/net_rpc_registry.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 92aaf06411..55585ec62b 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -629,7 +629,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, if (argc != 1 ) { d_printf("Usage: net rpc registry enumerate [recurse]\n"); d_printf("Example: net rpc registry enumerate 'HKLM\\Software\\Samba'\n"); - return NT_STATUS_OK; + return NT_STATUS_INVALID_PARAMETER; } status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_READ, @@ -697,7 +697,7 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, if (argc != 2 ) { d_printf("Usage: net rpc registry backup \n"); - return NT_STATUS_OK; + return NT_STATUS_INVALID_PARAMETER; } status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_ALL, @@ -882,7 +882,7 @@ static int rpc_registry_dump( int argc, const char **argv ) if (argc != 1 ) { d_printf("Usage: net rpc registry dump \n"); - return 0; + return -1; } d_printf("Opening %s....", argv[0]); @@ -926,7 +926,7 @@ static int rpc_registry_copy( int argc, const char **argv ) if (argc != 2 ) { d_printf("Usage: net rpc registry copy \n"); - return 0; + return -1; } d_printf("Opening %s....", argv[0]); @@ -997,7 +997,7 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, if (argc <1 || argc > 2) { d_printf("Usage: net rpc registry getsd \n"); d_printf("Example: net rpc registry getsd 'HKLM\\Software\\Samba'\n"); - return NT_STATUS_OK; + return NT_STATUS_INVALID_PARAMETER; } status = registry_openkey(mem_ctx, pipe_hnd, argv[0], -- cgit From 0000eeb9b859ef3f9dcc6b659d27c897048c63f6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 4 Apr 2008 17:52:35 +0200 Subject: net_rpc_registry: return available error code on failure in deletevalue. Michael (This used to be commit 0dc9840cefb08b2732d294eb45508ce687ded324) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 55585ec62b..da078f4d36 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -473,7 +473,7 @@ static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid, rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd, NULL); rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd, NULL); - return NT_STATUS_OK; + return status; } static int rpc_registry_deletevalue( int argc, const char **argv ) -- cgit From d3dcaac176212a20c2bb71a08b4ac39ea2689047 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 9 Apr 2008 12:29:34 +0200 Subject: 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 (This used to be commit 88c4851ad7240bc4f72a5ef92e21629e6a4c99c6) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index da078f4d36..564d79e9f9 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -661,7 +661,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, } for (i=0; i Date: Wed, 9 Apr 2008 14:30:18 +0200 Subject: net rpc registry: add getvalue command. This is the same as already implemented for "net registry". usage: net rpc registry getvalue Michael (This used to be commit ba59383437aed9058a58bdeedcf61a0076a94924) --- source3/utils/net_rpc_registry.c | 100 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 564d79e9f9..42370089e5 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/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 " + "\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, @@ -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, -- cgit From 44c689289c3ac29f329a9d9f0ec58e0416e62c4d Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 9 May 2008 22:50:04 +0200 Subject: net: Fix usage string. (This used to be commit e3470e9a1b19c239d6fa576f8c8c1a5a5c3b5d3c) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 42370089e5..022f2ddfcd 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -725,7 +725,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, struct registry_value **values = NULL; if (argc != 1 ) { - d_printf("Usage: net rpc registry enumerate [recurse]\n"); + d_printf("Usage: net rpc registry enumerate \n"); d_printf("Example: net rpc registry enumerate 'HKLM\\Software\\Samba'\n"); return NT_STATUS_INVALID_PARAMETER; } -- cgit From f5769109447d8da0f09b102d444a816ad97a00dc Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 9 May 2008 23:22:12 +0200 Subject: net: Remove globals (This used to be commit 1e9319cf88b65a2a8d4f5099a1fe5297e405ed2e) --- source3/utils/net_rpc_registry.c | 69 ++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 28 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 022f2ddfcd..0dc53c3f6b 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -369,7 +369,8 @@ static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx, return result; } -static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_registry_setvalue_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -425,7 +426,8 @@ static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid, return NT_STATUS_OK; } -static int rpc_registry_setvalue( int argc, const char **argv ) +static int rpc_registry_setvalue(struct net_context *c, int argc, + const char **argv ) { if (argc < 4) { d_fprintf(stderr, "usage: net rpc registry setvalue " @@ -433,11 +435,12 @@ static int rpc_registry_setvalue( int argc, const char **argv ) return -1; } - return run_rpc_command( NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, PI_WINREG, 0, rpc_registry_setvalue_internal, argc, argv ); } -static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_registry_deletevalue_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -476,7 +479,8 @@ static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid, return status; } -static int rpc_registry_deletevalue( int argc, const char **argv ) +static int rpc_registry_deletevalue(struct net_context *c, int argc, + const char **argv ) { if (argc != 2) { d_fprintf(stderr, "usage: net rpc registry deletevalue " @@ -484,11 +488,12 @@ static int rpc_registry_deletevalue( int argc, const char **argv ) return -1; } - return run_rpc_command( NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, PI_WINREG, 0, rpc_registry_deletevalue_internal, argc, argv ); } -static NTSTATUS rpc_registry_getvalue_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_registry_getvalue_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -574,7 +579,8 @@ done: return status; } -static int rpc_registry_getvalue(int argc, const char **argv) +static int rpc_registry_getvalue(struct net_context *c, int argc, + const char **argv) { if (argc != 2) { d_fprintf(stderr, "usage: net rpc registry deletevalue " @@ -582,11 +588,12 @@ static int rpc_registry_getvalue(int argc, const char **argv) return -1; } - return run_rpc_command(NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, PI_WINREG, 0, rpc_registry_getvalue_internal, argc, argv); } -static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_registry_createkey_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -645,18 +652,20 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, return status; } -static int rpc_registry_createkey( int argc, const char **argv ) +static int rpc_registry_createkey(struct net_context *c, int argc, + const char **argv ) { if (argc != 1) { d_fprintf(stderr, "usage: net rpc registry createkey \n"); return -1; } - return run_rpc_command( NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, PI_WINREG, 0, rpc_registry_createkey_internal, argc, argv ); } -static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_registry_deletekey_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -693,21 +702,22 @@ static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid, return status; } -static int rpc_registry_deletekey( int argc, const char **argv ) +static int rpc_registry_deletekey(struct net_context *c, int argc, const char **argv ) { if (argc != 1) { d_fprintf(stderr, "usage: net rpc registry deletekey \n"); return -1; } - return run_rpc_command( NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, PI_WINREG, 0, rpc_registry_deletekey_internal, argc, argv ); } /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_registry_enumerate_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -771,16 +781,18 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, /******************************************************************** ********************************************************************/ -static int rpc_registry_enumerate( int argc, const char **argv ) +static int rpc_registry_enumerate(struct net_context *c, int argc, + const char **argv ) { - return run_rpc_command( NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, PI_WINREG, 0, rpc_registry_enumerate_internal, argc, argv ); } /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_registry_save_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -823,9 +835,9 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, /******************************************************************** ********************************************************************/ -static int rpc_registry_save( int argc, const char **argv ) +static int rpc_registry_save(struct net_context *c, int argc, const char **argv ) { - return run_rpc_command( NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, PI_WINREG, 0, rpc_registry_save_internal, argc, argv ); } @@ -973,7 +985,7 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, /******************************************************************** ********************************************************************/ -static int rpc_registry_dump( int argc, const char **argv ) +static int rpc_registry_dump(struct net_context *c, int argc, const char **argv) { REGF_FILE *registry; REGF_NK_REC *nk; @@ -1016,7 +1028,7 @@ static int rpc_registry_dump( int argc, const char **argv ) /******************************************************************** ********************************************************************/ -static int rpc_registry_copy( int argc, const char **argv ) +static int rpc_registry_copy(struct net_context *c, int argc, const char **argv ) { REGF_FILE *infile = NULL, *outfile = NULL; REGF_NK_REC *nk; @@ -1073,7 +1085,8 @@ out: /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_registry_getsd_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -1149,16 +1162,16 @@ static NTSTATUS rpc_registry_getsd_internal(const DOM_SID *domain_sid, } -static int rpc_registry_getsd(int argc, const char **argv) +static int rpc_registry_getsd(struct net_context *c, int argc, const char **argv) { - return run_rpc_command(NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, PI_WINREG, 0, rpc_registry_getsd_internal, argc, argv); } /******************************************************************** ********************************************************************/ -int net_rpc_registry(int argc, const char **argv) +int net_rpc_registry(struct net_context *c, int argc, const char **argv) { struct functable2 func[] = { { "enumerate", rpc_registry_enumerate, @@ -1184,5 +1197,5 @@ int net_rpc_registry(int argc, const char **argv) {NULL, NULL, NULL} }; - return net_run_function2(argc, argv, "net rpc registry", func); + return net_run_function2(c, argc, argv, "net rpc registry", func); } -- cgit From 4206d9754486d2c1e18217cbcdbaad8f31f5244b Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Thu, 8 May 2008 11:23:38 +0200 Subject: net: more whitespace cleanup (This used to be commit ef0184d580500734fc7af51e1c790b075180a3d0) --- source3/utils/net_rpc_registry.c | 66 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 0dc53c3f6b..5da19934dc 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -47,7 +47,7 @@ static bool reg_hive_key(TALLOC_CTX *ctx, const char *fullname, { (*reg_type) = HKEY_LOCAL_MACHINE; } else if (strequal(hivename, "HKCR") || - strequal(hivename, "HKEY_CLASSES_ROOT")) + strequal(hivename, "HKEY_CLASSES_ROOT")) { (*reg_type) = HKEY_CLASSES_ROOT; } else if (strequal(hivename, "HKU") || @@ -172,7 +172,7 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, key_hnd, i, &name_buf, &class_buf, &modtime, &werr); - + if (W_ERROR_EQUAL(werr, WERR_NO_MORE_ITEMS) ) { status = NT_STATUS_OK; @@ -371,10 +371,10 @@ static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx, static NTSTATUS rpc_registry_setvalue_internal(struct net_context *c, const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { @@ -382,7 +382,7 @@ static NTSTATUS rpc_registry_setvalue_internal(struct net_context *c, NTSTATUS status; struct registry_value value; - status = registry_openkey(mem_ctx, pipe_hnd, argv[0], + status = registry_openkey(mem_ctx, pipe_hnd, argv[0], SEC_RIGHTS_MAXIMUM_ALLOWED, &hive_hnd, &key_hnd); if (!NT_STATUS_IS_OK(status)) { @@ -441,10 +441,10 @@ static int rpc_registry_setvalue(struct net_context *c, int argc, static NTSTATUS rpc_registry_deletevalue_internal(struct net_context *c, const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { @@ -594,10 +594,10 @@ static int rpc_registry_getvalue(struct net_context *c, int argc, static NTSTATUS rpc_registry_createkey_internal(struct net_context *c, const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { @@ -666,10 +666,10 @@ static int rpc_registry_createkey(struct net_context *c, int argc, static NTSTATUS rpc_registry_deletekey_internal(struct net_context *c, const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { @@ -718,14 +718,14 @@ static int rpc_registry_deletekey(struct net_context *c, int argc, const char ** static NTSTATUS rpc_registry_enumerate_internal(struct net_context *c, const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { - POLICY_HND pol_hive, pol_key; + POLICY_HND pol_hive, pol_key; NTSTATUS status; uint32 num_subkeys = 0; uint32 num_values = 0; @@ -733,7 +733,7 @@ static NTSTATUS rpc_registry_enumerate_internal(struct net_context *c, NTTIME **modtimes = NULL; uint32 i; struct registry_value **values = NULL; - + if (argc != 1 ) { d_printf("Usage: net rpc registry enumerate \n"); d_printf("Example: net rpc registry enumerate 'HKLM\\Software\\Samba'\n"); @@ -793,23 +793,23 @@ static int rpc_registry_enumerate(struct net_context *c, int argc, static NTSTATUS rpc_registry_save_internal(struct net_context *c, const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { WERROR result = WERR_GENERAL_FAILURE; - POLICY_HND pol_hive, pol_key; + POLICY_HND pol_hive, pol_key; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; struct winreg_String filename; - + if (argc != 2 ) { d_printf("Usage: net rpc registry backup \n"); return NT_STATUS_INVALID_PARAMETER; } - + status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_ALL, &pol_hive, &pol_key); if (!NT_STATUS_IS_OK(status)) { @@ -823,9 +823,9 @@ static NTSTATUS rpc_registry_save_internal(struct net_context *c, if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); } - + /* cleanup */ - + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key, NULL); rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive, NULL); @@ -923,7 +923,7 @@ static bool dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa /******************************************************************** ********************************************************************/ -static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, +static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, REGF_NK_REC *parent, REGF_FILE *outfile, const char *parentpath ) { @@ -989,21 +989,21 @@ static int rpc_registry_dump(struct net_context *c, int argc, const char **argv) { REGF_FILE *registry; REGF_NK_REC *nk; - + if (argc != 1 ) { d_printf("Usage: net rpc registry dump \n"); return -1; } - + d_printf("Opening %s....", argv[0]); if ( !(registry = regfio_open( argv[0], O_RDONLY, 0)) ) { d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]); return 1; } d_printf("ok\n"); - + /* get the root of the registry file */ - + if ((nk = regfio_rootkey( registry )) == NULL) { d_fprintf(stderr, "Could not get rootkey\n"); regfio_close( registry ); @@ -1017,7 +1017,7 @@ static int rpc_registry_dump(struct net_context *c, int argc, const char **argv) #if 0 talloc_report_full( registry->mem_ctx, stderr ); -#endif +#endif d_printf("Closing registry..."); regfio_close( registry ); d_printf("ok\n"); @@ -1033,12 +1033,12 @@ static int rpc_registry_copy(struct net_context *c, int argc, const char **argv REGF_FILE *infile = NULL, *outfile = NULL; REGF_NK_REC *nk; int result = 1; - + if (argc != 2 ) { d_printf("Usage: net rpc registry copy \n"); return -1; } - + d_printf("Opening %s....", argv[0]); if ( !(infile = regfio_open( argv[0], O_RDONLY, 0 )) ) { d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]); @@ -1052,9 +1052,9 @@ static int rpc_registry_copy(struct net_context *c, int argc, const char **argv goto out; } d_printf("ok\n"); - + /* get the root of the registry file */ - + if ((nk = regfio_rootkey( infile )) == NULL) { d_fprintf(stderr, "Could not get rootkey\n"); goto out; @@ -1196,6 +1196,6 @@ int net_rpc_registry(struct net_context *c, int argc, const char **argv) "Get security descriptor" }, {NULL, NULL, NULL} }; - + return net_run_function2(c, argc, argv, "net rpc registry", func); } -- cgit From 49835c6d9e5b838484e6e806b80d8acb7ef2ef5a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 15 May 2008 12:55:54 +0200 Subject: net_registry: add raw output of value to print_registry_value(). Michael (This used to be commit 340a706422cbca45cc63fa94d36c88f6751f4f31) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 5da19934dc..8832ad96f3 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -568,7 +568,7 @@ static NTSTATUS rpc_registry_getvalue_internal(struct net_context *c, goto done; } - print_registry_value(value); + print_registry_value(value, false); done: rpccli_winreg_CloseKey(pipe_hnd, tmp_ctx, &key_hnd, NULL); -- cgit From 9b920fa1f76c0bfde9dce5ade5b80882095f1705 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 15 May 2008 14:38:01 +0200 Subject: net rpc registry: fix usage message of getvalue. Michael (This used to be commit 5dedde7a5b01d47947a8ff49a57e729fe5bfc817) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 8832ad96f3..fa16a96009 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -583,7 +583,7 @@ static int rpc_registry_getvalue(struct net_context *c, int argc, const char **argv) { if (argc != 2) { - d_fprintf(stderr, "usage: net rpc registry deletevalue " + d_fprintf(stderr, "usage: net rpc registry getvalue " "\n"); return -1; } -- cgit From 301196f847cf51c3d94f176ab57abb95be0cad35 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 15 May 2008 16:07:06 +0200 Subject: net rpc registry: abstract add boolean "raw" to rpc_registry_getvalue_internal() and wrap it into new rpc_registry_getvalue_full() for the getvalue subcommand. Michael (This used to be commit 9ee5ddb96360987675963d629f98051bf34e3031) --- source3/utils/net_rpc_registry.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index fa16a96009..a453dc5d5c 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -498,6 +498,7 @@ static NTSTATUS rpc_registry_getvalue_internal(struct net_context *c, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, TALLOC_CTX *mem_ctx, + bool raw, int argc, const char **argv) { @@ -579,6 +580,20 @@ done: return status; } +static NTSTATUS rpc_registry_getvalue_raw(struct net_context *c, + 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) +{ + return rpc_registry_getvalue_internal(c, domain_sid, domain_name, + cli, pipe_hnd, mem_ctx, false, + argc, argv); +} + static int rpc_registry_getvalue(struct net_context *c, int argc, const char **argv) { @@ -589,7 +604,7 @@ static int rpc_registry_getvalue(struct net_context *c, int argc, } return run_rpc_command(c, NULL, PI_WINREG, 0, - rpc_registry_getvalue_internal, argc, argv); + rpc_registry_getvalue_raw, argc, argv); } static NTSTATUS rpc_registry_createkey_internal(struct net_context *c, -- cgit From abafce6ba7defe59b2526855551264493b50f1db Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 15 May 2008 16:49:25 +0200 Subject: net rpc registry: add a getvalueraw subcommand. Michael (This used to be commit 5b5b29302b53c31256dfa2fdefead458cb14c560) --- source3/utils/net_rpc_registry.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index a453dc5d5c..a23caf5773 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -580,6 +580,33 @@ done: return status; } +static NTSTATUS rpc_registry_getvalue_full(struct net_context *c, + 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) +{ + return rpc_registry_getvalue_internal(c, domain_sid, domain_name, + cli, pipe_hnd, mem_ctx, false, + argc, argv); +} + +static int rpc_registry_getvalue(struct net_context *c, int argc, + const char **argv) +{ + if (argc != 2) { + d_fprintf(stderr, "usage: net rpc registry getvalue " + "\n"); + return -1; + } + + return run_rpc_command(c, NULL, PI_WINREG, 0, + rpc_registry_getvalue_full, argc, argv); +} + static NTSTATUS rpc_registry_getvalue_raw(struct net_context *c, const DOM_SID *domain_sid, const char *domain_name, @@ -590,12 +617,12 @@ static NTSTATUS rpc_registry_getvalue_raw(struct net_context *c, const char **argv) { return rpc_registry_getvalue_internal(c, domain_sid, domain_name, - cli, pipe_hnd, mem_ctx, false, + cli, pipe_hnd, mem_ctx, true, argc, argv); } -static int rpc_registry_getvalue(struct net_context *c, int argc, - const char **argv) +static int rpc_registry_getvalueraw(struct net_context *c, int argc, + const char **argv) { if (argc != 2) { d_fprintf(stderr, "usage: net rpc registry getvalue " @@ -1197,6 +1224,8 @@ int net_rpc_registry(struct net_context *c, int argc, const char **argv) "Delete a registry key" }, { "getvalue", rpc_registry_getvalue, "Print a registry value" }, + { "getvalueraw", rpc_registry_getvalueraw, + "Print a registry value" }, { "setvalue", rpc_registry_setvalue, "Set a new registry value" }, { "deletevalue", rpc_registry_deletevalue, -- cgit From b1d6e885b1d37bf683ff0ba11ff81e4ea22e8c67 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 15 May 2008 18:06:23 +0200 Subject: net rpc registry: fix getvalueraw to really print raw... Michael (This used to be commit db933ae1a9877b3485506fc8f0ecae2f2bd8a41f) --- source3/utils/net_rpc_registry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index a23caf5773..bc46fbb52e 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -569,7 +569,7 @@ static NTSTATUS rpc_registry_getvalue_internal(struct net_context *c, goto done; } - print_registry_value(value, false); + print_registry_value(value, raw); done: rpccli_winreg_CloseKey(pipe_hnd, tmp_ctx, &key_hnd, NULL); -- cgit From 16938883e6fcae7601eb6343177aa2d56dd2136e Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 12 May 2008 11:53:23 +0200 Subject: net: Use true/false instead of True/False. (This used to be commit a8b567aac3b0e39cfe67fb97167b10312ca5e73a) --- source3/utils/net_rpc_registry.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index bc46fbb52e..accd731191 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -959,7 +959,7 @@ static bool dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa SAFE_FREE(regpath); } - return True; + return true; } /******************************************************************** @@ -977,13 +977,13 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, if ( !( subkeys = TALLOC_ZERO_P( infile->mem_ctx, REGSUBKEY_CTR )) ) { DEBUG(0,("write_registry_tree: talloc() failed!\n")); - return False; + return false; } if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) { DEBUG(0,("write_registry_tree: talloc() failed!\n")); TALLOC_FREE(subkeys); - return False; + return false; } /* copy values into the REGVAL_CTR */ @@ -1021,7 +1021,7 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, d_printf("[%s]\n", path ); TALLOC_FREE(subkeys); - return True; + return true; } /******************************************************************** -- cgit From 3d7a927ece3ffb39abed47ef438091e5b23f7efb Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sat, 7 Jun 2008 01:27:41 +0200 Subject: net: Make "net rpc registry" use functable3 (This used to be commit 08dd5f5311d97544d5cb3067f019260a9161ef81) --- source3/utils/net_rpc_registry.c | 138 +++++++++++++++++++++++++++++---------- 1 file changed, 102 insertions(+), 36 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index accd731191..0d7d46fb98 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -429,7 +429,7 @@ static NTSTATUS rpc_registry_setvalue_internal(struct net_context *c, static int rpc_registry_setvalue(struct net_context *c, int argc, const char **argv ) { - if (argc < 4) { + if (argc < 4 || c->display_usage) { d_fprintf(stderr, "usage: net rpc registry setvalue " " []+\n"); return -1; @@ -482,7 +482,7 @@ static NTSTATUS rpc_registry_deletevalue_internal(struct net_context *c, static int rpc_registry_deletevalue(struct net_context *c, int argc, const char **argv ) { - if (argc != 2) { + if (argc != 2 || c->display_usage) { d_fprintf(stderr, "usage: net rpc registry deletevalue " "\n"); return -1; @@ -597,7 +597,7 @@ static NTSTATUS rpc_registry_getvalue_full(struct net_context *c, static int rpc_registry_getvalue(struct net_context *c, int argc, const char **argv) { - if (argc != 2) { + if (argc != 2 || c->display_usage) { d_fprintf(stderr, "usage: net rpc registry getvalue " "\n"); return -1; @@ -624,7 +624,7 @@ static NTSTATUS rpc_registry_getvalue_raw(struct net_context *c, static int rpc_registry_getvalueraw(struct net_context *c, int argc, const char **argv) { - if (argc != 2) { + if (argc != 2 || c->display_usage) { d_fprintf(stderr, "usage: net rpc registry getvalue " "\n"); return -1; @@ -697,7 +697,7 @@ static NTSTATUS rpc_registry_createkey_internal(struct net_context *c, static int rpc_registry_createkey(struct net_context *c, int argc, const char **argv ) { - if (argc != 1) { + if (argc != 1 || c->display_usage) { d_fprintf(stderr, "usage: net rpc registry createkey \n"); return -1; } @@ -746,7 +746,7 @@ static NTSTATUS rpc_registry_deletekey_internal(struct net_context *c, static int rpc_registry_deletekey(struct net_context *c, int argc, const char **argv ) { - if (argc != 1) { + if (argc != 1 || c->display_usage) { d_fprintf(stderr, "usage: net rpc registry deletekey \n"); return -1; } @@ -776,7 +776,7 @@ static NTSTATUS rpc_registry_enumerate_internal(struct net_context *c, uint32 i; struct registry_value **values = NULL; - if (argc != 1 ) { + if (argc != 1 || c->display_usage) { d_printf("Usage: net rpc registry enumerate \n"); d_printf("Example: net rpc registry enumerate 'HKLM\\Software\\Samba'\n"); return NT_STATUS_INVALID_PARAMETER; @@ -847,7 +847,7 @@ static NTSTATUS rpc_registry_save_internal(struct net_context *c, NTSTATUS status = NT_STATUS_UNSUCCESSFUL; struct winreg_String filename; - if (argc != 2 ) { + if (argc != 2 || c->display_usage) { d_printf("Usage: net rpc registry backup \n"); return NT_STATUS_INVALID_PARAMETER; } @@ -1032,7 +1032,7 @@ static int rpc_registry_dump(struct net_context *c, int argc, const char **argv) REGF_FILE *registry; REGF_NK_REC *nk; - if (argc != 1 ) { + if (argc != 1 || c->display_usage) { d_printf("Usage: net rpc registry dump \n"); return -1; } @@ -1076,7 +1076,7 @@ static int rpc_registry_copy(struct net_context *c, int argc, const char **argv REGF_NK_REC *nk; int result = 1; - if (argc != 2 ) { + if (argc != 2 || c->display_usage) { d_printf("Usage: net rpc registry copy \n"); return -1; } @@ -1147,7 +1147,7 @@ static NTSTATUS rpc_registry_getsd_internal(struct net_context *c, SEC_RIGHT_MAXIMUM_ALLOWED | SEC_RIGHT_SYSTEM_SECURITY; - if (argc <1 || argc > 2) { + if (argc <1 || argc > 2 || c->display_usage) { d_printf("Usage: net rpc registry getsd \n"); d_printf("Example: net rpc registry getsd 'HKLM\\Software\\Samba'\n"); return NT_STATUS_INVALID_PARAMETER; @@ -1215,31 +1215,97 @@ static int rpc_registry_getsd(struct net_context *c, int argc, const char **argv int net_rpc_registry(struct net_context *c, int argc, const char **argv) { - struct functable2 func[] = { - { "enumerate", rpc_registry_enumerate, - "Enumerate registry keys and values" }, - { "createkey", rpc_registry_createkey, - "Create a new registry key" }, - { "deletekey", rpc_registry_deletekey, - "Delete a registry key" }, - { "getvalue", rpc_registry_getvalue, - "Print a registry value" }, - { "getvalueraw", rpc_registry_getvalueraw, - "Print a registry value" }, - { "setvalue", rpc_registry_setvalue, - "Set a new registry value" }, - { "deletevalue", rpc_registry_deletevalue, - "Delete a registry value" }, - { "save", rpc_registry_save, - "Save a registry file" }, - { "dump", rpc_registry_dump, - "Dump a registry file" }, - { "copy", rpc_registry_copy, - "Copy a registry file" }, - { "getsd", rpc_registry_getsd, - "Get security descriptor" }, - {NULL, NULL, NULL} + struct functable3 func[] = { + { + "enumerate", + rpc_registry_enumerate, + NET_TRANSPORT_RPC, + "Enumerate registry keys and values", + "net rpc registry enumerate\n" + " Enumerate registry keys and values" + }, + { + "createkey", + rpc_registry_createkey, + NET_TRANSPORT_RPC, + "Create a new registry key", + "net rpc registry createkey\n" + " Create a new registry key" + }, + { + "deletekey", + rpc_registry_deletekey, + NET_TRANSPORT_RPC, + "Delete a registry key", + "net rpc registry deletekey\n" + " Delete a registry key" + }, + { + "getvalue", + rpc_registry_getvalue, + NET_TRANSPORT_RPC, + "Print a registry value", + "net rpc registry getvalue\n" + " Print a registry value" + }, + { + "getvalueraw", + rpc_registry_getvalueraw, + NET_TRANSPORT_RPC, + "Print a registry value", + "net rpc registry getvalueraw\n" + " Print a registry value (raw version)" + }, + { + "setvalue", + rpc_registry_setvalue, + NET_TRANSPORT_RPC, + "Set a new registry value", + "net rpc registry setvalue\n" + " Set a new registry value" + }, + { + "deletevalue", + rpc_registry_deletevalue, + NET_TRANSPORT_RPC, + "Delete a registry value", + "net rpc registry deletevalue\n" + " Delete a registry value" + }, + { + "save", + rpc_registry_save, + NET_TRANSPORT_RPC, + "Save a registry file", + "net rpc registry save\n" + " Save a registry file" + }, + { + "dump", + rpc_registry_dump, + NET_TRANSPORT_RPC, + "Dump a registry file", + "net rpc registry dump\n" + " Dump a registry file" + }, + { + "copy", + rpc_registry_copy, + NET_TRANSPORT_RPC, + "Copy a registry file", + "net rpc registry copy\n" + " Copy a registry file" + }, + { + "getsd", + rpc_registry_getsd, + NET_TRANSPORT_RPC, + "Get security descriptor", + "net rpc registry getsd\n" + " Get security descriptior" + }, + {NULL, NULL, 0, NULL, NULL} }; - return net_run_function2(c, argc, argv, "net rpc registry", func); + return net_run_function3(c, argc, argv, "net rpc registry", func); } -- cgit From 255bdb26025a5025bc60637dd924f6ec71c49ee5 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sat, 7 Jun 2008 02:25:08 +0200 Subject: net: Rename functable3 to functable, get rid of old functables (This used to be commit bb7c5fc4ec77db4073d3beccf12af12910b6bd07) --- source3/utils/net_rpc_registry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 0d7d46fb98..ff620897e7 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -1215,7 +1215,7 @@ static int rpc_registry_getsd(struct net_context *c, int argc, const char **argv int net_rpc_registry(struct net_context *c, int argc, const char **argv) { - struct functable3 func[] = { + struct functable func[] = { { "enumerate", rpc_registry_enumerate, @@ -1307,5 +1307,5 @@ int net_rpc_registry(struct net_context *c, int argc, const char **argv) {NULL, NULL, 0, NULL, NULL} }; - return net_run_function3(c, argc, argv, "net rpc registry", func); + return net_run_function(c, argc, argv, "net rpc registry", func); } -- cgit From f23567fcb9d626c29603430a9cedd899e56ded32 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jul 2008 18:36:31 +0200 Subject: Refactoring: run_rpc_command uses ndr_syntax_id instead of pipe_idx (This used to be commit 850166ec0d17eb85a0c921dc3b966fac0677af4a) --- source3/utils/net_rpc_registry.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/utils/net_rpc_registry.c') diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index ff620897e7..124af00b57 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -435,7 +435,7 @@ static int rpc_registry_setvalue(struct net_context *c, int argc, return -1; } - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_setvalue_internal, argc, argv ); } @@ -488,7 +488,7 @@ static int rpc_registry_deletevalue(struct net_context *c, int argc, return -1; } - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_deletevalue_internal, argc, argv ); } @@ -603,7 +603,7 @@ static int rpc_registry_getvalue(struct net_context *c, int argc, return -1; } - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_getvalue_full, argc, argv); } @@ -630,7 +630,7 @@ static int rpc_registry_getvalueraw(struct net_context *c, int argc, return -1; } - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_getvalue_raw, argc, argv); } @@ -702,7 +702,7 @@ static int rpc_registry_createkey(struct net_context *c, int argc, return -1; } - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_createkey_internal, argc, argv ); } @@ -751,7 +751,7 @@ static int rpc_registry_deletekey(struct net_context *c, int argc, const char ** return -1; } - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_deletekey_internal, argc, argv ); } @@ -826,7 +826,7 @@ static NTSTATUS rpc_registry_enumerate_internal(struct net_context *c, static int rpc_registry_enumerate(struct net_context *c, int argc, const char **argv ) { - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_enumerate_internal, argc, argv ); } @@ -879,7 +879,7 @@ static NTSTATUS rpc_registry_save_internal(struct net_context *c, static int rpc_registry_save(struct net_context *c, int argc, const char **argv ) { - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_save_internal, argc, argv ); } @@ -1206,7 +1206,7 @@ static NTSTATUS rpc_registry_getsd_internal(struct net_context *c, static int rpc_registry_getsd(struct net_context *c, int argc, const char **argv) { - return run_rpc_command(c, NULL, PI_WINREG, 0, + return run_rpc_command(c, NULL, &ndr_table_winreg.syntax_id, 0, rpc_registry_getsd_internal, argc, argv); } -- cgit