summaryrefslogtreecommitdiff
path: root/source3/libmsrpc/cac_svcctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libmsrpc/cac_svcctl.c')
-rw-r--r--source3/libmsrpc/cac_svcctl.c850
1 files changed, 460 insertions, 390 deletions
diff --git a/source3/libmsrpc/cac_svcctl.c b/source3/libmsrpc/cac_svcctl.c
index 51a5b5d2dd..9f61b42129 100644
--- a/source3/libmsrpc/cac_svcctl.c
+++ b/source3/libmsrpc/cac_svcctl.c
@@ -1,3 +1,4 @@
+
/*
* Unix SMB/CIFS implementation.
* MS-RPC client library implementation (SVCCTL pipe)
@@ -23,259 +24,288 @@
#define WAIT_SLEEP_TIME 300000
-int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm *op) {
- SMBCSRV *srv = NULL;
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
-
- POLICY_HND *scm_out = NULL;
-
- if(!hnd)
- return CAC_FAILURE;
-
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- if(!op || op->in.access == 0 || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
-
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- /*initialize for samr pipe if we have to*/
- if(!hnd->_internal.pipes[PI_SVCCTL]) {
- if(!(pipe_hnd = cli_rpc_pipe_open_noauth(srv->cli, PI_SVCCTL, &(hnd->status)))) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
- return CAC_FAILURE;
- }
-
- hnd->_internal.pipes[PI_SVCCTL] = True;
- }
-
- scm_out = talloc(mem_ctx, POLICY_HND);
- if(!scm_out) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
-
- err = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, scm_out, op->in.access);
- hnd->status = werror_to_ntstatus(err);
-
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
-
- op->out.scm_hnd = scm_out;
-
- return CAC_SUCCESS;
+int cac_SvcOpenScm( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcOpenScm *op )
+{
+ SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
+
+ POLICY_HND *scm_out = NULL;
+
+ if ( !hnd )
+ return CAC_FAILURE;
+
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
+
+ if ( !op || op->in.access == 0 || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
+
+ srv = cac_GetServer( hnd );
+ if ( !srv ) {
+ hnd->status = NT_STATUS_INVALID_CONNECTION;
+ return CAC_FAILURE;
+ }
+
+ /*initialize for samr pipe if we have to */
+ if ( !hnd->_internal.pipes[PI_SVCCTL] ) {
+ if ( !
+ ( pipe_hnd =
+ cli_rpc_pipe_open_noauth( srv->cli, PI_SVCCTL,
+ &( hnd->status ) ) ) ) {
+ hnd->status = NT_STATUS_UNSUCCESSFUL;
+ return CAC_FAILURE;
+ }
+
+ hnd->_internal.pipes[PI_SVCCTL] = True;
+ }
+
+ scm_out = talloc( mem_ctx, POLICY_HND );
+ if ( !scm_out ) {
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
+
+ err = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, scm_out,
+ op->in.access );
+ hnd->status = werror_to_ntstatus( err );
+
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
+
+ op->out.scm_hnd = scm_out;
+
+ return CAC_SUCCESS;
}
-int cac_SvcClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *scm_hnd) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcClose( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ POLICY_HND * scm_hnd )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!scm_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !scm_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_close_service( pipe_hnd, mem_ctx, scm_hnd);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_close_service( pipe_hnd, mem_ctx, scm_hnd );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- return CAC_SUCCESS;
+ return CAC_SUCCESS;
}
-int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnumServices *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcEnumServices( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcEnumServices *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- uint32 type_buf = 0;
- uint32 state_buf = 0;
+ uint32 type_buf = 0;
+ uint32 state_buf = 0;
- uint32 num_svc_out = 0;
+ uint32 num_svc_out = 0;
- ENUM_SERVICES_STATUS *svc_buf = NULL;
+ ENUM_SERVICES_STATUS *svc_buf = NULL;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.scm_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.scm_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- type_buf = (op->in.type != 0) ? op->in.type : (SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32);
- state_buf = (op->in.state != 0) ? op->in.state : SVCCTL_STATE_ALL;
+ type_buf =
+ ( op->in.type !=
+ 0 ) ? op->in.
+ type : ( SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32 );
+ state_buf = ( op->in.state != 0 ) ? op->in.state : SVCCTL_STATE_ALL;
- err = rpccli_svcctl_enumerate_services( pipe_hnd, mem_ctx, op->in.scm_hnd, type_buf, state_buf, &num_svc_out, &svc_buf);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_enumerate_services( pipe_hnd, mem_ctx,
+ op->in.scm_hnd, type_buf,
+ state_buf, &num_svc_out,
+ &svc_buf );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- op->out.services = cac_MakeServiceArray(mem_ctx, svc_buf, num_svc_out);
+ op->out.services =
+ cac_MakeServiceArray( mem_ctx, svc_buf, num_svc_out );
- if(!op->out.services) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
+ if ( !op->out.services ) {
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
- TALLOC_FREE(svc_buf);
+ TALLOC_FREE( svc_buf );
- op->out.num_services = num_svc_out;
+ op->out.num_services = num_svc_out;
- return CAC_SUCCESS;
+ return CAC_SUCCESS;
}
-int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenService *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcOpenService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcOpenService *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- POLICY_HND *svc_hnd_out = NULL;
+ POLICY_HND *svc_hnd_out = NULL;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.scm_hnd || !op->in.name || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.scm_hnd || !op->in.name || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- svc_hnd_out = talloc(mem_ctx, POLICY_HND);
- if(!svc_hnd_out) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
+ svc_hnd_out = talloc( mem_ctx, POLICY_HND );
+ if ( !svc_hnd_out ) {
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_open_service( pipe_hnd, mem_ctx, op->in.scm_hnd, svc_hnd_out, op->in.name, op->in.access);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_open_service( pipe_hnd, mem_ctx, op->in.scm_hnd,
+ svc_hnd_out, op->in.name,
+ op->in.access );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- op->out.svc_hnd = svc_hnd_out;
+ op->out.svc_hnd = svc_hnd_out;
- return CAC_SUCCESS;
+ return CAC_SUCCESS;
}
-int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcControlService *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcControlService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcControlService *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- SERVICE_STATUS status_out;
+ SERVICE_STATUS status_out;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.svc_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.svc_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- if(op->in.control < SVCCTL_CONTROL_STOP || op->in.control > SVCCTL_CONTROL_SHUTDOWN) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( op->in.control < SVCCTL_CONTROL_STOP
+ || op->in.control > SVCCTL_CONTROL_SHUTDOWN ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, op->in.control, &status_out);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
+ op->in.svc_hnd, op->in.control,
+ &status_out );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- return CAC_SUCCESS;
+ return CAC_SUCCESS;
}
-int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetStatus *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcGetStatus( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcGetStatus *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- SERVICE_STATUS status_out;
+ SERVICE_STATUS status_out;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.svc_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.svc_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, op->in.svc_hnd, &status_out);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, op->in.svc_hnd,
+ &status_out );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- op->out.status = status_out;
+ op->out.status = status_out;
- return CAC_SUCCESS;
+ return CAC_SUCCESS;
}
@@ -288,273 +318,313 @@ int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetSta
* returns CAC_FAILURE if the state is never reached
* or CAC_SUCCESS if the state is reached
*/
-int cac_WaitForService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *svc_hnd, uint32 state, uint32 timeout, SERVICE_STATUS *status) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- /*number of milliseconds we have spent*/
- uint32 time_spent = 0;
- WERROR err;
-
- if(!hnd || !mem_ctx || !svc_hnd || !status)
- return CAC_FAILURE;
-
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
-
- while(status->state != state && time_spent < (timeout * 1000000) && NT_STATUS_IS_OK(hnd->status)) {
- /*if this is the first call, then we _just_ got the status.. sleep now*/
- usleep(WAIT_SLEEP_TIME);
- time_spent += WAIT_SLEEP_TIME;
-
- err = rpccli_svcctl_query_status(pipe_hnd, mem_ctx, svc_hnd, status);
- hnd->status = werror_to_ntstatus(err);
- }
-
- if(status->state == state)
- return CAC_SUCCESS;
-
- return CAC_FAILURE;
+int cac_WaitForService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ POLICY_HND * svc_hnd, uint32 state, uint32 timeout,
+ SERVICE_STATUS * status )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+
+ /*number of milliseconds we have spent */
+ uint32 time_spent = 0;
+ WERROR err;
+
+ if ( !hnd || !mem_ctx || !svc_hnd || !status )
+ return CAC_FAILURE;
+
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
+
+ while ( status->state != state && time_spent < ( timeout * 1000000 )
+ && NT_STATUS_IS_OK( hnd->status ) ) {
+ /*if this is the first call, then we _just_ got the status.. sleep now */
+ usleep( WAIT_SLEEP_TIME );
+ time_spent += WAIT_SLEEP_TIME;
+
+ err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, svc_hnd,
+ status );
+ hnd->status = werror_to_ntstatus( err );
+ }
+
+ if ( status->state == state )
+ return CAC_SUCCESS;
+
+ return CAC_FAILURE;
}
-int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStartService *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcStartService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcStartService *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- SERVICE_STATUS status_buf;
+ SERVICE_STATUS status_buf;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.svc_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.svc_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- if(op->in.num_parms != 0 && op->in.parms == NULL) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( op->in.num_parms != 0 && op->in.parms == NULL ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_start_service(pipe_hnd, mem_ctx, op->in.svc_hnd, (const char **)op->in.parms, op->in.num_parms);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_start_service( pipe_hnd, mem_ctx, op->in.svc_hnd,
+ ( const char ** ) op->in.parms,
+ op->in.num_parms );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- if(op->in.timeout == 0)
- return CAC_SUCCESS;
+ if ( op->in.timeout == 0 )
+ return CAC_SUCCESS;
- return cac_WaitForService(hnd, mem_ctx, op->in.svc_hnd, SVCCTL_RUNNING, op->in.timeout, &status_buf);
+ return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
+ SVCCTL_RUNNING, op->in.timeout,
+ &status_buf );
}
-int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStopService *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcStopService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcStopService *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- SERVICE_STATUS status_out;
+ SERVICE_STATUS status_out;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.svc_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.svc_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_STOP, &status_out);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
+ op->in.svc_hnd,
+ SVCCTL_CONTROL_STOP,
+ &status_out );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- op->out.status = status_out;
+ op->out.status = status_out;
- if(op->in.timeout == 0)
- return CAC_SUCCESS;
+ if ( op->in.timeout == 0 )
+ return CAC_SUCCESS;
- return cac_WaitForService(hnd, mem_ctx, op->in.svc_hnd, SVCCTL_STOPPED, op->in.timeout, &op->out.status);
+ return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
+ SVCCTL_STOPPED, op->in.timeout,
+ &op->out.status );
}
-int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPauseService *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcPauseService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcPauseService *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- SERVICE_STATUS status_out;
+ SERVICE_STATUS status_out;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.svc_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.svc_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_PAUSE, &status_out);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
+ op->in.svc_hnd,
+ SVCCTL_CONTROL_PAUSE,
+ &status_out );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- op->out.status = status_out;
+ op->out.status = status_out;
- if(op->in.timeout == 0)
- return CAC_SUCCESS;
+ if ( op->in.timeout == 0 )
+ return CAC_SUCCESS;
- return cac_WaitForService(hnd, mem_ctx, op->in.svc_hnd, SVCCTL_PAUSED, op->in.timeout, &op->out.status);
+ return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
+ SVCCTL_PAUSED, op->in.timeout,
+ &op->out.status );
}
-int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcContinueService *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcContinueService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcContinueService *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- SERVICE_STATUS status_out;
+ SERVICE_STATUS status_out;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.svc_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.svc_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_CONTINUE, &status_out);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
+ op->in.svc_hnd,
+ SVCCTL_CONTROL_CONTINUE,
+ &status_out );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- op->out.status = status_out;
+ op->out.status = status_out;
- if(op->in.timeout == 0)
- return CAC_SUCCESS;
+ if ( op->in.timeout == 0 )
+ return CAC_SUCCESS;
- return cac_WaitForService(hnd, mem_ctx, op->in.svc_hnd, SVCCTL_RUNNING, op->in.timeout, &op->out.status);
+ return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
+ SVCCTL_RUNNING, op->in.timeout,
+ &op->out.status );
}
-int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetDisplayName *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcGetDisplayName( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcGetDisplayName *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
- fstring disp_name_out;
+ fstring disp_name_out;
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.svc_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.svc_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_get_dispname( pipe_hnd, mem_ctx, op->in.svc_hnd, disp_name_out);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_get_dispname( pipe_hnd, mem_ctx, op->in.svc_hnd,
+ disp_name_out );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- op->out.display_name = talloc_strdup(mem_ctx, disp_name_out);
+ op->out.display_name = talloc_strdup( mem_ctx, disp_name_out );
- if(!op->out.display_name) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
+ if ( !op->out.display_name ) {
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
- return CAC_SUCCESS;
+ return CAC_SUCCESS;
}
-int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetServiceConfig *op) {
- struct rpc_pipe_client *pipe_hnd = NULL;
- WERROR err;
+int cac_SvcGetServiceConfig( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
+ struct SvcGetServiceConfig *op )
+{
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ WERROR err;
+
+ SERVICE_CONFIG config_out;
- SERVICE_CONFIG config_out;
-
- if(!hnd)
- return CAC_FAILURE;
+ if ( !hnd )
+ return CAC_FAILURE;
- if(!hnd->_internal.ctx) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ if ( !hnd->_internal.ctx ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- if(!op || !op->in.svc_hnd || !mem_ctx) {
- hnd->status = NT_STATUS_INVALID_PARAMETER;
- return CAC_FAILURE;
- }
+ if ( !op || !op->in.svc_hnd || !mem_ctx ) {
+ hnd->status = NT_STATUS_INVALID_PARAMETER;
+ return CAC_FAILURE;
+ }
- pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
- if(!pipe_hnd) {
- hnd->status = NT_STATUS_INVALID_HANDLE;
- return CAC_FAILURE;
- }
+ pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
+ if ( !pipe_hnd ) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = rpccli_svcctl_query_config( pipe_hnd, mem_ctx, op->in.svc_hnd, &config_out);
- hnd->status = werror_to_ntstatus(err);
+ err = rpccli_svcctl_query_config( pipe_hnd, mem_ctx, op->in.svc_hnd,
+ &config_out );
+ hnd->status = werror_to_ntstatus( err );
- if(!NT_STATUS_IS_OK(hnd->status))
- return CAC_FAILURE;
+ if ( !NT_STATUS_IS_OK( hnd->status ) )
+ return CAC_FAILURE;
- if(!cac_InitCacServiceConfig(mem_ctx, &config_out, &op->out.config)) {
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
- }
+ if ( !cac_InitCacServiceConfig
+ ( mem_ctx, &config_out, &op->out.config ) ) {
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
- return CAC_SUCCESS;
+ return CAC_SUCCESS;
}