2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Gerald Carter 2005.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include "rpc_client.h"
24 /*******************************************************************
25 *******************************************************************/
27 WERROR
rpccli_svcctl_enumerate_services( struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
28 POLICY_HND
*hSCM
, uint32 type
, uint32 state
,
29 uint32
*returned
, ENUM_SERVICES_STATUS
**service_array
)
31 SVCCTL_Q_ENUM_SERVICES_STATUS in
;
32 SVCCTL_R_ENUM_SERVICES_STATUS out
;
33 prs_struct qbuf
, rbuf
;
35 ENUM_SERVICES_STATUS
*services
;
41 /* setup the request */
43 memcpy( &in
.handle
, hSCM
, sizeof(POLICY_HND
) );
49 /* first time is to get the buffer size */
52 CLI_DO_RPC_WERR( cli
, mem_ctx
, &ndr_table_svcctl
.syntax_id
, SVCCTL_ENUM_SERVICES_STATUS_W
,
55 svcctl_io_q_enum_services_status
,
56 svcctl_io_r_enum_services_status
,
57 WERR_GENERAL_FAILURE
);
59 /* second time with correct buffer size...should be ok */
61 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
62 in
.buffer_size
= out
.needed
;
64 CLI_DO_RPC_WERR( cli
, mem_ctx
, &ndr_table_svcctl
.syntax_id
,
65 SVCCTL_ENUM_SERVICES_STATUS_W
,
68 svcctl_io_q_enum_services_status
,
69 svcctl_io_r_enum_services_status
,
70 WERR_GENERAL_FAILURE
);
73 if ( !W_ERROR_IS_OK(out
.status
) )
76 /* pull out the data */
78 if ( !(services
= TALLOC_ARRAY( mem_ctx
, ENUM_SERVICES_STATUS
, out
.returned
)) )
84 for ( i
=0; i
<out
.returned
; i
++ ) {
85 svcctl_io_enum_services_status( "", &services
[i
], &out
.buffer
, 0 );
88 *service_array
= services
;
89 *returned
= out
.returned
;
94 /*******************************************************************
95 *******************************************************************/
97 WERROR
rpccli_svcctl_query_config(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
98 POLICY_HND
*hService
, SERVICE_CONFIG
*config
)
100 SVCCTL_Q_QUERY_SERVICE_CONFIG in
;
101 SVCCTL_R_QUERY_SERVICE_CONFIG out
;
102 prs_struct qbuf
, rbuf
;
107 memcpy( &in
.handle
, hService
, sizeof(POLICY_HND
) );
111 CLI_DO_RPC_WERR( cli
, mem_ctx
, &ndr_table_svcctl
.syntax_id
,
112 SVCCTL_QUERY_SERVICE_CONFIG_W
,
115 svcctl_io_q_query_service_config
,
116 svcctl_io_r_query_service_config
,
117 WERR_GENERAL_FAILURE
);
119 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
120 in
.buffer_size
= out
.needed
;
122 CLI_DO_RPC_WERR( cli
, mem_ctx
, &ndr_table_svcctl
.syntax_id
,
123 SVCCTL_QUERY_SERVICE_CONFIG_W
,
126 svcctl_io_q_query_service_config
,
127 svcctl_io_r_query_service_config
,
128 WERR_GENERAL_FAILURE
);
131 if ( !W_ERROR_IS_OK( out
.status
) )
134 memcpy( config
, &out
.config
, sizeof(SERVICE_CONFIG
) );
136 config
->executablepath
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
137 config
->loadordergroup
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
138 config
->dependencies
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
139 config
->startname
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
140 config
->displayname
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
142 if ( out
.config
.executablepath
) {
143 config
->executablepath
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
144 copy_unistr2( config
->executablepath
, out
.config
.executablepath
);
147 if ( out
.config
.loadordergroup
) {
148 config
->loadordergroup
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
149 copy_unistr2( config
->loadordergroup
, out
.config
.loadordergroup
);
152 if ( out
.config
.dependencies
) {
153 config
->dependencies
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
154 copy_unistr2( config
->dependencies
, out
.config
.dependencies
);
157 if ( out
.config
.startname
) {
158 config
->startname
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
159 copy_unistr2( config
->startname
, out
.config
.startname
);
162 if ( out
.config
.displayname
) {
163 config
->displayname
= TALLOC_ZERO_P( mem_ctx
, UNISTR2
);
164 copy_unistr2( config
->displayname
, out
.config
.displayname
);