1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

r23271: merge service control pidl change for CloseServiceHandle() from SAMBA_3_0_26

(This used to be commit 0b1bc3521fac52f3164b6cc9e053abc3ceabf5e7)
This commit is contained in:
Gerald Carter 2007-05-31 17:24:30 +00:00 committed by Gerald (Jerry) Carter
parent eec5e026ad
commit d99f4f004c
9 changed files with 307 additions and 113 deletions

View File

@ -349,7 +349,7 @@ LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \
LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_unixinfo.o librpc/gen_ndr/cli_lsa.o \
librpc/gen_ndr/cli_dfs.o librpc/gen_ndr/cli_echo.o \
librpc/gen_ndr/cli_srvsvc.o \
librpc/gen_ndr/cli_srvsvc.o librpc/gen_ndr/cli_svcctl.o \
librpc/gen_ndr/cli_winreg.o librpc/gen_ndr/cli_initshutdown.o \
librpc/gen_ndr/cli_eventlog.o librpc/gen_ndr/cli_epmapper.o \
$(LIBNDR_GEN_OBJ) $(RPCCLIENT_NDR_OBJ)
@ -384,6 +384,7 @@ RPC_SVC_OBJ = librpc/gen_ndr/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o
RPC_WKS_OBJ = librpc/gen_ndr/srv_wkssvc.o rpc_server/srv_wkssvc_nt.o
RPC_SVCCTL_OBJ = rpc_server/srv_svcctl.o rpc_server/srv_svcctl_nt.o \
librpc/gen_ndr/srv_svcctl.o \
services/svc_spoolss.o services/svc_rcinit.o services/services_db.o \
services/svc_netlogon.o services/svc_winreg.o \
services/svc_wins.o
@ -399,7 +400,7 @@ RPC_EVENTLOG_OBJ = rpc_server/srv_eventlog.o rpc_server/srv_eventlog_nt.o rpc_se
RPC_PIPE_OBJ = rpc_server/srv_pipe_hnd.o \
rpc_server/srv_pipe.o rpc_server/srv_lsa_hnd.o
RPC_ECHO_OBJ = librpc/gen_ndr/srv_echo.o rpc_server/srv_echo_nt.o
RPC_ECHO_OBJ = rpc_server/srv_echo_nt.o librpc/gen_ndr/srv_echo.o
RPC_SERVER_OBJ = @RPC_STATIC@ $(RPC_PIPE_OBJ)

View File

@ -687,8 +687,6 @@ typedef int BOOL;
#include "rpc_ds.h"
#include "rpc_perfcount.h"
#include "rpc_perfcount_defs.h"
#include "librpc/gen_ndr/srvsvc.h"
#include "librpc/gen_ndr/echo.h"
#include "librpc/gen_ndr/notify.h"
#include "nt_printing.h"
#include "idmap.h"
@ -782,6 +780,8 @@ enum flush_reason_enum {
/* generated rpc server implementation functions */
#include "librpc/gen_ndr/srv_echo.h"
#include "librpc/gen_ndr/srv_svcctl.h"
#include "librpc/gen_ndr/srv_lsa.h"
/***** automatically generated prototypes *****/
#ifndef NO_PROTO_H

View File

@ -313,6 +313,8 @@ struct id_map {
#include "librpc/gen_ndr/eventlog.h"
#include "librpc/gen_ndr/srvsvc.h"
#include "librpc/gen_ndr/wkssvc.h"
#include "librpc/gen_ndr/echo.h"
#include "librpc/gen_ndr/svcctl.h"
struct lsa_dom_info {
BOOL valid;

View File

@ -91,7 +91,6 @@ int cac_SvcClose( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
POLICY_HND * scm_hnd )
{
struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if ( !hnd )
return CAC_FAILURE;
@ -112,8 +111,7 @@ int cac_SvcClose( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
return CAC_FAILURE;
}
err = rpccli_svcctl_close_service( pipe_hnd, mem_ctx, scm_hnd );
hnd->status = werror_to_ntstatus( err );
hnd->status = rpccli_svcctl_CloseServiceHandle( pipe_hnd, mem_ctx, scm_hnd );
if ( !NT_STATUS_IS_OK( hnd->status ) )
return CAC_FAILURE;

View File

@ -133,30 +133,6 @@ WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_
return out.status;
}
/********************************************************************
********************************************************************/
WERROR rpccli_svcctl_close_service(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService )
{
SVCCTL_Q_CLOSE_SERVICE in;
SVCCTL_R_CLOSE_SERVICE out;
prs_struct qbuf, rbuf;
ZERO_STRUCT(in);
ZERO_STRUCT(out);
memcpy( &in.handle, hService, sizeof(POLICY_HND) );
CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_CLOSE_SERVICE,
in, out,
qbuf, rbuf,
svcctl_io_q_close_service,
svcctl_io_r_close_service,
WERR_GENERAL_FAILURE );
return out.status;
}
/*******************************************************************
*******************************************************************/

View File

@ -196,53 +196,6 @@ uint32 svcctl_sizeof_service_config( SERVICE_CONFIG *config )
return size;
}
/*******************************************************************
********************************************************************/
BOOL svcctl_io_q_close_service(const char *desc, SVCCTL_Q_CLOSE_SERVICE *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL)
return False;
prs_debug(ps, depth, desc, "svcctl_io_q_close_service");
depth++;
if(!prs_align(ps))
return False;
if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth))
return False;
return True;
}
/*******************************************************************
********************************************************************/
BOOL svcctl_io_r_close_service(const char *desc, SVCCTL_R_CLOSE_SERVICE *r_u, prs_struct *ps, int depth)
{
if (r_u == NULL)
return False;
prs_debug(ps, depth, desc, "svcctl_io_r_close_service");
depth++;
if(!prs_align(ps))
return False;
if(!smb_io_pol_hnd("pol_handle", &r_u->handle, ps, depth))
return False;
if(!prs_werror("status", ps, depth, &r_u->status))
return False;
return True;
}
/*******************************************************************
********************************************************************/

View File

@ -1,7 +1,7 @@
/*
* Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
* Copyright (C) Gerald Carter 2005.
* Copyright (C) Gerald Carter 2005 - 2007
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,28 +23,30 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
static BOOL proxy_svcctl_call(pipes_struct *p, uint8 opnum)
{
struct api_struct *fns;
int n_fns;
svcctl_get_pipe_fns(&fns, &n_fns);
if (opnum >= n_fns)
return False;
if (fns[opnum].opnum != opnum) {
smb_panic("SVCCTL function table not sorted\n");
}
return fns[opnum].fn(p);
}
/*******************************************************************
********************************************************************/
static BOOL api_svcctl_close_service(pipes_struct *p)
{
SVCCTL_Q_CLOSE_SERVICE q_u;
SVCCTL_R_CLOSE_SERVICE r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
if(!svcctl_io_q_close_service("", &q_u, data, 0))
return False;
r_u.status = _svcctl_close_service(p, &q_u, &r_u);
if(!svcctl_io_r_close_service("", &r_u, rdata, 0))
return False;
return True;
return proxy_svcctl_call( p, DCERPC_SVCCTL_CLOSESERVICEHANDLE );
}
/*******************************************************************
@ -432,14 +434,15 @@ static struct api_struct api_svcctl_cmds[] =
};
void svcctl_get_pipe_fns( struct api_struct **fns, int *n_fns )
void svcctl2_get_pipe_fns( struct api_struct **fns, int *n_fns )
{
*fns = api_svcctl_cmds;
*fns = api_svcctl_cmds;
*n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct);
}
NTSTATUS rpc_svcctl_init(void)
NTSTATUS rpc_svcctl2_init(void)
{
return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "svcctl", "ntsvcs", api_svcctl_cmds,
sizeof(api_svcctl_cmds) / sizeof(struct api_struct));
return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
"svcctl", "ntsvcs", api_svcctl_cmds,
sizeof(api_svcctl_cmds) / sizeof(struct api_struct));
}

View File

@ -318,9 +318,12 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_
/********************************************************************
********************************************************************/
WERROR _svcctl_close_service(pipes_struct *p, SVCCTL_Q_CLOSE_SERVICE *q_u, SVCCTL_R_CLOSE_SERVICE *r_u)
WERROR _svcctl_CloseServiceHandle(pipes_struct *p, struct svcctl_CloseServiceHandle *r)
{
return close_policy_hnd( p, &q_u->handle ) ? WERR_OK : WERR_BADFID;
if ( !close_policy_hnd( p, r->in.handle ) )
return WERR_BADFID;
return WERR_OK;
}
/********************************************************************
@ -871,3 +874,261 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u,
}
WERROR _svcctl_ControlService(pipes_struct *p, struct svcctl_ControlService *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_LockServiceDatabase(pipes_struct *p, struct svcctl_LockServiceDatabase *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, struct svcctl_QueryServiceObjectSecurity *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServiceObjectSecurity *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceStatus(pipes_struct *p, struct svcctl_QueryServiceStatus *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, struct svcctl_UnlockServiceDatabase *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_NotifyBootConfigStatus(pipes_struct *p, struct svcctl_NotifyBootConfigStatus *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_SCSetServiceBitsW(pipes_struct *p, struct svcctl_SCSetServiceBitsW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_ChangeServiceConfigW(pipes_struct *p, struct svcctl_ChangeServiceConfigW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_CreateServiceW(pipes_struct *p, struct svcctl_CreateServiceW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_EnumDependentServicesW(pipes_struct *p, struct svcctl_EnumDependentServicesW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesStatusW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_OpenSCManagerW(pipes_struct *p, struct svcctl_OpenSCManagerW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_OpenServiceW(pipes_struct *p, struct svcctl_OpenServiceW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceConfigW(pipes_struct *p, struct svcctl_QueryServiceConfigW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceLockStatusW(pipes_struct *p, struct svcctl_QueryServiceLockStatusW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_StartServiceW(pipes_struct *p, struct svcctl_StartServiceW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, struct svcctl_GetServiceDisplayNameW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_GetServiceKeyNameW(pipes_struct *p, struct svcctl_GetServiceKeyNameW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_SCSetServiceBitsA(pipes_struct *p, struct svcctl_SCSetServiceBitsA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_ChangeServiceConfigA(pipes_struct *p, struct svcctl_ChangeServiceConfigA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_CreateServiceA(pipes_struct *p, struct svcctl_CreateServiceA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_EnumDependentServicesA(pipes_struct *p, struct svcctl_EnumDependentServicesA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_EnumServicesStatusA(pipes_struct *p, struct svcctl_EnumServicesStatusA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_OpenSCManagerA(pipes_struct *p, struct svcctl_OpenSCManagerA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_OpenServiceA(pipes_struct *p, struct svcctl_OpenServiceA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceConfigA(pipes_struct *p, struct svcctl_QueryServiceConfigA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceLockStatusA(pipes_struct *p, struct svcctl_QueryServiceLockStatusA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_StartServiceA(pipes_struct *p, struct svcctl_StartServiceA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_GetServiceDisplayNameA(pipes_struct *p, struct svcctl_GetServiceDisplayNameA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_GetServiceKeyNameA(pipes_struct *p, struct svcctl_GetServiceKeyNameA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_GetCurrentGroupeStateW(pipes_struct *p, struct svcctl_GetCurrentGroupeStateW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_EnumServiceGroupW(pipes_struct *p, struct svcctl_EnumServiceGroupW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_ChangeServiceConfig2A(pipes_struct *p, struct svcctl_ChangeServiceConfig2A *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_ChangeServiceConfig2W(pipes_struct *p, struct svcctl_ChangeServiceConfig2W *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceConfig2A(pipes_struct *p, struct svcctl_QueryServiceConfig2A *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceConfig2W(pipes_struct *p, struct svcctl_QueryServiceConfig2W *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_QueryServiceStatusEx(pipes_struct *p, struct svcctl_QueryServiceStatusEx *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _EnumServicesStatusExA(pipes_struct *p, struct EnumServicesStatusExA *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _EnumServicesStatusExW(pipes_struct *p, struct EnumServicesStatusExW *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}
WERROR _svcctl_SCSendTSMessage(pipes_struct *p, struct svcctl_SCSendTSMessage *r)
{
p->rng_fault_state = True;
return WERR_NOT_SUPPORTED;
}

View File

@ -49,7 +49,7 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd,
*state = service_status.state;
}
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hService );
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService);
return result;
}
@ -131,7 +131,7 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd,
d_printf("%s service is %s.\n", service, svc_status_string(state));
done:
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hService );
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService);
return result;
}
@ -185,7 +185,7 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid,
}
done:
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM );
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM);
return werror_to_ntstatus(result);
}
@ -286,8 +286,8 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
}
done:
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hService );
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM );
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService);
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM);
return werror_to_ntstatus(result);
}
@ -325,7 +325,7 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid,
result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
SVCCTL_CONTROL_STOP, SVCCTL_STOPPED );
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM );
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM);
return werror_to_ntstatus(result);
}
@ -363,7 +363,7 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid,
result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
SVCCTL_CONTROL_PAUSE, SVCCTL_PAUSED );
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM );
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM);
return werror_to_ntstatus(result);
}
@ -401,7 +401,7 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid,
result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
SVCCTL_CONTROL_CONTINUE, SVCCTL_RUNNING );
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM );
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM);
return werror_to_ntstatus(result);
}
@ -463,8 +463,8 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
d_fprintf(stderr, "Failed to start service: %s [%s]\n", servicename, dos_errstr(result) );
done:
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hService );
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hSCM );
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService);
rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM);
return werror_to_ntstatus(result);
}