/********************************************************************
********************************************************************/
+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,
return NT_STATUS_OK;
}
- status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- nt_errstr(status));
- return status;
- }
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
return werror_to_ntstatus(result);
}
}
/* Open the Service Control Manager */
- status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- nt_errstr(status));
- return status;
- }
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(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;
fstrcpy( servicename, argv[0] );
/* Open the Service Control Manager */
- status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- nt_errstr(status));
- return status;
- }
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(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;
fstrcpy( servicename, argv[0] );
/* Open the Service Control Manager */
- status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- nt_errstr(status));
- return status;
- }
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(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;
fstrcpy( servicename, argv[0] );
/* Open the Service Control Manager */
- status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- nt_errstr(status));
- return status;
- }
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
return werror_to_ntstatus(result);
}
}
/* Open the Service Control Manager */
- status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- nt_errstr(status));
- return status;
- }
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
return werror_to_ntstatus(result);
}
ZERO_STRUCT(hService);
/* Open the Service Control Manager */
- status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_ENUMERATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- nt_errstr(status));
- return status;
- }
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_ENUMERATE_SERVICE,
+ &hSCM);
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
return werror_to_ntstatus(result);
}
ZERO_STRUCT(hService);
/* Open the Service Control Manager */
- status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
- pipe_hnd->srv_name_slash,
- NULL,
- SC_RIGHT_MGR_CREATE_SERVICE,
- &hSCM,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- nt_errstr(status));
- return status;
- }
+ result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
+ SC_RIGHT_MGR_CREATE_SERVICE,
+ &hSCM);
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr,
- _("Failed to open Service Control Manager. [%s]\n"),
- win_errstr(result));
return werror_to_ntstatus(result);
}