#include "includes.h"
#include "utils/net.h"
-#include "../librpc/gen_ndr/cli_svcctl.h"
+#include "rpc_client/rpc_client.h"
+#include "../librpc/gen_ndr/ndr_svcctl.h"
+#include "../librpc/gen_ndr/ndr_svcctl_c.h"
struct svc_state_msg {
uint32 flag;
/********************************************************************
********************************************************************/
+static WERROR open_service(struct dcerpc_binding_handle *b,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *hSCM,
+ const char *service,
+ uint32_t access_mask,
+ struct policy_handle *hService)
+{
+ NTSTATUS status;
+ WERROR result;
+
+ status = dcerpc_svcctl_OpenServiceW(b, mem_ctx,
+ hSCM,
+ service,
+ access_mask,
+ hService,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ d_fprintf(stderr, _("Failed to open service. [%s]\n"),
+ nt_errstr(status));
+ return result;
+ }
+ if (!W_ERROR_IS_OK(result) ) {
+ d_fprintf(stderr, _("Failed to open service. [%s]\n"),
+ win_errstr(result));
+ return result;
+ }
+
+ return WERR_OK;
+}
+
+/********************************************************************
+********************************************************************/
+
+static WERROR open_scm(struct dcerpc_binding_handle *b,
+ TALLOC_CTX *mem_ctx,
+ const char *server_name,
+ uint32_t access_mask,
+ struct policy_handle *hSCM)
+{
+ NTSTATUS status;
+ WERROR result;
+
+ status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
+ server_name,
+ NULL,
+ access_mask,
+ hSCM,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ d_fprintf(stderr,
+ _("Failed to open Service Control Manager. [%s]\n"),
+ nt_errstr(status));
+ return result;
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ d_fprintf(stderr,
+ _("Failed to open Service Control Manager. [%s]\n"),
+ win_errstr(result));
+ return result;
+ }
+
+ return WERR_OK;
+}
+
+/********************************************************************
+********************************************************************/
+
static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
struct policy_handle *hSCM,
struct SERVICE_STATUS service_status;
WERROR result = WERR_GENERAL_FAILURE;
NTSTATUS status;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
/* now cycle until the status is actually 'watch_state' */
- 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"),
- win_errstr(result));
+ result = open_service(b, mem_ctx, hSCM, service,
+ SC_RIGHT_SVC_QUERY_STATUS,
+ &hService);
+ if (!W_ERROR_IS_OK(result) ) {
return result;
}
- status = rpccli_svcctl_QueryServiceStatus(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_QueryServiceStatus(b, mem_ctx,
&hService,
&service_status,
&result);
-
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
- *state = service_status.state;
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
}
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL);
+ *state = service_status.state;
+
+ done:
+ if (is_valid_policy_hnd(&hService)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
+ }
return result;
}
d_printf(".");
i++;
- sys_usleep( 100 );
+ usleep( 100 );
}
d_printf("\n");
NTSTATUS status;
struct SERVICE_STATUS service_status;
uint32 state = 0;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
/* Open the Service */
- status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx,
- hSCM,
- service,
- (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE),
- &hService,
- &result);
-
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
- d_fprintf(stderr, _("Failed to open service. [%s]\n"),
- win_errstr(result));
- goto done;
+ result = open_service(b, mem_ctx, hSCM, service,
+ (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE),
+ &hService);
+ if (!W_ERROR_IS_OK(result) ) {
+ return result;
}
/* get the status */
- status = rpccli_svcctl_ControlService(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_ControlService(b, mem_ctx,
&hService,
control,
&service_status,
&result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ d_fprintf(stderr, _("Control service request failed. [%s]\n"),
+ nt_errstr(status));
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, _("Control service request failed. [%s]\n"),
win_errstr(result));
goto done;
d_printf(_("%s service is %s.\n"), service, svc_status_string(state));
done:
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL);
+ if (is_valid_policy_hnd(&hService)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
+ }
return result;
}
WERROR result = WERR_GENERAL_FAILURE;
NTSTATUS status;
int i;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
uint8_t *buffer = NULL;
uint32_t buf_size = 0;
return NT_STATUS_OK;
}
- status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
+ if (!W_ERROR_IS_OK(result)) {
return werror_to_ntstatus(result);
}
do {
- status = rpccli_svcctl_EnumServicesStatusW(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_EnumServicesStatusW(b, mem_ctx,
&hSCM,
SERVICE_TYPE_WIN32,
SERVICE_STATE_ALL,
&resume_handle,
&result);
- if (NT_STATUS_IS_ERR(status)) {
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr,
_("Failed to enumerate services. [%s]\n"),
- win_errstr(result));
+ nt_errstr(status));
break;
}
continue;
}
+ if (!W_ERROR_IS_OK(result)) {
+ status = werror_to_ntstatus(result);
+ d_fprintf(stderr,
+ _("Failed to enumerate services. [%s]\n"),
+ win_errstr(result));
+ break;
+ }
+
if ( num_services == 0 ) {
d_printf(_("No services returned\n"));
break;
} while (W_ERROR_EQUAL(result, WERR_MORE_DATA));
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL);
+ if (is_valid_policy_hnd(&hSCM)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
+ }
return status;
}
struct QUERY_SERVICE_CONFIG config;
uint32_t buf_size = sizeof(config);
uint32_t ret_size = 0;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 1 ) {
d_printf("%s net rpc service status <service>\n", _("Usage:"));
}
/* Open the Service Control Manager */
- status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
+ if (!W_ERROR_IS_OK(result)) {
return werror_to_ntstatus(result);
}
/* Open the Service */
- status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx,
- &hSCM,
- argv[0],
- (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG),
- &hService,
- &result);
-
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
- d_fprintf(stderr, _("Failed to open service. [%s]\n"),
- win_errstr(result));
+ result = open_service(b, mem_ctx, &hSCM, argv[0],
+ (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG),
+ &hService);
+ if (!W_ERROR_IS_OK(result) ) {
goto done;
}
/* get the status */
- status = rpccli_svcctl_QueryServiceStatus(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_QueryServiceStatus(b, mem_ctx,
&hService,
&service_status,
&result);
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ d_fprintf(stderr, _("Query status request failed. [%s]\n"),
+ nt_errstr(status));
+ goto done;
+ }
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
+ if (!W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, _("Query status request failed. [%s]\n"),
win_errstr(result));
goto done;
/* get the config */
- status = rpccli_svcctl_QueryServiceConfigW(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_QueryServiceConfigW(b, mem_ctx,
&hService,
&config,
buf_size,
&ret_size,
&result);
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ d_fprintf(stderr, _("Query config request failed. [%s]\n"),
+ nt_errstr(status));
+ goto done;
+ }
+
if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) {
buf_size = ret_size;
- status = rpccli_svcctl_QueryServiceConfigW(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_QueryServiceConfigW(b, mem_ctx,
&hService,
&config,
buf_size,
&ret_size,
&result);
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ d_fprintf(stderr, _("Query config request failed. [%s]\n"),
+ nt_errstr(status));
+ goto done;
+ }
}
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
+ if (!W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, _("Query config request failed. [%s]\n"),
win_errstr(result));
goto done;
}
done:
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL);
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL);
+ if (is_valid_policy_hnd(&hService)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
+ }
+ if (is_valid_policy_hnd(&hSCM)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
+ }
return werror_to_ntstatus(result);
}
{
struct policy_handle hSCM;
WERROR result = WERR_GENERAL_FAILURE;
- NTSTATUS status;
- fstring servicename;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 1 ) {
d_printf("%s net rpc service status <service>\n", _("Usage:"));
return NT_STATUS_OK;
}
- fstrcpy( servicename, argv[0] );
-
/* Open the Service Control Manager */
- status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
+ if (!W_ERROR_IS_OK(result)) {
return werror_to_ntstatus(result);
}
- result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
+ result = control_service(pipe_hnd, mem_ctx, &hSCM, argv[0],
SVCCTL_CONTROL_STOP, SVCCTL_STOPPED );
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL);
+ if (is_valid_policy_hnd(&hSCM)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
+ }
return werror_to_ntstatus(result);
}
{
struct policy_handle hSCM;
WERROR result = WERR_GENERAL_FAILURE;
- NTSTATUS status;
- fstring servicename;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 1 ) {
d_printf("%s net rpc service status <service>\n", _("Usage:"));
return NT_STATUS_OK;
}
- fstrcpy( servicename, argv[0] );
-
/* Open the Service Control Manager */
- status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
+ if (!W_ERROR_IS_OK(result)) {
return werror_to_ntstatus(result);
}
- result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
+ result = control_service(pipe_hnd, mem_ctx, &hSCM, argv[0],
SVCCTL_CONTROL_PAUSE, SVCCTL_PAUSED );
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL);
+ if (is_valid_policy_hnd(&hSCM)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
+ }
return werror_to_ntstatus(result);
}
{
struct policy_handle hSCM;
WERROR result = WERR_GENERAL_FAILURE;
- NTSTATUS status;
- fstring servicename;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 1 ) {
d_printf("%s net rpc service status <service>\n", _("Usage:"));
return NT_STATUS_OK;
}
- fstrcpy( servicename, argv[0] );
-
/* Open the Service Control Manager */
- status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
+ if (!W_ERROR_IS_OK(result)) {
return werror_to_ntstatus(result);
}
- result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
+ result = control_service(pipe_hnd, mem_ctx, &hSCM, argv[0],
SVCCTL_CONTROL_CONTINUE, SVCCTL_RUNNING );
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL);
+ if (is_valid_policy_hnd(&hSCM)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
+ }
return werror_to_ntstatus(result);
}
WERROR result = WERR_GENERAL_FAILURE;
NTSTATUS status;
uint32 state = 0;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 1 ) {
d_printf("%s net rpc service status <service>\n", _("Usage:"));
}
/* Open the Service Control Manager */
- status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
+ if (!W_ERROR_IS_OK(result)) {
return werror_to_ntstatus(result);
}
- /* Open the Service */
- status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx,
- &hSCM,
- argv[0],
- SC_RIGHT_SVC_START,
- &hService,
- &result);
+ /* Open the Service */
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
- d_fprintf(stderr, _("Failed to open service. [%s]\n"),
- win_errstr(result));
+ result = open_service(b, mem_ctx, &hSCM, argv[0],
+ SC_RIGHT_SVC_START,
+ &hService);
+ if (!W_ERROR_IS_OK(result) ) {
goto done;
}
/* get the status */
- status = rpccli_svcctl_StartServiceW(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_StartServiceW(b, mem_ctx,
&hService,
0,
NULL,
&result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ d_fprintf(stderr, _("Query status request failed. [%s]\n"),
+ nt_errstr(status));
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, _("Query status request failed. [%s]\n"),
win_errstr(result));
goto done;
argv[0], win_errstr(result) );
done:
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL);
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL);
+ if (is_valid_policy_hnd(&hService)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
+ }
+ if (is_valid_policy_hnd(&hSCM)) {
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
+ }
return werror_to_ntstatus(result);
}
struct policy_handle hSCM, hService;
WERROR result = WERR_GENERAL_FAILURE;
NTSTATUS status;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 1 ) {
d_printf("%s net rpc service delete <service>\n", _("Usage:"));
return NT_STATUS_OK;
}
+ ZERO_STRUCT(hSCM);
+ ZERO_STRUCT(hService);
+
/* Open the Service Control Manager */
- status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
+ if (!W_ERROR_IS_OK(result)) {
return werror_to_ntstatus(result);
}
/* Open the Service */
- status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx,
- &hSCM,
- argv[0],
- SERVICE_ALL_ACCESS,
- &hService,
- &result);
-
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
- d_fprintf(stderr, _("Failed to open service. [%s]\n"),
- win_errstr(result));
+ result = open_service(b, mem_ctx, &hSCM, argv[0],
+ SERVICE_ALL_ACCESS,
+ &hService);
+ if (!W_ERROR_IS_OK(result) ) {
goto done;
}
/* Delete the Service */
- status = rpccli_svcctl_DeleteService(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_DeleteService(b, mem_ctx,
&hService,
&result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
+ d_fprintf(stderr, _("Delete service request failed. [%s]\n"),
+ nt_errstr(status));
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(result)) {
d_fprintf(stderr, _("Delete service request failed. [%s]\n"),
win_errstr(result));
goto done;
done:
if (is_valid_policy_hnd(&hService)) {
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL);
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
}
if (is_valid_policy_hnd(&hSCM)) {
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL);
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
}
return werror_to_ntstatus(result);
const char *ServiceName;
const char *DisplayName;
const char *binary_path;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 3) {
d_printf("%s net rpc service create <service> "
return NT_STATUS_OK;
}
+ ZERO_STRUCT(hSCM);
+ ZERO_STRUCT(hService);
+
/* Open the Service Control Manager */
- status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_CREATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_CREATE_SERVICE,
+ &hSCM);
+ if (!W_ERROR_IS_OK(result)) {
return werror_to_ntstatus(result);
}
DisplayName = argv[1];
binary_path = argv[2];
- status = rpccli_svcctl_CreateServiceW(pipe_hnd, mem_ctx,
+ status = dcerpc_svcctl_CreateServiceW(b, mem_ctx,
&hSCM,
ServiceName,
DisplayName,
0, /* password_size */
&hService,
&result);
-
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) {
+ if (!NT_STATUS_IS_OK(status)) {
+ result = ntstatus_to_werror(status);
d_fprintf(stderr, _("Create service request failed. [%s]\n"),
- win_errstr(result));
+ nt_errstr(status));
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ d_fprintf(stderr, _("Create service request failed. [%s]\n"),
+ win_errstr(result));
goto done;
}
done:
if (is_valid_policy_hnd(&hService)) {
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL);
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
}
if (is_valid_policy_hnd(&hSCM)) {
- rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL);
+ WERROR _result;
+ dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
}
return werror_to_ntstatus(result);
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
rpc_service_list_internal, argc, argv );
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
rpc_service_start_internal, argc, argv );
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
rpc_service_stop_internal, argc, argv );
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
rpc_service_resume_internal, argc, argv );
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
rpc_service_pause_internal, argc, argv );
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
rpc_service_status_internal, argc, argv );
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
rpc_service_delete_internal, argc, argv);
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
rpc_service_create_internal, argc, argv);
}