1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

r12173: doing some service control work

* Add a few new error codes for disabled services
* dump some more details about service status in 'net rpc service'
* disable the WINS and NetLogon services if not configured in smb.conf

Still trying to figure out how to disable the start button
on the NetLogon and WINS services.
This commit is contained in:
Gerald Carter 2005-12-11 04:21:34 +00:00 committed by Gerald (Jerry) Carter
parent 8b30cf8e09
commit c0f54eeebc
7 changed files with 65 additions and 34 deletions

View File

@ -196,6 +196,8 @@
#define WERR_REG_FILE_INVALID W_ERROR(1017)
#define WERR_NO_SUCH_SERVICE W_ERROR(1060)
#define WERR_INVALID_SERVICE_CONTROL W_ERROR(1052)
#define WERR_SERVICE_DISABLED W_ERROR(1058)
#define WERR_SERVICE_NEVER_STARTED W_ERROR(1077)
#define WERR_MACHINE_LOCKED W_ERROR(1271)
#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338)
#define WERR_EVENTLOG_FILE_CORRUPT W_ERROR(1500)

View File

@ -69,6 +69,7 @@
/* SERVER_STATUS - ControlAccepted */
#define SVCCTL_ACCEPT_NONE 0x00000000
#define SVCCTL_ACCEPT_STOP 0x00000001
#define SVCCTL_ACCEPT_PAUSE_CONTINUE 0x00000002
#define SVCCTL_ACCEPT_SHUTDOWN 0x00000004
@ -126,7 +127,7 @@ typedef struct {
uint32 type;
uint32 state;
uint32 controls_accepted;
uint32 win32_exit_code;
WERROR win32_exit_code;
uint32 service_exit_code;
uint32 check_point;
uint32 wait_hint;

View File

@ -76,6 +76,7 @@ werror_code_struct dos_errs[] =
{ "WERR_REG_CORRUPT", WERR_REG_CORRUPT },
{ "WERR_REG_IO_FAILURE", WERR_REG_IO_FAILURE },
{ "WERR_REG_FILE_INVALID", WERR_REG_FILE_INVALID },
{ "WERR_SERVICE_DISABLED", WERR_SERVICE_DISABLED },
{ NULL, W_ERROR(0) }
};

View File

@ -615,9 +615,20 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG
config->tag_id = 0x00000000; /* unassigned loadorder group */
config->service_type = SVCCTL_WIN32_OWN_PROC;
config->start_type = SVCCTL_DEMAND_START;
config->error_control = SVCCTL_SVC_ERROR_NORMAL;
/* set the start type. NetLogon and WINS are disabled to prevent
the client from showing the "Start" button (if of course the services
are not running */
if ( strequal( name, "NETLOGON" ) && ( lp_servicenumber(name) == -1 ) )
config->start_type = SVCCTL_DISABLED;
else if ( strequal( name, "WINS" ) && ( !lp_wins_support() ))
config->start_type = SVCCTL_DISABLED;
else
config->start_type = SVCCTL_DEMAND_START;
TALLOC_FREE( values );
return WERR_OK;

View File

@ -25,8 +25,30 @@
/*********************************************************************
*********************************************************************/
static WERROR netlogon_status( const char *service, SERVICE_STATUS *service_status )
{
ZERO_STRUCTP( service_status );
service_status->type = 0x20;
service_status->controls_accepted = SVCCTL_ACCEPT_NONE;
if ( lp_servicenumber("NETLOGON") != -1 ) {
service_status->state = SVCCTL_RUNNING;
service_status->win32_exit_code = WERR_SERVICE_NEVER_STARTED;
}
else
service_status->state = SVCCTL_STOPPED;
return WERR_OK;
}
/*********************************************************************
*********************************************************************/
static WERROR netlogon_stop( const char *service, SERVICE_STATUS *service_status )
{
netlogon_status( service, service_status );
return WERR_ACCESS_DENIED;
}
@ -35,28 +57,15 @@ static WERROR netlogon_stop( const char *service, SERVICE_STATUS *service_status
static WERROR netlogon_start( const char *service )
{
if ( lp_servicenumber("NETLOGON") == -1 )
return WERR_SERVICE_DISABLED;
return WERR_ACCESS_DENIED;
}
/*********************************************************************
*********************************************************************/
static WERROR netlogon_status( const char *service, SERVICE_STATUS *service_status )
{
ZERO_STRUCTP( service_status );
service_status->type = 0x20;
if ( lp_servicenumber("NETLOGON") != -1 )
service_status->state = SVCCTL_RUNNING;
else
service_status->state = SVCCTL_STOPPED;
return WERR_OK;
}
/*********************************************************************
*********************************************************************/
/* struct for svcctl control to manipulate netlogon service */
SERVICE_CONTROL_OPS netlogon_svc_ops = {

View File

@ -25,8 +25,30 @@
/*********************************************************************
*********************************************************************/
static WERROR wins_status( const char *service, SERVICE_STATUS *service_status )
{
ZERO_STRUCTP( service_status );
service_status->type = 0x10;
service_status->controls_accepted = SVCCTL_ACCEPT_NONE;
if ( lp_wins_support() )
service_status->state = SVCCTL_RUNNING;
else {
service_status->state = SVCCTL_STOPPED;
service_status->win32_exit_code = WERR_SERVICE_NEVER_STARTED;
}
return WERR_OK;
}
/*********************************************************************
*********************************************************************/
static WERROR wins_stop( const char *service, SERVICE_STATUS *service_status )
{
wins_status( service, service_status );
return WERR_ACCESS_DENIED;
}
@ -41,22 +63,6 @@ static WERROR wins_start( const char *service )
/*********************************************************************
*********************************************************************/
static WERROR wins_status( const char *service, SERVICE_STATUS *service_status )
{
ZERO_STRUCTP( service_status );
service_status->type = 0x10;
if ( lp_wins_support() )
service_status->state = SVCCTL_RUNNING;
else
service_status->state = SVCCTL_STOPPED;
return WERR_OK;
}
/*********************************************************************
*********************************************************************/
/* struct for svcctl control to manipulate wins service */
SERVICE_CONTROL_OPS wins_svc_ops = {

View File

@ -254,6 +254,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
/* print out the configuration information for the service */
d_printf("Configuration details:\n");
d_printf("\tControls Accepted = 0x%x\n", service_status.controls_accepted);
d_printf("\tService Type = 0x%x\n", config.service_type);
d_printf("\tStart Type = 0x%x\n", config.start_type);
d_printf("\tError Control = 0x%x\n", config.error_control);