summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_rpc_service.c92
1 files changed, 75 insertions, 17 deletions
diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c
index 5ad907e8a6..789afe234f 100644
--- a/source3/utils/net_rpc_service.c
+++ b/source3/utils/net_rpc_service.c
@@ -20,6 +20,9 @@
#include "utils/net.h"
+#define CLI_SERVER_NAME_SLASH(_ctx, _p, _cli) \
+ _p = talloc_asprintf(_ctx, "\\\\%s", _cli->cli->desthost);
+
/********************************************************************
********************************************************************/
@@ -149,9 +152,11 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid,
POLICY_HND hSCM;
ENUM_SERVICES_STATUS *services;
WERROR result = WERR_GENERAL_FAILURE;
+ NTSTATUS status;
fstring servicename;
fstring displayname;
uint32 num_services = 0;
+ const char *server_name;
int i;
if (argc != 0 ) {
@@ -159,8 +164,16 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid,
return NT_STATUS_OK;
}
- result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
- if ( !W_ERROR_IS_OK(result) ) {
+ CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
+ NT_STATUS_HAVE_NO_MEMORY(server_name);
+
+ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
+ server_name,
+ 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", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -202,10 +215,12 @@ 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;
+ const char *server_name;
if (argc != 1 ) {
d_printf("Usage: net rpc service status <service>\n");
@@ -215,9 +230,16 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
fstrcpy( servicename, argv[0] );
/* Open the Service Control Manager */
-
- result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
- if ( !W_ERROR_IS_OK(result) ) {
+ CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
+ NT_STATUS_HAVE_NO_MEMORY(server_name);
+
+ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
+ server_name,
+ 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", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -304,7 +326,9 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid,
{
POLICY_HND hSCM;
WERROR result = WERR_GENERAL_FAILURE;
+ NTSTATUS status;
fstring servicename;
+ const char *server_name;
if (argc != 1 ) {
d_printf("Usage: net rpc service status <service>\n");
@@ -314,9 +338,16 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid,
fstrcpy( servicename, argv[0] );
/* Open the Service Control Manager */
-
- result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
- if ( !W_ERROR_IS_OK(result) ) {
+ CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
+ NT_STATUS_HAVE_NO_MEMORY(server_name);
+
+ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
+ server_name,
+ 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", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -342,7 +373,9 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid,
{
POLICY_HND hSCM;
WERROR result = WERR_GENERAL_FAILURE;
+ NTSTATUS status;
fstring servicename;
+ const char *server_name;
if (argc != 1 ) {
d_printf("Usage: net rpc service status <service>\n");
@@ -352,9 +385,16 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid,
fstrcpy( servicename, argv[0] );
/* Open the Service Control Manager */
-
- result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
- if ( !W_ERROR_IS_OK(result) ) {
+ CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
+ NT_STATUS_HAVE_NO_MEMORY(server_name);
+
+ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
+ server_name,
+ 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", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -380,7 +420,9 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid,
{
POLICY_HND hSCM;
WERROR result = WERR_GENERAL_FAILURE;
+ NTSTATUS status;
fstring servicename;
+ const char *server_name;
if (argc != 1 ) {
d_printf("Usage: net rpc service status <service>\n");
@@ -390,9 +432,16 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid,
fstrcpy( servicename, argv[0] );
/* Open the Service Control Manager */
-
- result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
- if ( !W_ERROR_IS_OK(result) ) {
+ CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
+ NT_STATUS_HAVE_NO_MEMORY(server_name);
+
+ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
+ server_name,
+ 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", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -418,8 +467,10 @@ 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;
if (argc != 1 ) {
d_printf("Usage: net rpc service status <service>\n");
@@ -429,9 +480,16 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
fstrcpy( servicename, argv[0] );
/* Open the Service Control Manager */
-
- result = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
- if ( !W_ERROR_IS_OK(result) ) {
+ CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
+ NT_STATUS_HAVE_NO_MEMORY(server_name);
+
+ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx,
+ server_name,
+ 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", dos_errstr(result));
return werror_to_ntstatus(result);
}