From 259d44dbb2c2239339f6888fd5da12632abcbb28 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Mar 2005 16:11:23 +0000 Subject: r6038: adding more flesh to 'net rpc service' open and close the service control manager. Also experimenting with ideas for cli_xxx() interface. (This used to be commit 4da89ef17b8c4644b97b923cebfe8e446b508b4d) --- source3/rpc_client/cli_svcctl.c | 109 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index afef5f4fbb..7bf7392cd6 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -21,13 +21,118 @@ #include "includes.h" +/******************************************************************* +*******************************************************************/ + +WERROR cli_svcctl_open_scm( struct cli_state *cli, TALLOC_CTX *mem_ctx, + SVCCTL_Q_OPEN_SCMANAGER *in, SVCCTL_R_OPEN_SCMANAGER *out ) +{ + prs_struct qbuf, rbuf; + + /* Initialise parse structures */ + + prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); + prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); + + out->status = WERR_GENERAL_FAILURE; + + /* Marshall data and send request */ + + if ( svcctl_io_q_open_scmanager("", in, &qbuf, 0) ) { + if ( rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, &qbuf, &rbuf) ) { + /* Unmarshall response */ + if (!svcctl_io_r_open_scmanager("", out, &rbuf, 0)) { + out->status = WERR_GENERAL_FAILURE; + } + } + } + + prs_mem_free(&qbuf); + prs_mem_free(&rbuf); + + return out->status; +} /******************************************************************* *******************************************************************/ -NTSTATUS cli_svcctl_enumerate_services(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_close_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, + SVCCTL_Q_CLOSE_SERVICE *in, SVCCTL_R_CLOSE_SERVICE *out ) { - return NT_STATUS_OK; + prs_struct qbuf, rbuf; + + /* Initialise parse structures */ + + prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); + prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); + + out->status = WERR_GENERAL_FAILURE; + + /* Marshall data and send request */ + + if ( svcctl_io_q_close_service("", in, &qbuf, 0) ) { + if ( rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_CLOSE_SERVICE, &qbuf, &rbuf) ) { + /* Unmarshall response */ + if (!svcctl_io_r_close_service("", out, &rbuf, 0)) { + out->status = WERR_GENERAL_FAILURE; + } + } + } + + prs_mem_free(&qbuf); + prs_mem_free(&rbuf); + + return out->status; +} + +/******************************************************************* +*******************************************************************/ + +WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hSCM, uint32 type, uint32 state, + uint32 *resume, uint32 buffer_size, RPC_BUFFER *buffer, + uint32 returned ) +{ + prs_struct qbuf, rbuf; + SVCCTL_Q_ENUM_SERVICES_STATUS q; + SVCCTL_R_ENUM_SERVICES_STATUS r; + WERROR result = WERR_GENERAL_FAILURE; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + /* Initialise parse structures */ + + prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); + prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); + + /* Initialise input parameters */ + + + /* Marshall data and send request */ + + if (!svcctl_io_q_enum_services_status("", &q, &qbuf, 0) || + !rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, &qbuf, &rbuf)) { + goto done; + } + + /* Unmarshall response */ + + if (!svcctl_io_r_enum_services_status("", &r, &rbuf, 0)) { + goto done; + } + + /* Return output parameters */ + + if (W_ERROR_IS_OK(result = r.status)) { + *buffer = r.buffer; + } + +done: + prs_mem_free(&qbuf); + prs_mem_free(&rbuf); + + return result; } /******************************************************************* -- cgit