diff options
author | Gerald Carter <jerry@samba.org> | 2005-03-24 18:05:31 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:56:18 -0500 |
commit | 9d009834a63e45e8a348419d4f5313757cff8c8d (patch) | |
tree | d0665f66b8d8273879564e0b64c8df7f7df23741 /source3/rpc_client | |
parent | eb1adc527bb1b01f28fa86e7caa66c85181df764 (diff) | |
download | samba-9d009834a63e45e8a348419d4f5313757cff8c8d.tar.gz samba-9d009834a63e45e8a348419d4f5313757cff8c8d.tar.bz2 samba-9d009834a63e45e8a348419d4f5313757cff8c8d.zip |
r6040: finish out 'net rpc service list'
(This used to be commit 42588ba50cb1b47a00f3e0bed33ca3431eb8af14)
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_svcctl.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 1702112bba..74d6483b17 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -20,24 +20,7 @@ #include "includes.h" - -/* macro to expand cookie-cutter code */ - -#define CLI_DO_RPC( cli, mem_ctx, pipe_num, opnum, in, out, qbuf, rbuf, q_io_fn, r_io_fn, default_error) \ -{ out.status = default_error;\ - prs_init( &qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL ); \ - prs_init( &rbuf, 0, mem_ctx, UNMARSHALL );\ - if ( q_io_fn("", &in, &qbuf, 0) ) {\ - if ( rpc_api_pipe_req(cli, pipe_num, opnum, &qbuf, &rbuf) ) {\ - if (!r_io_fn("", &out, &rbuf, 0)) {\ - out.status = default_error;\ - }\ - }\ - }\ - prs_mem_free( &qbuf );\ - prs_mem_free( &rbuf );\ -} - +#include "rpc_client.h" /******************************************************************** ********************************************************************/ @@ -110,14 +93,28 @@ WERROR close_service_handle( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, uint32 type, uint32 state, - uint32 *resume, uint32 returned ) + uint32 *returned, ENUM_SERVICES_STATUS **service_array ) { SVCCTL_Q_ENUM_SERVICES_STATUS in; SVCCTL_R_ENUM_SERVICES_STATUS out; prs_struct qbuf, rbuf; + uint32 resume = 0; + ENUM_SERVICES_STATUS *services; + int i; ZERO_STRUCT(in); ZERO_STRUCT(out); + + /* setup the request */ + + memcpy( &in.handle, hSCM, sizeof(POLICY_HND) ); + + in.type = type; + in.state = state; + in.resume = &resume; + + /* first time is to get the buffer size */ + in.buffer_size = 0; CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, in, out, @@ -126,8 +123,34 @@ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx svcctl_io_r_enum_services_status, WERR_GENERAL_FAILURE ); + /* second time with correct buffer size...should be ok */ + + if ( !W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { + in.buffer_size = out.needed; + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, + in, out, + qbuf, rbuf, + svcctl_io_q_enum_services_status, + svcctl_io_r_enum_services_status, + WERR_GENERAL_FAILURE ); + } + if ( !W_ERROR_IS_OK(out.status) ) return out.status; + + /* pull out the data */ + if ( !(services = TALLOC_ARRAY( mem_ctx, ENUM_SERVICES_STATUS, out.returned )) ) + return WERR_NOMEM; + + for ( i=0; i<out.returned; i++ ) { + svcctl_io_enum_services_status( "", &services[i], &out.buffer, 0 ); + } + + *service_array = services; + *returned = out.returned; + + return out.status; } |