mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
Use rpccli_svcctl_OpenSCManagerW() in net.
Guenther
This commit is contained in:
parent
1131e914df
commit
275ce92e27
@ -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 */
|
||||
CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
|
||||
NT_STATUS_HAVE_NO_MEMORY(server_name);
|
||||
|
||||
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
|
||||
if ( !W_ERROR_IS_OK(result) ) {
|
||||
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 */
|
||||
CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
|
||||
NT_STATUS_HAVE_NO_MEMORY(server_name);
|
||||
|
||||
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
|
||||
if ( !W_ERROR_IS_OK(result) ) {
|
||||
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 */
|
||||
CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
|
||||
NT_STATUS_HAVE_NO_MEMORY(server_name);
|
||||
|
||||
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
|
||||
if ( !W_ERROR_IS_OK(result) ) {
|
||||
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 */
|
||||
CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
|
||||
NT_STATUS_HAVE_NO_MEMORY(server_name);
|
||||
|
||||
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
|
||||
if ( !W_ERROR_IS_OK(result) ) {
|
||||
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 */
|
||||
CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd);
|
||||
NT_STATUS_HAVE_NO_MEMORY(server_name);
|
||||
|
||||
result = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
|
||||
if ( !W_ERROR_IS_OK(result) ) {
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user