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_svc_open_sc_man(struct cli_state *cli, uint16 fnum,
38 char *srv_name, char *db_name,
44 SVC_Q_OPEN_SC_MAN q_o;
45 BOOL valid_pol = False;
47 if (hnd == NULL) return False;
49 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
50 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
52 /* create and send a MSRPC command with api SVC_OPEN_SC_MAN */
54 DEBUG(4,("SVC Open SC_MAN\n"));
56 make_svc_q_open_sc_man(&q_o, srv_name, db_name, des_access);
58 /* turn parameters into data stream */
59 svc_io_q_open_sc_man("", &q_o, &buf, 0);
61 /* send the data on \PIPE\ */
62 if (rpc_api_pipe_req(cli, fnum, SVC_OPEN_SC_MAN, &buf, &rbuf))
64 SVC_R_OPEN_SC_MAN r_o;
69 svc_io_r_open_sc_man("", &r_o, &rbuf, 0);
72 if (p && r_o.status != 0)
74 /* report error code */
75 DEBUG(0,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
81 /* ok, at last: we're happy. return the policy handle */
82 memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
94 /****************************************************************************
95 do a SVC Enumerate Services
96 ****************************************************************************/
97 BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum,
99 uint32 services_type, uint32 services_state,
100 uint32 buf_size, uint32 *resume_hnd,
101 ENUM_SRVC_STATUS **svcs)
105 SVC_Q_ENUM_SVCS_STATUS q_o;
106 BOOL valid_pol = False;
108 if (hnd == NULL) return False;
110 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
111 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
113 /* create and send a MSRPC command with api SVC_ENUM_SVCS_STATUS */
115 DEBUG(4,("SVC Enum Services Status\n"));
117 make_svc_q_enum_svcs_status(&q_o, hnd,
118 services_type, services_state,
119 buf_size, *resume_hnd);
121 /* turn parameters into data stream */
122 svc_io_q_enum_svcs_status("", &q_o, &buf, 0);
124 /* send the data on \PIPE\ */
125 if (rpc_api_pipe_req(cli, fnum, SVC_ENUM_SVCS_STATUS, &buf, &rbuf))
127 SVC_R_ENUM_SVCS_STATUS r_o;
132 svc_io_r_enum_svcs_status("", &r_o, &rbuf, 0);
133 p = rbuf.offset != 0;
135 if (p && r_o.dos_status != 0)
137 /* report error code */
138 DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", smb_err_msg(ERRDOS, r_o.dos_status)));
139 p = r_o.dos_status != ERRmoredata;
145 (*resume_hnd) = get_enum_hnd(&r_o.resume_hnd);
157 /****************************************************************************
159 ****************************************************************************/
160 BOOL do_svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
165 BOOL valid_close = False;
167 if (hnd == NULL) return False;
169 /* create and send a MSRPC command with api SVC_CLOSE */
171 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
172 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
174 DEBUG(4,("SVC Close\n"));
176 /* store the parameters */
177 make_svc_q_close(&q_c, hnd);
179 /* turn parameters into data stream */
180 svc_io_q_close("", &q_c, &buf, 0);
182 /* send the data on \PIPE\ */
183 if (rpc_api_pipe_req(cli, fnum, SVC_CLOSE, &buf, &rbuf))
190 svc_io_r_close("", &r_c, &rbuf, 0);
191 p = rbuf.offset != 0;
193 if (p && r_c.status != 0)
195 /* report error code */
196 DEBUG(0,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status)));
202 /* check that the returned policy handle is all zeros */
206 for (i = 0; i < sizeof(r_c.pol.data); i++)
208 if (r_c.pol.data[i] != 0)
216 DEBUG(0,("SVC_CLOSE: non-zero handle returned\n"));