mlsvc_svcctl.c revision 7b59d02d2a384be9a08087b14defadd214b3c1dd
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* NT Service Control Services (SVCCTL) RPC interface definition.
* This interface provides remote access to add, remove, start and
* stop services.
*/
#include <stdio.h>
#include <strings.h>
#include <smbsrv/ntstatus.h>
#include <smbsrv/mlsvc_util.h>
/*
* The handle keys for this interface.
*/
static int svcctl_key_manager;
static int svcctl_key_service;
typedef struct {
char *svc_name;
char *display_name;
char *local_name;
} svc_info_t;
/*
* The list of service we report to Server Manager. Entries don't
* have to be alphabetically arranged here; Server Manager will
* sort the list.
*
* NOTE: The enumeration list is currently built in a fixed-size,
* 1024 byte buffer. Be careful not to over-run the buffer.
*/
static svc_info_t svc_info[] = {
{ "Dhcp", "DHCP Client", "dhcpc" },
{ "WebAdmin", "Web Administration", "httpd" },
{ "RlgnSvr", "Remote Login", "rlogin" },
{ "RshSvr", "Remote Shell", "rsh" },
{ "SshSvr", "Secure Shell", "ssh" },
{ "TlntSvr", "Telnet", "telnet" },
{ "Dnscache", "DNS Client", "dns" },
{ "UPS", "Uninterruptible Power Supply", "ups" },
{ "TftpSvr", "TFTP", "tftp" }
};
static DWORD svcctl_get_status(const char *);
static DWORD svcctl_validate_service(char *);
static int svcctl_is_admin(struct mlrpc_xaction *);
static int svcctl_s_Close(void *, struct mlrpc_xaction *);
static int svcctl_s_OpenManager(void *, struct mlrpc_xaction *);
static int svcctl_s_OpenService(void *, struct mlrpc_xaction *);
static int svcctl_s_QueryServiceStatus(void *, struct mlrpc_xaction *);
static int svcctl_s_QueryServiceConfig(void *, struct mlrpc_xaction *);
static int svcctl_s_EnumServicesStatus(void *, struct mlrpc_xaction *);
static mlrpc_stub_table_t svcctl_stub_table[] = {
{0}
};
static mlrpc_service_t svcctl_service = {
"SVCCTL", /* name */
"Service Control Services", /* desc */
"\\svcctl", /* endpoint */
PIPE_NTSVCS, /* sec_addr_port */
"367abb81-9844-35f1-ad3298f038001003", 2, /* abstract */
"8a885d04-1ceb-11c9-9fe808002b104860", 2, /* transfer */
0, /* no bind_instance_size */
0, /* no bind_req() */
0, /* no unbind_and_close() */
0, /* use generic_call_stub() */
svcctl_stub_table /* stub_table */
};
/*
* svcctl_initialize
*
* This function registers the SVCCTL RPC interface with the RPC runtime
* library. It must be called in order to use either the client side
* or the server side functions.
*/
void
svcctl_initialize(void)
{
(void) mlrpc_register_service(&svcctl_service);
}
/*
* svcctl_s_Close
*
* This is a request to close the SVCCTL interface specified by the
* handle. Free the handle and zero out the result handle for the
* client.
*
* Returns:
* ERROR_SUCCESS
* ERROR_INVALID_HANDLE
*/
static int
{
return (MLRPC_DRC_OK);
}
/*
* svcctl_s_OpenManager
*
* Request to open the service control manager.
* The caller must have administrator rights in order to open this
* interface. We don't support write access.
*
* Returns:
* ERROR_SUCCESS
* ERROR_ACCESS_DENIED
*
* On success, returns a handle for use with subsequent svcctl requests.
*/
static int
{
ndr_hdid_t *id;
int rc;
return (MLRPC_DRC_OK);
}
} else {
}
return (MLRPC_DRC_OK);
}
/*
* svcctl_s_OpenService
*
* Return a handle for use with subsequent svcctl requests.
*
* Returns:
* ERROR_SUCCESS
* ERROR_INVALID_HANDLE
* ERROR_SERVICE_DOES_NOT_EXIST
*/
static int
{
return (MLRPC_DRC_OK);
}
if (status != ERROR_SUCCESS) {
return (MLRPC_DRC_OK);
}
} else {
}
return (MLRPC_DRC_OK);
}
/*
* svcctl_s_QueryServiceStatus
*
* Returns:
* ERROR_SUCCESS
* ERROR_INVALID_HANDLE
*/
static int
{
return (MLRPC_DRC_OK);
}
return (MLRPC_DRC_OK);
}
/*
* svcctl_s_EnumServicesStatus
*
* Enumerate the list of services we support. Currently, this list
* is built in a fixed-size 1024 byte buffer - be careful not to
* over-run the buffer.
*
* Returns:
* ERROR_SUCCESS
* ERROR_INVALID_HANDLE
*/
static int
{
char *name;
int i, namelen;
int offs;
return (MLRPC_DRC_OK);
}
return (MLRPC_DRC_OK);
}
/*LINTED E_BAD_PTR_CAST_ALIGN*/
for (i = 0; i < SVCCTL_NUM_SVCS; i++) {
svc = &service_table[i];
/*LINTED E_BAD_PTR_CAST_ALIGN*/
/*LINTED E_BAD_PTR_CAST_ALIGN*/
if (name)
else
}
param->bytes_needed = 0;
param->resume_handle = 0;
return (MLRPC_DRC_OK);
}
/*
* svcctl_s_QueryServiceConfig
*
* Returns:
* ERROR_SUCCESS
* ERROR_INVALID_HANDLE
*/
static int
{
return (MLRPC_DRC_OK);
}
return (MLRPC_DRC_OK);
}
/*
* Check to see whether or not a service is supported. The check is
* case-insensitive to avoid any naming issues due to the different
* versions of Windows.
*
* Returns:
* ERROR_SUCCESS
* ERROR_SERVICE_DOES_NOT_EXIST
*/
static DWORD
svcctl_validate_service(char *svc_name)
{
int i;
return (ERROR_SERVICE_DOES_NOT_EXIST);
for (i = 0; i < SVCCTL_NUM_SVCS; i++) {
return (ERROR_SUCCESS);
}
return (ERROR_SERVICE_DOES_NOT_EXIST);
}
/*
* Report the service status: SERVICE_PAUSED or SERVICE_RUNNING.
*/
/*ARGSUSED*/
static DWORD
svcctl_get_status(const char *name)
{
return (SERVICE_RUNNING);
}
/*
* SVCCTL access is restricted to administrators: members of
* the Domain Admins or Administrators groups.
*
* Returns 1 if the user has admin rights. Otherwise returns 0.
*/
static int
{
return (0);
}