3 * Unix SMB/Netbios implementation.
5 * RPC Pipe client / server routines
6 * Copyright (C) Andrew Tridgell 1992-1998,
7 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
8 * Copyright (C) Paul Ashton 1997-1998.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 extern int DEBUGLEVEL;
34 /****************************************************************************
36 ****************************************************************************/
37 BOOL do_reg_connect(struct cli_state *cli, uint16 fnum, char *full_keyname, char *key_name,
43 if (full_keyname == NULL)
48 ZERO_STRUCTP(reg_hnd);
51 * open registry receive a policy handle
54 if (!reg_split_key(full_keyname, ®_type, key_name))
56 DEBUG(0,("do_reg_connect: unrecognised key name %s\n", full_keyname));
62 case HKEY_LOCAL_MACHINE:
64 res = res ? do_reg_open_hklm(cli, fnum,
72 res = res ? do_reg_open_hku(cli, fnum,
79 DEBUG(0,("do_reg_connect: unrecognised hive key\n"));
87 /****************************************************************************
89 ****************************************************************************/
90 BOOL do_reg_open_hklm(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
96 BOOL valid_pol = False;
98 if (hnd == NULL) return False;
100 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
101 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
103 /* create and send a MSRPC command with api REG_OPEN_HKLM */
105 DEBUG(4,("REG Open HKLM\n"));
107 make_reg_q_open_hklm(&q_o, unknown_0, level);
109 /* turn parameters into data stream */
110 reg_io_q_open_hklm("", &q_o, &buf, 0);
112 /* send the data on \PIPE\ */
113 if (rpc_api_pipe_req(cli, fnum, REG_OPEN_HKLM, &buf, &rbuf))
120 reg_io_r_open_hklm("", &r_o, &rbuf, 0);
121 p = rbuf.offset != 0;
123 if (p && r_o.status != 0)
125 /* report error code */
126 DEBUG(0,("REG_OPEN_HKLM: %s\n", get_nt_error_msg(r_o.status)));
132 /* ok, at last: we're happy. return the policy handle */
133 memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
144 /****************************************************************************
146 ****************************************************************************/
147 BOOL do_reg_open_hku(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
153 BOOL valid_pol = False;
155 if (hnd == NULL) return False;
157 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
158 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
160 /* create and send a MSRPC command with api REG_OPEN_HKU */
162 DEBUG(4,("REG Open HKU\n"));
164 make_reg_q_open_hku(&q_o, unknown_0, level);
166 /* turn parameters into data stream */
167 reg_io_q_open_hku("", &q_o, &buf, 0);
169 /* send the data on \PIPE\ */
170 if (rpc_api_pipe_req(cli, fnum, REG_OPEN_HKU, &buf, &rbuf))
177 reg_io_r_open_hku("", &r_o, &rbuf, 0);
178 p = rbuf.offset != 0;
180 if (p && r_o.status != 0)
182 /* report error code */
183 DEBUG(0,("REG_OPEN_HKU: %s\n", get_nt_error_msg(r_o.status)));
189 /* ok, at last: we're happy. return the policy handle */
190 memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
201 /****************************************************************************
202 do a REG Unknown 0xB command. sent after a create key or create value.
203 this might be some sort of "sync" or "refresh" command, sent after
204 modification of the registry...
205 ****************************************************************************/
206 BOOL do_reg_flush_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
211 BOOL valid_query = False;
213 if (hnd == NULL) return False;
215 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
216 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
218 /* create and send a MSRPC command with api REG_FLUSH_KEY */
220 DEBUG(4,("REG Unknown 0xB\n"));
222 make_reg_q_flush_key(&q_o, hnd);
224 /* turn parameters into data stream */
225 reg_io_q_flush_key("", &q_o, &buf, 0);
227 /* send the data on \PIPE\ */
228 if (rpc_api_pipe_req(cli, fnum, REG_FLUSH_KEY, &buf, &rbuf))
235 reg_io_r_flush_key("", &r_o, &rbuf, 0);
236 p = rbuf.offset != 0;
238 if (p && r_o.status != 0)
240 /* report error code */
241 DEBUG(0,("REG_FLUSH_KEY: %s\n", get_nt_error_msg(r_o.status)));
257 /****************************************************************************
259 ****************************************************************************/
260 BOOL do_reg_query_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
261 char *class, uint32 *class_len,
262 uint32 *num_subkeys, uint32 *max_subkeylen,
263 uint32 *max_subkeysize, uint32 *num_values,
264 uint32 *max_valnamelen, uint32 *max_valbufsize,
265 uint32 *sec_desc, NTTIME *mod_time)
270 BOOL valid_query = False;
272 if (hnd == NULL) return False;
274 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
275 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
277 /* create and send a MSRPC command with api REG_QUERY_KEY */
279 DEBUG(4,("REG Query Key\n"));
281 make_reg_q_query_key(&q_o, hnd, *class_len);
283 /* turn parameters into data stream */
284 reg_io_q_query_key("", &q_o, &buf, 0);
286 /* send the data on \PIPE\ */
287 if (rpc_api_pipe_req(cli, fnum, REG_QUERY_KEY, &buf, &rbuf))
294 reg_io_r_query_key("", &r_o, &rbuf, 0);
295 p = rbuf.offset != 0;
297 if (p && r_o.status != 0)
299 /* report error code */
300 DEBUG(0,("REG_QUERY_KEY: %s\n", get_nt_error_msg(r_o.status)));
308 *class_len = r_o.hdr_class.uni_max_len;
309 unistr2_to_ascii(class, &r_o.uni_class, sizeof(fstring)-1);
310 *num_subkeys = r_o.num_subkeys ;
311 *max_subkeylen = r_o.max_subkeylen ;
312 *max_subkeysize = r_o.max_subkeysize;
313 *num_values = r_o.num_values ;
314 *max_valnamelen = r_o.max_valnamelen;
315 *max_valbufsize = r_o.max_valbufsize;
316 *sec_desc = r_o.sec_desc ;
317 *mod_time = r_o.mod_time ;
327 /****************************************************************************
329 ****************************************************************************/
330 BOOL do_reg_unknown_1a(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 *unk)
335 BOOL valid_query = False;
337 if (hnd == NULL) return False;
339 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
340 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
342 /* create and send a MSRPC command with api REG_UNKNOWN_1A */
344 DEBUG(4,("REG Unknown 1a\n"));
346 make_reg_q_unk_1a(&q_o, hnd);
348 /* turn parameters into data stream */
349 reg_io_q_unk_1a("", &q_o, &buf, 0);
351 /* send the data on \PIPE\ */
352 if (rpc_api_pipe_req(cli, fnum, REG_UNK_1A, &buf, &rbuf))
359 reg_io_r_unk_1a("", &r_o, &rbuf, 0);
360 p = rbuf.offset != 0;
362 if (p && r_o.status != 0)
364 /* report error code */
365 DEBUG(0,("REG_UNK_1A: %s\n", get_nt_error_msg(r_o.status)));
372 (*unk) = r_o.unknown;
382 /****************************************************************************
384 ****************************************************************************/
385 BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
386 char *type, uint32 *unk_0, uint32 *unk_1)
391 BOOL valid_query = False;
393 if (hnd == NULL) return False;
395 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
396 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
398 /* create and send a MSRPC command with api REG_INFO */
400 DEBUG(4,("REG Query Info\n"));
402 make_reg_q_info(&q_o, hnd, "ProductType", time(NULL), 4, 1);
404 /* turn parameters into data stream */
405 reg_io_q_info("", &q_o, &buf, 0);
407 /* send the data on \PIPE\ */
408 if (rpc_api_pipe_req(cli, fnum, REG_INFO, &buf, &rbuf))
415 reg_io_r_info("", &r_o, &rbuf, 0);
416 p = rbuf.offset != 0;
418 if (p && r_o.status != 0)
420 /* report error code */
421 DEBUG(0,("REG_INFO: %s\n", get_nt_error_msg(r_o.status)));
428 unibuf_to_ascii(type, r_o.uni_type.buffer,
429 MIN(r_o.uni_type.buf_len, sizeof(fstring)-1));
430 (*unk_0) = r_o.unknown_0;
431 (*unk_1) = r_o.unknown_1;
441 /****************************************************************************
442 do a REG Set Key Security
443 ****************************************************************************/
444 BOOL do_reg_set_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
445 uint32 sec_buf_size, SEC_DESC *sec_buf)
449 REG_Q_SET_KEY_SEC q_o;
450 BOOL valid_query = False;
452 if (hnd == NULL) return False;
454 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
455 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
457 /* create and send a MSRPC command with api REG_SET_KEY_SEC */
459 DEBUG(4,("REG Set Key security.\n"));
461 make_reg_q_set_key_sec(&q_o, hnd, sec_buf_size, sec_buf);
463 /* turn parameters into data stream */
464 reg_io_q_set_key_sec("", &q_o, &buf, 0);
466 /* send the data on \PIPE\ */
467 if (rpc_api_pipe_req(cli, fnum, REG_SET_KEY_SEC, &buf, &rbuf))
469 REG_R_SET_KEY_SEC r_o;
474 reg_io_r_set_key_sec("", &r_o, &rbuf, 0);
475 p = rbuf.offset != 0;
477 if (p && r_o.status != 0)
490 /****************************************************************************
491 do a REG Query Key Security
492 ****************************************************************************/
493 BOOL do_reg_get_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
494 uint32 *sec_buf_size, SEC_DESC_BUF *sec_buf)
498 REG_Q_GET_KEY_SEC q_o;
499 BOOL valid_query = False;
501 if (hnd == NULL) return False;
503 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
504 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
506 /* create and send a MSRPC command with api REG_GET_KEY_SEC */
508 DEBUG(4,("REG query key security. buf_size: %d\n", *sec_buf_size));
510 make_reg_q_get_key_sec(&q_o, hnd, *sec_buf_size, sec_buf);
512 /* turn parameters into data stream */
513 reg_io_q_get_key_sec("", &q_o, &buf, 0);
515 /* send the data on \PIPE\ */
516 if (rpc_api_pipe_req(cli, fnum, REG_GET_KEY_SEC, &buf, &rbuf))
518 REG_R_GET_KEY_SEC r_o;
524 if (*sec_buf_size != 0)
526 sec_buf->sec = (SEC_DESC*)malloc(*sec_buf_size);
528 reg_io_r_get_key_sec("", &r_o, &rbuf, 0);
529 p = rbuf.offset != 0;
531 if (p && r_o.status == 0x0000007a)
534 * get the maximum buffer size: it was too small
536 (*sec_buf_size) = r_o.hdr_sec.buf_max_len;
537 DEBUG(5,("sec_buf_size too small. use %d\n", *sec_buf_size));
540 else if (p && r_o.status != 0)
542 /* report error code */
543 DEBUG(0,("REG_GET_KEY_SEC: %s\n", get_nt_error_msg(r_o.status)));
549 (*sec_buf_size) = r_o.data->len;
559 /****************************************************************************
560 do a REG Delete Value
561 ****************************************************************************/
562 BOOL do_reg_delete_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, char *val_name)
566 REG_Q_DELETE_VALUE q_o;
567 BOOL valid_delete = False;
569 if (hnd == NULL) return False;
571 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
572 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
574 /* create and send a MSRPC command with api REG_DELETE_VALUE */
576 DEBUG(4,("REG Delete Value: %s\n", val_name));
578 make_reg_q_delete_val(&q_o, hnd, val_name);
580 /* turn parameters into data stream */
581 reg_io_q_delete_val("", &q_o, &buf, 0);
583 /* send the data on \PIPE\ */
584 if (rpc_api_pipe_req(cli, fnum, REG_DELETE_VALUE, &buf, &rbuf))
586 REG_R_DELETE_VALUE r_o;
591 reg_io_r_delete_val("", &r_o, &rbuf, 0);
592 p = rbuf.offset != 0;
594 if (p && r_o.status != 0)
596 /* report error code */
597 DEBUG(0,("REG_DELETE_VALUE: %s\n", get_nt_error_msg(r_o.status)));
613 /****************************************************************************
615 ****************************************************************************/
616 BOOL do_reg_delete_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, char *key_name)
620 REG_Q_DELETE_KEY q_o;
621 BOOL valid_delete = False;
623 if (hnd == NULL) return False;
625 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
626 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
628 /* create and send a MSRPC command with api REG_DELETE_KEY */
630 DEBUG(4,("REG Delete Key: %s\n", key_name));
632 make_reg_q_delete_key(&q_o, hnd, key_name);
634 /* turn parameters into data stream */
635 reg_io_q_delete_key("", &q_o, &buf, 0);
637 /* send the data on \PIPE\ */
638 if (rpc_api_pipe_req(cli, fnum, REG_DELETE_KEY, &buf, &rbuf))
640 REG_R_DELETE_KEY r_o;
645 reg_io_r_delete_key("", &r_o, &rbuf, 0);
646 p = rbuf.offset != 0;
648 if (p && r_o.status != 0)
650 /* report error code */
651 DEBUG(0,("REG_DELETE_KEY: %s\n", get_nt_error_msg(r_o.status)));
667 /****************************************************************************
669 ****************************************************************************/
670 BOOL do_reg_create_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
671 char *key_name, char *key_class,
672 SEC_ACCESS *sam_access,
677 REG_Q_CREATE_KEY q_o;
678 BOOL valid_create = False;
680 SEC_DESC_BUF sec_buf;
684 ZERO_STRUCT(sec_buf);
687 if (hnd == NULL) return False;
689 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
690 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
692 /* create and send a MSRPC command with api REG_CREATE_KEY */
694 DEBUG(4,("REG Create Key: %s %s 0x%08x\n", key_name, key_class,
695 sam_access != NULL ? sam_access->mask : 0));
697 sec_len = make_sec_desc(&sec, 1, SEC_DESC_SELF_RELATIVE,
698 NULL, NULL, NULL, NULL);
700 DEBUG(10,("make_sec_desc: len = %d\n", sec_len));
702 make_reg_q_create_key(&q_o, hnd, key_name, key_class, sam_access,
703 &sec_buf, sec_len, &sec);
705 /* turn parameters into data stream */
706 reg_io_q_create_key("", &q_o, &buf, 0);
708 /* send the data on \PIPE\ */
709 if (rpc_api_pipe_req(cli, fnum, REG_CREATE_KEY, &buf, &rbuf))
711 REG_R_CREATE_KEY r_o;
716 reg_io_r_create_key("", &r_o, &rbuf, 0);
717 p = rbuf.offset != 0;
719 if (p && r_o.status != 0)
721 /* report error code */
722 DEBUG(0,("REG_CREATE_KEY: %s\n", get_nt_error_msg(r_o.status)));
729 memcpy(key, r_o.key_pol.data, sizeof(key->data));
741 /****************************************************************************
743 ****************************************************************************/
744 BOOL do_reg_enum_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
745 int key_index, char *key_name,
746 uint32 *unk_1, uint32 *unk_2,
752 BOOL valid_query = False;
754 if (hnd == NULL) return False;
756 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
757 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
759 /* create and send a MSRPC command with api REG_ENUM_KEY */
761 DEBUG(4,("REG Enum Key\n"));
763 make_reg_q_enum_key(&q_o, hnd, key_index);
765 /* turn parameters into data stream */
766 reg_io_q_enum_key("", &q_o, &buf, 0);
768 /* send the data on \PIPE\ */
769 if (rpc_api_pipe_req(cli, fnum, REG_ENUM_KEY, &buf, &rbuf))
776 reg_io_r_enum_key("", &r_o, &rbuf, 0);
777 p = rbuf.offset != 0;
779 if (p && r_o.status != 0)
781 /* report error code */
782 DEBUG(0,("REG_ENUM_KEY: %s\n", get_nt_error_msg(r_o.status)));
789 (*unk_1) = r_o.unknown_1;
790 (*unk_2) = r_o.unknown_2;
791 unistr_to_ascii(key_name, r_o.key_name.str.buffer,
793 (*mod_time) = nt_time_to_unix(&r_o.time);
803 /****************************************************************************
804 do a REG Create Value
805 ****************************************************************************/
806 BOOL do_reg_create_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
807 char *val_name, uint32 type, BUFFER3 *data)
811 REG_Q_CREATE_VALUE q_o;
812 BOOL valid_create = False;
814 if (hnd == NULL) return False;
816 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
817 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
819 /* create and send a MSRPC command with api REG_CREATE_VALUE */
821 DEBUG(4,("REG Create Value: %s\n", val_name));
823 make_reg_q_create_val(&q_o, hnd, val_name, type, data);
825 /* turn parameters into data stream */
826 reg_io_q_create_val("", &q_o, &buf, 0);
828 /* send the data on \PIPE\ */
829 if (rpc_api_pipe_req(cli, fnum, REG_CREATE_VALUE, &buf, &rbuf))
831 REG_R_CREATE_VALUE r_o;
836 reg_io_r_create_val("", &r_o, &rbuf, 0);
837 p = rbuf.offset != 0;
839 if (p && r_o.status != 0)
841 /* report error code */
842 DEBUG(0,("REG_CREATE_VALUE: %s\n", get_nt_error_msg(r_o.status)));
858 /****************************************************************************
860 ****************************************************************************/
861 BOOL do_reg_enum_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
862 int val_index, int max_valnamelen, int max_valbufsize,
864 uint32 *val_type, BUFFER2 *value)
868 REG_Q_ENUM_VALUE q_o;
869 BOOL valid_query = False;
871 if (hnd == NULL) return False;
873 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
874 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
876 /* create and send a MSRPC command with api REG_ENUM_VALUE */
878 DEBUG(4,("REG Enum Value\n"));
880 make_reg_q_enum_val(&q_o, hnd, val_index, max_valnamelen, max_valbufsize);
882 /* turn parameters into data stream */
883 reg_io_q_enum_val("", &q_o, &buf, 0);
885 /* send the data on \PIPE\ */
886 if (rpc_api_pipe_req(cli, fnum, REG_ENUM_VALUE, &buf, &rbuf))
888 REG_R_ENUM_VALUE r_o;
892 r_o.buf_value = value;
894 reg_io_r_enum_val("", &r_o, &rbuf, 0);
895 p = rbuf.offset != 0;
897 if (p && r_o.status != 0)
899 /* report error code */
900 DEBUG(0,("REG_ENUM_VALUE: %s\n", get_nt_error_msg(r_o.status)));
907 (*val_type) = r_o.type;
908 unistr2_to_ascii(val_name, &r_o.uni_name, sizeof(fstring)-1);
918 /****************************************************************************
920 ****************************************************************************/
921 BOOL do_reg_open_entry(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
922 char *key_name, uint32 unk_0,
927 REG_Q_OPEN_ENTRY q_o;
928 BOOL valid_pol = False;
930 if (hnd == NULL) return False;
932 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
933 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
935 /* create and send a MSRPC command with api REG_OPEN_ENTRY */
937 DEBUG(4,("REG Open Entry\n"));
939 make_reg_q_open_entry(&q_o, hnd, key_name, unk_0);
941 /* turn parameters into data stream */
942 reg_io_q_open_entry("", &q_o, &buf, 0);
944 /* send the data on \PIPE\ */
945 if (rpc_api_pipe_req(cli, fnum, REG_OPEN_ENTRY, &buf, &rbuf))
947 REG_R_OPEN_ENTRY r_o;
952 reg_io_r_open_entry("", &r_o, &rbuf, 0);
953 p = rbuf.offset != 0;
955 if (p && r_o.status != 0)
957 /* report error code */
958 DEBUG(0,("REG_OPEN_ENTRY: %s\n", get_nt_error_msg(r_o.status)));
965 memcpy(key_hnd, r_o.pol.data, sizeof(key_hnd->data));
975 /****************************************************************************
977 ****************************************************************************/
978 BOOL do_reg_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
983 BOOL valid_close = False;
985 if (hnd == NULL) return False;
987 /* create and send a MSRPC command with api REG_CLOSE */
989 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
990 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
992 DEBUG(4,("REG Close\n"));
994 /* store the parameters */
995 make_reg_q_close(&q_c, hnd);
997 /* turn parameters into data stream */
998 reg_io_q_close("", &q_c, &buf, 0);
1000 /* send the data on \PIPE\ */
1001 if (rpc_api_pipe_req(cli, fnum, REG_CLOSE, &buf, &rbuf))
1008 reg_io_r_close("", &r_c, &rbuf, 0);
1009 p = rbuf.offset != 0;
1011 if (p && r_c.status != 0)
1013 /* report error code */
1014 DEBUG(0,("REG_CLOSE: %s\n", get_nt_error_msg(r_c.status)));
1020 /* check that the returned policy handle is all zeros */
1024 for (i = 0; i < sizeof(r_c.pol.data); i++)
1026 if (r_c.pol.data[i] != 0)
1028 valid_close = False;
1034 DEBUG(0,("REG_CLOSE: non-zero handle returned\n"));
1039 prs_mem_free(&rbuf);
1040 prs_mem_free(&buf );
1045 /****************************************************************************
1046 do a REG Shutdown Server
1047 ****************************************************************************/
1048 BOOL do_reg_shutdown(struct cli_state *cli, uint16 fnum,
1049 char *msg, uint32 timeout, uint16 flags)
1054 BOOL valid_shutdown = False;
1056 if (msg == NULL) return False;
1058 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
1059 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
1061 /* create and send a MSRPC command with api REG_SHUTDOWN */
1063 DEBUG(4,("REG Shutdown: (timeout: %d secs) %s\n", timeout, msg));
1065 make_reg_q_shutdown(&q_o, msg, timeout, flags);
1067 /* turn parameters into data stream */
1068 reg_io_q_shutdown("", &q_o, &buf, 0);
1070 /* send the data on \PIPE\ */
1071 if (rpc_api_pipe_req(cli, fnum, REG_SHUTDOWN, &buf, &rbuf))
1078 reg_io_r_shutdown("", &r_o, &rbuf, 0);
1079 p = rbuf.offset != 0;
1081 if (p && r_o.status != 0)
1083 /* report error code */
1084 DEBUG(0,("REG_SHUTDOWN: %s\n", get_nt_error_msg(r_o.status)));
1090 valid_shutdown = True;
1094 prs_mem_free(&rbuf);
1095 prs_mem_free(&buf );
1097 return valid_shutdown;