2 Unix SMB/CIFS implementation.
3 NT Domain Authentication SMB / MSRPC client
4 Copyright (C) Andrew Tridgell 1994-1997
5 Copyright (C) Luke Kenneth Casson Leighton 1996-1997
6 Copyright (C) Simo Sorce 2001
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "rpcclient.h"
30 * [HKLM]|[HKU]\[parent_keyname_components]\[subkey]|[value]
32 * reg_getsubkey() splits this down into:
33 * [HKLM]|[HKU]\[parent_keyname_components] and [subkey]|[value]
35 * do_reg_connect() splits the left side down further into:
36 * [HKLM]|[HKU] and [parent_keyname_components].
38 * HKLM is short for HKEY_LOCAL_MACHINE
39 * HKU is short for HKEY_USERS
41 * oh, and HKEY stands for "Hive Key".
45 #if 0 /* Simo: reg functions need to be updated to the new cmd interface */
47 /****************************************************************************
49 ****************************************************************************/
50 static void cmd_reg_enum(struct client_info
*info
)
66 uint32 max_class_len
= 0;
69 uint32 max_subkeysize
;
71 uint32 max_valnamelen
;
72 uint32 max_valbufsize
;
77 * unknown 0x1a request
80 uint32 unk_1a_response
;
82 DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli
->fd
));
84 if (!next_token_nr(NULL
, full_keyname
, NULL
, sizeof(full_keyname
)))
86 fprintf(out_hnd
, "regenum <key_name>\n");
90 /* open WINREG session. */
91 res
= res
? cli_nt_session_open(smb_cli
, PIPE_WINREG
) : False
;
93 /* open registry receive a policy handle */
94 res
= res
? do_reg_connect(smb_cli
, full_keyname
, key_name
,
95 &info
->dom
.reg_pol_connect
) : False
;
100 res1
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
101 key_name
, 0x02000000, &key_pol
) : False
;
105 memcpy(&key_pol
, &info
->dom
.reg_pol_connect
, sizeof(key_pol
));
108 res1
= res1
? do_reg_query_key(smb_cli
,
110 key_class
, &max_class_len
,
111 &num_subkeys
, &max_subkeylen
, &max_subkeysize
,
112 &num_values
, &max_valnamelen
, &max_valbufsize
,
113 &sec_desc
, &mod_time
) : False
;
115 if (res1
&& num_subkeys
> 0)
117 fprintf(out_hnd
,"Subkeys\n");
118 fprintf(out_hnd
,"-------\n");
121 for (i
= 0; i
< num_subkeys
; i
++)
133 res2
= res1
? do_reg_unknown_1a(smb_cli
, &key_pol
,
134 &unk_1a_response
) : False
;
136 if (res2
&& unk_1a_response
!= 5)
138 fprintf(out_hnd
,"Unknown 1a response: %x\n", unk_1a_response
);
142 res2
= res2
? do_reg_enum_key(smb_cli
, &key_pol
,
144 &enum_unk1
, &enum_unk2
,
145 &key_mod_time
) : False
;
149 display_reg_key_info(out_hnd
, ACTION_HEADER
, enum_name
, key_mod_time
);
150 display_reg_key_info(out_hnd
, ACTION_ENUMERATE
, enum_name
, key_mod_time
);
151 display_reg_key_info(out_hnd
, ACTION_FOOTER
, enum_name
, key_mod_time
);
158 fprintf(out_hnd
,"Key Values\n");
159 fprintf(out_hnd
,"----------\n");
162 for (i
= 0; i
< num_values
; i
++)
173 res2
= res1
? do_reg_unknown_1a(smb_cli
, &key_pol
,
174 &unk_1a_response
) : False
;
176 if (res2
&& unk_1a_response
!= 5)
178 fprintf(out_hnd
,"Unknown 1a response: %x\n", unk_1a_response
);
182 res2
= res2
? do_reg_enum_val(smb_cli
, &key_pol
,
183 i
, max_valnamelen
, max_valbufsize
,
184 val_name
, &val_type
, &value
) : False
;
188 display_reg_value_info(out_hnd
, ACTION_HEADER
, val_name
, val_type
, &value
);
189 display_reg_value_info(out_hnd
, ACTION_ENUMERATE
, val_name
, val_type
, &value
);
190 display_reg_value_info(out_hnd
, ACTION_FOOTER
, val_name
, val_type
, &value
);
194 /* close the handles */
195 if ((*key_name
) != 0)
197 res1
= res1
? do_reg_close(smb_cli
, &key_pol
) : False
;
199 res
= res
? do_reg_close(smb_cli
, &info
->dom
.reg_pol_connect
) : False
;
201 /* close the session */
202 cli_nt_session_close(smb_cli
);
204 if (res
&& res1
&& res2
)
206 DEBUG(5,("cmd_reg_enum: query succeeded\n"));
210 DEBUG(5,("cmd_reg_enum: query failed\n"));
214 /****************************************************************************
215 nt registry query key
216 ****************************************************************************/
217 static void cmd_reg_query_key(struct client_info
*info
)
223 fstring full_keyname
;
231 uint32 key_class_len
= 0;
233 uint32 max_subkeylen
;
234 uint32 max_subkeysize
;
236 uint32 max_valnamelen
;
237 uint32 max_valbufsize
;
241 DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli
->fd
));
243 if (!next_token_nr(NULL
, full_keyname
, NULL
, sizeof(full_keyname
)))
245 fprintf(out_hnd
, "regquery key_name\n");
249 /* open WINREG session. */
250 res
= res
? cli_nt_session_open(smb_cli
, PIPE_WINREG
) : False
;
252 /* open registry receive a policy handle */
253 res
= res
? do_reg_connect(smb_cli
, full_keyname
, key_name
,
254 &info
->dom
.reg_pol_connect
) : False
;
256 if ((*key_name
) != 0)
259 res1
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
260 key_name
, 0x02000000, &key_pol
) : False
;
264 memcpy(&key_pol
, &info
->dom
.reg_pol_connect
, sizeof(key_pol
));
267 res1
= res1
? do_reg_query_key(smb_cli
,
269 key_class
, &key_class_len
,
270 &num_subkeys
, &max_subkeylen
, &max_subkeysize
,
271 &num_values
, &max_valnamelen
, &max_valbufsize
,
272 &sec_desc
, &mod_time
) : False
;
274 if (res1
&& key_class_len
!= 0)
276 res1
= res1
? do_reg_query_key(smb_cli
,
278 key_class
, &key_class_len
,
279 &num_subkeys
, &max_subkeylen
, &max_subkeysize
,
280 &num_values
, &max_valnamelen
, &max_valbufsize
,
281 &sec_desc
, &mod_time
) : False
;
286 fprintf(out_hnd
,"Registry Query Info Key\n");
287 fprintf(out_hnd
,"key class: %s\n", key_class
);
288 fprintf(out_hnd
,"subkeys, max_len, max_size: %d %d %d\n", num_subkeys
, max_subkeylen
, max_subkeysize
);
289 fprintf(out_hnd
,"vals, max_len, max_size: 0x%x 0x%x 0x%x\n", num_values
, max_valnamelen
, max_valbufsize
);
290 fprintf(out_hnd
,"sec desc: 0x%x\n", sec_desc
);
291 fprintf(out_hnd
,"mod time: %s\n", http_timestring(nt_time_to_unix(&mod_time
)));
294 /* close the handles */
295 if ((*key_name
) != 0)
297 res1
= res1
? do_reg_close(smb_cli
, &key_pol
) : False
;
299 res
= res
? do_reg_close(smb_cli
, &info
->dom
.reg_pol_connect
) : False
;
301 /* close the session */
302 cli_nt_session_close(smb_cli
);
306 DEBUG(5,("cmd_reg_query: query succeeded\n"));
310 DEBUG(5,("cmd_reg_query: query failed\n"));
314 /****************************************************************************
315 nt registry create value
316 ****************************************************************************/
317 static void cmd_reg_create_val(struct client_info
*info
)
323 POLICY_HND parent_pol
;
324 fstring full_keyname
;
336 res1
= res1
? do_reg_query_info(smb_cli
, &val_pol
,
337 val_name
, *val_type
) : False
;
340 DEBUG(5, ("cmd_reg_create_val: smb_cli->fd:%d\n", smb_cli
->fd
));
342 if (!next_token_nr(NULL
, full_keyname
, NULL
, sizeof(full_keyname
)))
344 fprintf(out_hnd
, "regcreate <val_name> <val_type> <val>\n");
348 reg_get_subkey(full_keyname
, keyname
, val_name
);
350 if (keyname
[0] == 0 || val_name
[0] == 0)
352 fprintf(out_hnd
, "invalid key name\n");
356 if (!next_token_nr(NULL
, tmp
, NULL
, sizeof(tmp
)))
358 fprintf(out_hnd
, "regcreate <val_name> <val_type (1|4)> <val>\n");
362 val_type
= atoi(tmp
);
364 if (val_type
!= 1 && val_type
!= 3 && val_type
!= 4)
366 fprintf(out_hnd
, "val_type 1=UNISTR, 3=BYTES, 4=DWORD supported\n");
370 if (!next_token_nr(NULL
, tmp
, NULL
, sizeof(tmp
)))
372 fprintf(out_hnd
, "regcreate <val_name> <val_type (1|4)> <val>\n");
378 case 0x01: /* UNISTR */
380 init_buffer3_str(&value
, tmp
, strlen(tmp
)+1);
383 case 0x03: /* BYTES */
385 init_buffer3_hex(&value
, tmp
);
388 case 0x04: /* DWORD */
391 if (strnequal(tmp
, "0x", 2))
393 tmp_val
= strtol(tmp
, (char**)NULL
, 16);
397 tmp_val
= strtol(tmp
, (char**)NULL
, 10);
399 init_buffer3_uint32(&value
, tmp_val
);
404 fprintf(out_hnd
, "i told you i only deal with UNISTR, DWORD and BYTES!\n");
409 DEBUG(10,("key data:\n"));
410 dump_data(10, (char *)value
.buffer
, value
.buf_len
);
412 /* open WINREG session. */
413 res
= res
? cli_nt_session_open(smb_cli
, PIPE_WINREG
) : False
;
415 /* open registry receive a policy handle */
416 res
= res
? do_reg_connect(smb_cli
, keyname
, parent_name
,
417 &info
->dom
.reg_pol_connect
) : False
;
419 if ((*val_name
) != 0)
422 res3
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
423 parent_name
, 0x02000000, &parent_pol
) : False
;
427 memcpy(&parent_pol
, &info
->dom
.reg_pol_connect
, sizeof(parent_pol
));
430 /* create an entry */
431 res4
= res3
? do_reg_create_val(smb_cli
, &parent_pol
,
432 val_name
, val_type
, &value
) : False
;
434 /* flush the modified key */
435 res4
= res4
? do_reg_flush_key(smb_cli
, &parent_pol
) : False
;
437 /* close the val handle */
438 if ((*val_name
) != 0)
440 res3
= res3
? do_reg_close(smb_cli
, &parent_pol
) : False
;
443 /* close the registry handles */
444 res
= res
? do_reg_close(smb_cli
, &info
->dom
.reg_pol_connect
) : False
;
446 /* close the session */
447 cli_nt_session_close(smb_cli
);
449 if (res
&& res3
&& res4
)
451 DEBUG(5,("cmd_reg_create_val: query succeeded\n"));
452 fprintf(out_hnd
,"OK\n");
456 DEBUG(5,("cmd_reg_create_val: query failed\n"));
460 /****************************************************************************
461 nt registry delete value
462 ****************************************************************************/
463 static void cmd_reg_delete_val(struct client_info
*info
)
469 POLICY_HND parent_pol
;
470 fstring full_keyname
;
475 DEBUG(5, ("cmd_reg_delete_val: smb_cli->fd:%d\n", smb_cli
->fd
));
477 if (!next_token_nr(NULL
, full_keyname
, NULL
, sizeof(full_keyname
)))
479 fprintf(out_hnd
, "regdelete <val_name>\n");
483 reg_get_subkey(full_keyname
, keyname
, val_name
);
485 if (keyname
[0] == 0 || val_name
[0] == 0)
487 fprintf(out_hnd
, "invalid key name\n");
491 /* open WINREG session. */
492 res
= res
? cli_nt_session_open(smb_cli
, PIPE_WINREG
) : False
;
494 /* open registry receive a policy handle */
495 res
= res
? do_reg_connect(smb_cli
, keyname
, parent_name
,
496 &info
->dom
.reg_pol_connect
) : False
;
498 if ((*val_name
) != 0)
501 res3
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
502 parent_name
, 0x02000000, &parent_pol
) : False
;
506 memcpy(&parent_pol
, &info
->dom
.reg_pol_connect
, sizeof(parent_pol
));
509 /* delete an entry */
510 res4
= res3
? do_reg_delete_val(smb_cli
, &parent_pol
, val_name
) : False
;
512 /* flush the modified key */
513 res4
= res4
? do_reg_flush_key(smb_cli
, &parent_pol
) : False
;
515 /* close the key handle */
516 res3
= res3
? do_reg_close(smb_cli
, &parent_pol
) : False
;
518 /* close the registry handles */
519 res
= res
? do_reg_close(smb_cli
, &info
->dom
.reg_pol_connect
) : False
;
521 /* close the session */
522 cli_nt_session_close(smb_cli
);
524 if (res
&& res3
&& res4
)
526 DEBUG(5,("cmd_reg_delete_val: query succeeded\n"));
527 fprintf(out_hnd
,"OK\n");
531 DEBUG(5,("cmd_reg_delete_val: query failed\n"));
535 /****************************************************************************
536 nt registry delete key
537 ****************************************************************************/
538 static void cmd_reg_delete_key(struct client_info
*info
)
544 POLICY_HND parent_pol
;
545 fstring full_keyname
;
550 DEBUG(5, ("cmd_reg_delete_key: smb_cli->fd:%d\n", smb_cli
->fd
));
552 if (!next_token_nr(NULL
, full_keyname
, NULL
, sizeof(full_keyname
)))
554 fprintf(out_hnd
, "regdeletekey <key_name>\n");
558 reg_get_subkey(full_keyname
, parent_name
, subkey_name
);
560 if (parent_name
[0] == 0 || subkey_name
[0] == 0)
562 fprintf(out_hnd
, "invalid key name\n");
566 /* open WINREG session. */
567 res
= res
? cli_nt_session_open(smb_cli
, PIPE_WINREG
) : False
;
569 /* open registry receive a policy handle */
570 res
= res
? do_reg_connect(smb_cli
, parent_name
, key_name
,
571 &info
->dom
.reg_pol_connect
) : False
;
573 if ((*key_name
) != 0)
576 res3
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
577 key_name
, 0x02000000, &parent_pol
) : False
;
581 memcpy(&parent_pol
, &info
->dom
.reg_pol_connect
, sizeof(parent_pol
));
584 /* create an entry */
585 res4
= res3
? do_reg_delete_key(smb_cli
, &parent_pol
, subkey_name
) : False
;
587 /* flush the modified key */
588 res4
= res4
? do_reg_flush_key(smb_cli
, &parent_pol
) : False
;
590 /* close the key handle */
591 if ((*key_name
) != 0)
593 res3
= res3
? do_reg_close(smb_cli
, &parent_pol
) : False
;
596 /* close the registry handles */
597 res
= res
? do_reg_close(smb_cli
, &info
->dom
.reg_pol_connect
) : False
;
599 /* close the session */
600 cli_nt_session_close(smb_cli
);
602 if (res
&& res3
&& res4
)
604 DEBUG(5,("cmd_reg_delete_key: query succeeded\n"));
605 fprintf(out_hnd
,"OK\n");
609 DEBUG(5,("cmd_reg_delete_key: query failed\n"));
613 /****************************************************************************
614 nt registry create key
615 ****************************************************************************/
616 static void cmd_reg_create_key(struct client_info
*info
)
622 POLICY_HND parent_pol
;
624 fstring full_keyname
;
629 SEC_ACCESS sam_access
;
631 DEBUG(5, ("cmd_reg_create_key: smb_cli->fd:%d\n", smb_cli
->fd
));
633 if (!next_token_nr(NULL
, full_keyname
, NULL
, sizeof(full_keyname
)))
635 fprintf(out_hnd
, "regcreate <key_name> [key_class]\n");
639 reg_get_subkey(full_keyname
, parent_key
, key_name
);
641 if (parent_key
[0] == 0 || key_name
[0] == 0)
643 fprintf(out_hnd
, "invalid key name\n");
647 if (!next_token_nr(NULL
, key_class
, NULL
, sizeof(key_class
)))
649 memset(key_class
, 0, sizeof(key_class
));
652 /* set access permissions */
653 sam_access
.mask
= SEC_RIGHTS_READ
;
655 /* open WINREG session. */
656 res
= res
? cli_nt_session_open(smb_cli
, PIPE_WINREG
) : False
;
658 /* open registry receive a policy handle */
659 res
= res
? do_reg_connect(smb_cli
, parent_key
, parent_name
,
660 &info
->dom
.reg_pol_connect
) : False
;
662 if ((*parent_name
) != 0)
665 res3
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
666 parent_name
, 0x02000000, &parent_pol
) : False
;
670 memcpy(&parent_pol
, &info
->dom
.reg_pol_connect
, sizeof(parent_pol
));
673 /* create an entry */
674 res4
= res3
? do_reg_create_key(smb_cli
, &parent_pol
,
675 key_name
, key_class
, &sam_access
, &key_pol
) : False
;
677 /* flush the modified key */
678 res4
= res4
? do_reg_flush_key(smb_cli
, &parent_pol
) : False
;
680 /* close the key handle */
681 res4
= res4
? do_reg_close(smb_cli
, &key_pol
) : False
;
683 /* close the key handle */
684 if ((*parent_name
) != 0)
686 res3
= res3
? do_reg_close(smb_cli
, &parent_pol
) : False
;
689 /* close the registry handles */
690 res
= res
? do_reg_close(smb_cli
, &info
->dom
.reg_pol_connect
) : False
;
692 /* close the session */
693 cli_nt_session_close(smb_cli
);
695 if (res
&& res3
&& res4
)
697 DEBUG(5,("cmd_reg_create_key: query succeeded\n"));
698 fprintf(out_hnd
,"OK\n");
702 DEBUG(5,("cmd_reg_create_key: query failed\n"));
706 /****************************************************************************
707 nt registry security info
708 ****************************************************************************/
709 static void cmd_reg_test_key_sec(struct client_info
*info
)
716 fstring full_keyname
;
726 DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli
->fd
));
728 if (!next_token_nr(NULL
, full_keyname
, NULL
, sizeof(full_keyname
)))
730 fprintf(out_hnd
, "reggetsec <key_name>\n");
734 /* open WINREG session. */
735 res
= res
? cli_nt_session_open(smb_cli
, PIPE_WINREG
) : False
;
737 /* open registry receive a policy handle */
738 res
= res
? do_reg_connect(smb_cli
, full_keyname
, key_name
,
739 &info
->dom
.reg_pol_connect
) : False
;
741 if ((*key_name
) != 0)
744 res3
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
745 key_name
, 0x02000000, &key_pol
) : False
;
749 memcpy(&key_pol
, &info
->dom
.reg_pol_connect
, sizeof(key_pol
));
753 res3
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
754 key_name
, 0x02000000, &key_pol
) : False
;
756 /* query key sec info. first call sets sec_buf_size. */
759 res4
= res3
? do_reg_get_key_sec(smb_cli
, &key_pol
,
760 &sec_buf_size
, &psdb
) : False
;
762 free_sec_desc_buf(&psdb
);
764 res4
= res4
? do_reg_get_key_sec(smb_cli
, &key_pol
,
765 &sec_buf_size
, &psdb
) : False
;
767 if (res4
&& psdb
->len
> 0 && psdb
->sec
!= NULL
)
769 display_sec_desc(out_hnd
, ACTION_HEADER
, psdb
->sec
);
770 display_sec_desc(out_hnd
, ACTION_ENUMERATE
, psdb
->sec
);
771 display_sec_desc(out_hnd
, ACTION_FOOTER
, psdb
->sec
);
773 res4
= res4
? do_reg_set_key_sec(smb_cli
, &key_pol
, psdb
) : False
;
776 free_sec_desc_buf(&psdb
);
778 /* close the key handle */
779 if ((*key_name
) != 0)
781 res3
= res3
? do_reg_close(smb_cli
, &key_pol
) : False
;
784 /* close the registry handles */
785 res
= res
? do_reg_close(smb_cli
, &info
->dom
.reg_pol_connect
) : False
;
787 /* close the session */
788 cli_nt_session_close(smb_cli
);
790 if (res
&& res3
&& res4
)
792 DEBUG(5,("cmd_reg_test2: query succeeded\n"));
793 fprintf(out_hnd
,"Registry Test2\n");
797 DEBUG(5,("cmd_reg_test2: query failed\n"));
801 /****************************************************************************
802 nt registry security info
803 ****************************************************************************/
804 static void cmd_reg_get_key_sec(struct client_info
*info
)
811 fstring full_keyname
;
821 DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli
->fd
));
823 if (!next_token_nr(NULL
, full_keyname
, NULL
, sizeof(full_keyname
)))
825 fprintf(out_hnd
, "reggetsec <key_name>\n");
829 /* open WINREG session. */
830 res
= res
? cli_nt_session_open(smb_cli
, PIPE_WINREG
) : False
;
832 /* open registry receive a policy handle */
833 res
= res
? do_reg_connect(smb_cli
, full_keyname
, key_name
,
834 &info
->dom
.reg_pol_connect
) : False
;
836 if ((*key_name
) != 0)
839 res3
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
840 key_name
, 0x02000000, &key_pol
) : False
;
844 memcpy(&key_pol
, &info
->dom
.reg_pol_connect
, sizeof(key_pol
));
848 res3
= res
? do_reg_open_entry(smb_cli
, &info
->dom
.reg_pol_connect
,
849 key_name
, 0x02000000, &key_pol
) : False
;
853 res4
= res3
? do_reg_get_key_sec(smb_cli
, &key_pol
,
854 &sec_buf_size
, &psdb
) : False
;
856 free_sec_desc_buf(&psdb
);
858 res4
= res4
? do_reg_get_key_sec(smb_cli
, &key_pol
,
859 &sec_buf_size
, &psdb
) : False
;
861 if (res4
&& psdb
->len
> 0 && psdb
->sec
!= NULL
)
863 display_sec_desc(out_hnd
, ACTION_HEADER
, psdb
->sec
);
864 display_sec_desc(out_hnd
, ACTION_ENUMERATE
, psdb
->sec
);
865 display_sec_desc(out_hnd
, ACTION_FOOTER
, psdb
->sec
);
868 free_sec_desc_buf(&psdb
);
870 /* close the key handle */
871 if ((*key_name
) != 0)
873 res3
= res3
? do_reg_close(smb_cli
, &key_pol
) : False
;
876 /* close the registry handles */
877 res
= res
? do_reg_close(smb_cli
, &info
->dom
.reg_pol_connect
) : False
;
879 /* close the session */
880 cli_nt_session_close(smb_cli
);
882 if (res
&& res3
&& res4
)
884 DEBUG(5,("cmd_reg_get_key_sec: query succeeded\n"));
888 DEBUG(5,("cmd_reg_get_key_sec: query failed\n"));
894 /****************************************************************************
896 ****************************************************************************/
897 static NTSTATUS
cmd_reg_shutdown(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
898 int argc
, char **argv
)
900 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
907 optind
= 0; /* TODO: test if this hack works on other systems too --simo */
909 while ((opt
= getopt(argc
, argv
, "m:t:rf")) != EOF
)
911 fprintf (stderr
, "[%s]\n", argv
[argc
-1]);
917 safe_strcpy(msg
, optarg
, sizeof(msg
)-1);
918 fprintf (stderr
, "[%s|%s]\n", optarg
, msg
);
923 timeout
= atoi(optarg
);
924 fprintf (stderr
, "[%s|%d]\n", optarg
, timeout
);
940 /* create an entry */
941 result
= cli_reg_shutdown(cli
, mem_ctx
, msg
, timeout
, flgs
);
943 if (NT_STATUS_IS_OK(result
))
944 DEBUG(5,("cmd_reg_shutdown: query succeeded\n"));
946 DEBUG(5,("cmd_reg_shutdown: query failed\n"));
951 /****************************************************************************
953 ****************************************************************************/
954 static NTSTATUS
cmd_reg_abort_shutdown(struct cli_state
*cli
,
955 TALLOC_CTX
*mem_ctx
, int argc
,
958 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
960 result
= cli_reg_abort_shutdown(cli
, mem_ctx
);
962 if (NT_STATUS_IS_OK(result
))
963 DEBUG(5,("cmd_reg_abort_shutdown: query succeeded\n"));
965 DEBUG(5,("cmd_reg_abort_shutdown: query failed\n"));
971 /* List of commands exported by this module */
972 struct cmd_set reg_commands
[] = {
976 { "shutdown", cmd_reg_shutdown
, PIPE_WINREG
, "Remote Shutdown",
977 "[-m message] [-t timeout] [-r] [-f] (-r == reboot, -f == force)" },
979 { "abortshutdown", cmd_reg_abort_shutdown
, PIPE_WINREG
, "Abort Shutdown",
982 { "regenum", cmd_reg_enum, "Registry Enumeration",
985 { "regdeletekey", cmd_reg_delete_key, "Registry Key Delete",
988 { "regcreatekey", cmd_reg_create_key, "Registry Key Create",
989 "<keyname> [keyclass]" },
991 { "regqueryval", cmd_reg_query_info, "Registry Value Query",
994 { "regquerykey", cmd_reg_query_key, "Registry Key Query",
997 { "regdeleteval", cmd_reg_delete_val, "Registry Value Delete",
1000 { "regcreateval", cmd_reg_create_val, "Registry Key Create",
1001 "<valname> <valtype> <value>" },
1003 { "reggetsec", cmd_reg_get_key_sec, "Registry Key Security",
1006 { "regtestsec", cmd_reg_test_key_sec, "Test Registry Key Security",