summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/utils/net_rpc_service.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c
index 789afe234f..74848b23a4 100644
--- a/source3/utils/net_rpc_service.c
+++ b/source3/utils/net_rpc_service.c
@@ -35,13 +35,17 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd,
POLICY_HND hService;
SERVICE_STATUS service_status;
WERROR result = WERR_GENERAL_FAILURE;
+ NTSTATUS status;
/* now cycle until the status is actually 'watch_state' */
- result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, hSCM, &hService,
- service, SC_RIGHT_SVC_QUERY_STATUS );
-
- if ( !W_ERROR_IS_OK(result) ) {
+ status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx,
+ hSCM,
+ service,
+ SC_RIGHT_SVC_QUERY_STATUS,
+ &hService,
+ &result);
+ if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result));
return result;
}
@@ -103,15 +107,20 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd,
{
POLICY_HND hService;
WERROR result = WERR_GENERAL_FAILURE;
+ NTSTATUS status;
SERVICE_STATUS service_status;
uint32 state = 0;
/* Open the Service */
- result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, hSCM, &hService,
- service, (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE) );
+ status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx,
+ hSCM,
+ service,
+ (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE),
+ &hService,
+ &result);
- if ( !W_ERROR_IS_OK(result) ) {
+ if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result));
goto done;
}
@@ -216,7 +225,6 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
POLICY_HND hSCM, hService;
WERROR result = WERR_GENERAL_FAILURE;
NTSTATUS status;
- fstring servicename;
SERVICE_STATUS service_status;
SERVICE_CONFIG config;
fstring ascii_string;
@@ -227,8 +235,6 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
return NT_STATUS_OK;
}
- fstrcpy( servicename, argv[0] );
-
/* Open the Service Control Manager */
CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
NT_STATUS_HAVE_NO_MEMORY(server_name);
@@ -246,10 +252,14 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
/* Open the Service */
- result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService, servicename,
- (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG) );
+ status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx,
+ &hSCM,
+ argv[0],
+ (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG),
+ &hService,
+ &result);
- if ( !W_ERROR_IS_OK(result) ) {
+ if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result));
goto done;
}
@@ -262,7 +272,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
goto done;
}
- d_printf("%s service is %s.\n", servicename, svc_status_string(service_status.state));
+ d_printf("%s service is %s.\n", argv[0], svc_status_string(service_status.state));
/* get the config */
@@ -468,7 +478,6 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
POLICY_HND hSCM, hService;
WERROR result = WERR_GENERAL_FAILURE;
NTSTATUS status;
- fstring servicename;
uint32 state = 0;
const char *server_name;
@@ -477,8 +486,6 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
return NT_STATUS_OK;
}
- fstrcpy( servicename, argv[0] );
-
/* Open the Service Control Manager */
CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
NT_STATUS_HAVE_NO_MEMORY(server_name);
@@ -496,10 +503,14 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
/* Open the Service */
- result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService,
- servicename, SC_RIGHT_SVC_START );
+ status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx,
+ &hSCM,
+ argv[0],
+ SC_RIGHT_SVC_START,
+ &hService,
+ &result);
- if ( !W_ERROR_IS_OK(result) ) {
+ if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result));
goto done;
}
@@ -512,12 +523,12 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
goto done;
}
- result = watch_service_state(pipe_hnd, mem_ctx, &hSCM, servicename, SVCCTL_RUNNING, &state );
+ result = watch_service_state(pipe_hnd, mem_ctx, &hSCM, argv[0], SVCCTL_RUNNING, &state );
if ( W_ERROR_IS_OK(result) && (state == SVCCTL_RUNNING) )
- d_printf("Successfully started service: %s\n", servicename );
+ d_printf("Successfully started service: %s\n", argv[0] );
else
- d_fprintf(stderr, "Failed to start service: %s [%s]\n", servicename, dos_errstr(result) );
+ d_fprintf(stderr, "Failed to start service: %s [%s]\n", argv[0], dos_errstr(result) );
done:
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL);