2 Samba Unix/Linux SMB client library
3 Distributed SMB/CIFS Server Management Utility
5 Copyright (C) Gerald (Jerry) Carter 2005-2006
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 #include "utils/net.h"
24 #include "reg_objects.h"
26 static BOOL reg_hive_key(const char *fullname, uint32 *reg_type,
27 const char **key_name)
32 sep = strchr_m(fullname, '\\');
39 len = strlen(fullname);
43 if (strnequal(fullname, "HKLM", len) ||
44 strnequal(fullname, "HKEY_LOCAL_MACHINE", len))
45 (*reg_type) = HKEY_LOCAL_MACHINE;
46 else if (strnequal(fullname, "HKCR", len) ||
47 strnequal(fullname, "HKEY_CLASSES_ROOT", len))
48 (*reg_type) = HKEY_CLASSES_ROOT;
49 else if (strnequal(fullname, "HKU", len) ||
50 strnequal(fullname, "HKEY_USERS", len))
51 (*reg_type) = HKEY_USERS;
52 else if (strnequal(fullname, "HKPD", len) ||
53 strnequal(fullname, "HKEY_PERFORMANCE_DATA", len))
54 (*reg_type) = HKEY_PERFORMANCE_DATA;
56 DEBUG(10,("reg_hive_key: unrecognised hive key %s\n",
64 static NTSTATUS registry_openkey(TALLOC_CTX *mem_ctx,
65 struct rpc_pipe_client *pipe_hnd,
66 const char *name, uint32 access_mask,
67 struct policy_handle *hive_hnd,
68 struct policy_handle *key_hnd)
72 struct winreg_String key;
74 if (!reg_hive_key(name, &hive, &key.name)) {
75 return NT_STATUS_INVALID_PARAMETER;
78 status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, access_mask,
80 if (!(NT_STATUS_IS_OK(status))) {
84 status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, hive_hnd, key, 0,
85 access_mask, key_hnd);
86 if (!(NT_STATUS_IS_OK(status))) {
87 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, hive_hnd);
94 static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx,
95 struct rpc_pipe_client *pipe_hnd,
96 struct policy_handle *key_hnd,
97 uint32 *pnum_keys, char ***pnames,
98 char ***pclasses, NTTIME ***pmodtimes)
102 uint32 num_subkeys, max_subkeylen, max_classlen;
103 uint32 num_values, max_valnamelen, max_valbufsize;
105 NTTIME last_changed_time;
107 struct winreg_String classname;
108 char **names, **classes;
111 if (!(mem_ctx = talloc_new(ctx))) {
112 return NT_STATUS_NO_MEMORY;
115 ZERO_STRUCT(classname);
116 status = rpccli_winreg_QueryInfoKey(
117 pipe_hnd, mem_ctx, key_hnd, &classname, &num_subkeys,
118 &max_subkeylen, &max_classlen, &num_values, &max_valnamelen,
119 &max_valbufsize, &secdescsize, &last_changed_time );
121 if (!NT_STATUS_IS_OK(status)) {
125 if (num_subkeys == 0) {
127 TALLOC_FREE(mem_ctx);
131 if ((!(names = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_subkeys))) ||
132 (!(classes = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_subkeys))) ||
133 (!(modtimes = TALLOC_ZERO_ARRAY(mem_ctx, NTTIME *,
135 status = NT_STATUS_NO_MEMORY;
139 for (i=0; i<num_subkeys; i++) {
141 struct winreg_StringBuf class_buf;
142 struct winreg_StringBuf *pclass_buf = &class_buf;
143 struct winreg_StringBuf name_buf;
145 NTTIME *pmodtime = &modtime;
149 class_buf.size = max_classlen+2;
153 name_buf.size = max_subkeylen+2;
155 ZERO_STRUCT(modtime);
157 status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, key_hnd,
158 i, &name_buf, &pclass_buf,
161 if (W_ERROR_EQUAL(ntstatus_to_werror(status),
162 WERR_NO_MORE_ITEMS) ) {
163 status = NT_STATUS_OK;
166 if (!NT_STATUS_IS_OK(status)) {
172 if (pclass_buf && pclass_buf->name &&
173 (!(classes[i] = talloc_strdup(classes,
174 pclass_buf->name)))) {
175 status = NT_STATUS_NO_MEMORY;
179 if (!(names[i] = talloc_strdup(names, name_buf.name))) {
180 status = NT_STATUS_NO_MEMORY;
185 (!(modtimes[i] = (NTTIME *)talloc_memdup(
186 modtimes, pmodtime, sizeof(*pmodtime))))) {
187 status = NT_STATUS_NO_MEMORY;
192 *pnum_keys = num_subkeys;
195 *pnames = talloc_move(ctx, &names);
198 *pclasses = talloc_move(ctx, &classes);
201 *pmodtimes = talloc_move(ctx, &modtimes);
204 status = NT_STATUS_OK;
207 TALLOC_FREE(mem_ctx);
211 static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx,
212 struct rpc_pipe_client *pipe_hnd,
213 struct policy_handle *key_hnd,
214 uint32 *pnum_values, char ***pvalnames,
215 struct registry_value ***pvalues)
219 uint32 num_subkeys, max_subkeylen, max_classlen;
220 uint32 num_values, max_valnamelen, max_valbufsize;
222 NTTIME last_changed_time;
224 struct winreg_String classname;
225 struct registry_value **values;
228 if (!(mem_ctx = talloc_new(ctx))) {
229 return NT_STATUS_NO_MEMORY;
232 ZERO_STRUCT(classname);
233 status = rpccli_winreg_QueryInfoKey(
234 pipe_hnd, mem_ctx, key_hnd, &classname, &num_subkeys,
235 &max_subkeylen, &max_classlen, &num_values, &max_valnamelen,
236 &max_valbufsize, &secdescsize, &last_changed_time );
238 if (!NT_STATUS_IS_OK(status)) {
242 if (num_values == 0) {
244 TALLOC_FREE(mem_ctx);
248 if ((!(names = TALLOC_ARRAY(mem_ctx, char *, num_values))) ||
249 (!(values = TALLOC_ARRAY(mem_ctx, struct registry_value *,
251 status = NT_STATUS_NO_MEMORY;
255 for (i=0; i<num_values; i++) {
256 enum winreg_Type type = REG_NONE;
257 enum winreg_Type *ptype = &type;
262 uint32 *pdata_size = &data_size;
265 uint32 *pvalue_length = &value_length;
268 struct winreg_ValNameBuf name_buf;
273 name_buf.size = max_valnamelen + 2;
275 data_size = max_valbufsize;
278 status = rpccli_winreg_EnumValue(pipe_hnd, mem_ctx, key_hnd,
279 i, &name_buf, &ptype,
283 if ( W_ERROR_EQUAL(ntstatus_to_werror(status),
284 WERR_NO_MORE_ITEMS) ) {
285 status = NT_STATUS_OK;
289 if (!(NT_STATUS_IS_OK(status))) {
293 if ((name_buf.name == NULL) || (ptype == NULL) ||
294 (data == NULL) || (pdata_size == 0) ||
295 (pvalue_length == NULL)) {
296 status = NT_STATUS_INVALID_PARAMETER;
300 if (!(names[i] = talloc_strdup(names, name_buf.name))) {
301 status = NT_STATUS_NO_MEMORY;
305 err = registry_pull_value(values, &values[i], *ptype, data,
306 *pdata_size, *pvalue_length);
307 if (!W_ERROR_IS_OK(err)) {
308 status = werror_to_ntstatus(err);
313 *pnum_values = num_values;
316 *pvalnames = talloc_move(ctx, &names);
319 *pvalues = talloc_move(ctx, &values);
322 status = NT_STATUS_OK;
325 TALLOC_FREE(mem_ctx);
329 static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx,
330 struct rpc_pipe_client *pipe_hnd,
331 struct policy_handle *key_hnd,
333 const struct registry_value *value)
335 struct winreg_String name_string;
340 err = registry_push_value(mem_ctx, value, &blob);
341 if (!W_ERROR_IS_OK(err)) {
342 return werror_to_ntstatus(err);
345 name_string.name = name;
346 result = rpccli_winreg_SetValue(pipe_hnd, blob.data, key_hnd,
347 name_string, value->type,
348 blob.data, blob.length);
349 TALLOC_FREE(blob.data);
353 static NTSTATUS rpc_registry_setvalue_internal(const DOM_SID *domain_sid,
354 const char *domain_name,
355 struct cli_state *cli,
356 struct rpc_pipe_client *pipe_hnd,
361 struct policy_handle hive_hnd, key_hnd;
363 struct registry_value value;
365 status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_WRITE,
366 &hive_hnd, &key_hnd);
367 if (!NT_STATUS_IS_OK(status)) {
368 d_fprintf(stderr, "registry_openkey failed: %s\n",
373 if (!strequal(argv[2], "multi_sz") && (argc != 4)) {
374 d_fprintf(stderr, "Too many args for type %s\n", argv[2]);
375 return NT_STATUS_NOT_IMPLEMENTED;
378 if (strequal(argv[2], "dword")) {
379 value.type = REG_DWORD;
380 value.v.dword = strtoul(argv[3], NULL, 10);
382 else if (strequal(argv[2], "sz")) {
384 value.v.sz.len = strlen(argv[3])+1;
385 value.v.sz.str = CONST_DISCARD(char *, argv[3]);
388 d_fprintf(stderr, "type \"%s\" not implemented\n", argv[3]);
389 status = NT_STATUS_NOT_IMPLEMENTED;
393 status = registry_setvalue(mem_ctx, pipe_hnd, &key_hnd,
396 if (!NT_STATUS_IS_OK(status)) {
397 d_fprintf(stderr, "registry_setvalue failed: %s\n",
402 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd);
403 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd);
408 static int rpc_registry_setvalue( int argc, const char **argv )
411 d_fprintf(stderr, "usage: net rpc registry setvalue <key> "
412 "<valuename> <type> [<val>]+\n");
416 return run_rpc_command( NULL, PI_WINREG, 0,
417 rpc_registry_setvalue_internal, argc, argv );
420 static NTSTATUS rpc_registry_deletevalue_internal(const DOM_SID *domain_sid,
421 const char *domain_name,
422 struct cli_state *cli,
423 struct rpc_pipe_client *pipe_hnd,
428 struct policy_handle hive_hnd, key_hnd;
430 struct winreg_String valuename;
432 status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_WRITE,
433 &hive_hnd, &key_hnd);
434 if (!NT_STATUS_IS_OK(status)) {
435 d_fprintf(stderr, "registry_openkey failed: %s\n",
440 valuename.name = argv[1];
442 status = rpccli_winreg_DeleteValue(pipe_hnd, mem_ctx, &key_hnd,
445 if (!NT_STATUS_IS_OK(status)) {
446 d_fprintf(stderr, "registry_deletevalue failed: %s\n",
450 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd);
451 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd);
456 static int rpc_registry_deletevalue( int argc, const char **argv )
459 d_fprintf(stderr, "usage: net rpc registry deletevalue <key> "
464 return run_rpc_command( NULL, PI_WINREG, 0,
465 rpc_registry_deletevalue_internal, argc, argv );
468 static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid,
469 const char *domain_name,
470 struct cli_state *cli,
471 struct rpc_pipe_client *pipe_hnd,
477 struct policy_handle hive_hnd, key_hnd;
478 struct winreg_String key, keyclass;
479 enum winreg_CreateAction action;
480 enum winreg_CreateAction *paction = &action;
483 if (!reg_hive_key(argv[0], &hive, &key.name)) {
484 return NT_STATUS_INVALID_PARAMETER;
487 status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive,
488 REG_KEY_READ|REG_KEY_WRITE,
490 if (!(NT_STATUS_IS_OK(status))) {
494 action = REG_ACTION_NONE;
497 status = rpccli_winreg_CreateKey(pipe_hnd, mem_ctx, &hive_hnd, key,
498 keyclass, 0, REG_KEY_READ, NULL,
500 if (!NT_STATUS_IS_OK(status)) {
501 d_fprintf(stderr, "createkey returned %s\n",
503 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd);
509 case REG_ACTION_NONE:
510 d_printf("createkey did nothing -- huh?\n");
512 case REG_CREATED_NEW_KEY:
513 d_printf("createkey created %s\n", argv[0]);
515 case REG_OPENED_EXISTING_KEY:
516 d_printf("createkey opened existing %s\n", argv[0]);
521 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &key_hnd);
522 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd);
527 static int rpc_registry_createkey( int argc, const char **argv )
530 d_fprintf(stderr, "usage: net rpc registry createkey <key>\n");
534 return run_rpc_command( NULL, PI_WINREG, 0,
535 rpc_registry_createkey_internal, argc, argv );
538 static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid,
539 const char *domain_name,
540 struct cli_state *cli,
541 struct rpc_pipe_client *pipe_hnd,
547 struct policy_handle hive_hnd;
548 struct winreg_String key;
551 if (!reg_hive_key(argv[0], &hive, &key.name)) {
552 return NT_STATUS_INVALID_PARAMETER;
555 status = rpccli_winreg_Connect(pipe_hnd, mem_ctx, hive, REG_KEY_WRITE,
557 if (!(NT_STATUS_IS_OK(status))) {
561 status = rpccli_winreg_DeleteKey(pipe_hnd, mem_ctx, &hive_hnd, key);
562 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &hive_hnd);
564 if (!NT_STATUS_IS_OK(status)) {
565 d_fprintf(stderr, "deletekey returned %s\n",
572 static int rpc_registry_deletekey( int argc, const char **argv )
575 d_fprintf(stderr, "usage: net rpc registry deletekey <key>\n");
579 return run_rpc_command( NULL, PI_WINREG, 0,
580 rpc_registry_deletekey_internal, argc, argv );
583 /********************************************************************
584 ********************************************************************/
586 static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
587 const char *domain_name,
588 struct cli_state *cli,
589 struct rpc_pipe_client *pipe_hnd,
594 POLICY_HND pol_hive, pol_key;
596 uint32 num_subkeys = 0;
597 uint32 num_values = 0;
598 char **names = NULL, **classes = NULL;
599 NTTIME **modtimes = NULL;
601 struct registry_value **values = NULL;
604 d_printf("Usage: net rpc enumerate <path> [recurse]\n");
605 d_printf("Example: net rpc enumerate 'HKLM\\Software\\Samba'\n");
609 status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_READ,
610 &pol_hive, &pol_key);
611 if (!NT_STATUS_IS_OK(status)) {
612 d_fprintf(stderr, "registry_openkey failed: %s\n",
617 status = registry_enumkeys(mem_ctx, pipe_hnd, &pol_key, &num_subkeys,
618 &names, &classes, &modtimes);
619 if (!NT_STATUS_IS_OK(status)) {
620 d_fprintf(stderr, "enumerating keys failed: %s\n",
625 for (i=0; i<num_subkeys; i++) {
626 d_printf("Keyname = %s\n", names[i]);
627 d_printf("Modtime = %s\n", modtimes[i]
628 ? http_timestring(nt_time_to_unix(*modtimes[i]))
633 status = registry_enumvalues(mem_ctx, pipe_hnd, &pol_key, &num_values,
635 if (!NT_STATUS_IS_OK(status)) {
636 d_fprintf(stderr, "enumerating values failed: %s\n",
641 for (i=0; i<num_values; i++) {
642 struct registry_value *v = values[i];
643 d_printf("Valuename = %s\n", names[i]);
644 d_printf("Type = %s\n",
645 reg_type_lookup(v->type));
648 d_printf("Value = %d\n", v->v.dword);
652 d_printf("Value = \"%s\"\n", v->v.sz.str);
656 for (j = 0; j < v->v.multi_sz.num_strings; j++) {
657 d_printf("Value[%3.3d] = \"%s\"\n", j,
658 v->v.multi_sz.strings[j]);
663 d_printf("Value = %d bytes\n",
667 d_printf("Value = <unprintable>\n");
674 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key );
675 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive );
680 /********************************************************************
681 ********************************************************************/
683 static int rpc_registry_enumerate( int argc, const char **argv )
685 return run_rpc_command( NULL, PI_WINREG, 0,
686 rpc_registry_enumerate_internal, argc, argv );
689 /********************************************************************
690 ********************************************************************/
692 static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
693 const char *domain_name,
694 struct cli_state *cli,
695 struct rpc_pipe_client *pipe_hnd,
700 WERROR result = WERR_GENERAL_FAILURE;
701 POLICY_HND pol_hive, pol_key;
702 NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
703 struct winreg_String filename;
706 d_printf("Usage: net rpc backup <path> <file> \n");
710 status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_ALL,
711 &pol_hive, &pol_key);
712 if (!NT_STATUS_IS_OK(status)) {
713 d_fprintf(stderr, "registry_openkey failed: %s\n",
718 filename.name = argv[1];
719 status = rpccli_winreg_SaveKey( pipe_hnd, mem_ctx, &pol_key, &filename, NULL );
720 if ( !W_ERROR_IS_OK(result) ) {
721 d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]);
726 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key );
727 rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive );
732 /********************************************************************
733 ********************************************************************/
735 static int rpc_registry_save( int argc, const char **argv )
737 return run_rpc_command( NULL, PI_WINREG, 0,
738 rpc_registry_save_internal, argc, argv );
742 /********************************************************************
743 ********************************************************************/
745 static void dump_values( REGF_NK_REC *nk )
749 uint32 data_size, data;
754 for ( i=0; i<nk->num_values; i++ ) {
755 d_printf( "\"%s\" = ", nk->values[i].valuename ? nk->values[i].valuename : "(default)" );
756 d_printf( "(%s) ", reg_type_lookup( nk->values[i].type ) );
758 data_size = nk->values[i].data_size & ~VK_DATA_IN_OFFSET;
759 switch ( nk->values[i].type ) {
761 rpcstr_pull( data_str, nk->values[i].data, sizeof(data_str), -1, STR_TERMINATE );
762 d_printf( "%s", data_str );
766 for ( j=0; j<data_size; j++ ) {
767 d_printf( "%c", nk->values[i].data[j] );
771 data = IVAL( nk->values[i].data, 0 );
772 d_printf("0x%x", data );
775 for ( j=0; j<data_size; j++ ) {
776 d_printf( "%x", nk->values[i].data[j] );
789 /********************************************************************
790 ********************************************************************/
792 static BOOL dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *parent )
797 /* depth first dump of the registry tree */
799 while ( (key = regfio_fetch_subkey( file, nk )) ) {
800 pstr_sprintf( regpath, "%s\\%s", parent, key->keyname );
801 d_printf("[%s]\n", regpath );
804 dump_registry_tree( file, key, regpath );
810 /********************************************************************
811 ********************************************************************/
813 static BOOL write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
814 REGF_NK_REC *parent, REGF_FILE *outfile,
815 const char *parentpath )
817 REGF_NK_REC *key, *subkey;
819 REGSUBKEY_CTR *subkeys;
823 if ( !( subkeys = TALLOC_ZERO_P( infile->mem_ctx, REGSUBKEY_CTR )) ) {
824 DEBUG(0,("write_registry_tree: talloc() failed!\n"));
828 if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) {
829 DEBUG(0,("write_registry_tree: talloc() failed!\n"));
833 /* copy values into the REGVAL_CTR */
835 for ( i=0; i<nk->num_values; i++ ) {
836 regval_ctr_addvalue( values, nk->values[i].valuename, nk->values[i].type,
837 (const char *)nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) );
840 /* copy subkeys into the REGSUBKEY_CTR */
842 while ( (subkey = regfio_fetch_subkey( infile, nk )) ) {
843 regsubkey_ctr_addkey( subkeys, subkey->keyname );
846 key = regfio_write_key( outfile, nk->keyname, values, subkeys, nk->sec_desc->sec_desc, parent );
848 /* write each one of the subkeys out */
850 pstr_sprintf( path, "%s%s%s", parentpath, parent ? "\\" : "", nk->keyname );
851 nk->subkey_index = 0;
852 while ( (subkey = regfio_fetch_subkey( infile, nk )) ) {
853 write_registry_tree( infile, subkey, key, outfile, path );
856 TALLOC_FREE( subkeys );
858 d_printf("[%s]\n", path );
863 /********************************************************************
864 ********************************************************************/
866 static int rpc_registry_dump( int argc, const char **argv )
872 d_printf("Usage: net rpc dump <file> \n");
876 d_printf("Opening %s....", argv[0]);
877 if ( !(registry = regfio_open( argv[0], O_RDONLY, 0)) ) {
878 d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]);
883 /* get the root of the registry file */
885 if ((nk = regfio_rootkey( registry )) == NULL) {
886 d_fprintf(stderr, "Could not get rootkey\n");
887 regfio_close( registry );
890 d_printf("[%s]\n", nk->keyname);
894 dump_registry_tree( registry, nk, nk->keyname );
897 talloc_report_full( registry->mem_ctx, stderr );
899 d_printf("Closing registry...");
900 regfio_close( registry );
906 /********************************************************************
907 ********************************************************************/
909 static int rpc_registry_copy( int argc, const char **argv )
911 REGF_FILE *infile = NULL, *outfile = NULL;
916 d_printf("Usage: net rpc copy <srcfile> <newfile>\n");
920 d_printf("Opening %s....", argv[0]);
921 if ( !(infile = regfio_open( argv[0], O_RDONLY, 0 )) ) {
922 d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]);
927 d_printf("Opening %s....", argv[1]);
928 if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) {
929 d_fprintf(stderr, "Failed to open %s for writing\n", argv[1]);
934 /* get the root of the registry file */
936 if ((nk = regfio_rootkey( infile )) == NULL) {
937 d_fprintf(stderr, "Could not get rootkey\n");
940 d_printf("RootKey: [%s]\n", nk->keyname);
942 write_registry_tree( infile, nk, NULL, outfile, "" );
948 d_printf("Closing %s...", argv[1]);
950 regfio_close( outfile );
954 d_printf("Closing %s...", argv[0]);
956 regfio_close( infile );
963 /********************************************************************
964 ********************************************************************/
966 int net_rpc_registry(int argc, const char **argv)
968 struct functable2 func[] = {
969 { "enumerate", rpc_registry_enumerate,
970 "Enumerate registry keys and values" },
971 { "createkey", rpc_registry_createkey,
972 "Create a new registry key" },
973 { "deletekey", rpc_registry_deletekey,
974 "Delete a registry key" },
975 { "setvalue", rpc_registry_setvalue,
976 "Set a new registry value" },
977 { "deletevalue", rpc_registry_deletevalue,
978 "Delete a registry value" },
979 { "save", rpc_registry_save,
980 "Save a registry file" },
981 { "dump", rpc_registry_dump,
982 "Dump a registry file" },
983 { "copy", rpc_registry_copy,
984 "Copy a registry file" },
988 return net_run_function2(argc, argv, "net rpc registry", func);