From ee7a16624ecc9ef5ff9845a002f10add78ed7fee Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jun 2005 15:18:18 +0000 Subject: [PATCH] r7610: can successfully stop and start the 'spooler' service by setting the state for the 'disable spoolss' parameter in memory for an individual smbd --- source/include/rpc_svcctl.h | 1 + source/param/loadparm.c | 28 ++++++++++++++- source/rpc_server/srv_svcctl_nt.c | 74 ++++----------------------------------- source/services/svc_spoolss.c | 21 +++++++++++ 4 files changed, 56 insertions(+), 68 deletions(-) diff --git a/source/include/rpc_svcctl.h b/source/include/rpc_svcctl.h index 8ce2cbe404e..77dd004fed4 100644 --- a/source/include/rpc_svcctl.h +++ b/source/include/rpc_svcctl.h @@ -55,6 +55,7 @@ /* SERVER_STATUS - CurrentState */ +#define SVCCTL_STATE_UNKNOWN 0x00000000 /* only used internally to smbd */ #define SVCCTL_STOPPED 0x00000001 #define SVCCTL_START_PENDING 0x00000002 #define SVCCTL_STOP_PENDING 0x00000003 diff --git a/source/param/loadparm.c b/source/param/loadparm.c index bfd7b650cbe..0083b508208 100644 --- a/source/param/loadparm.c +++ b/source/param/loadparm.c @@ -1860,7 +1860,7 @@ FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security) FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize) FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime) FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses) -FN_GLOBAL_INTEGER(lp_disable_spoolss, &Globals.bDisableSpoolss) +FN_GLOBAL_INTEGER(_lp_disable_spoolss, &Globals.bDisableSpoolss) FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog) static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as) FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce) @@ -4466,6 +4466,32 @@ const char *lp_printcapname(void) Ensure we don't use sendfile if server smb signing is active. ********************************************************************/ +static uint32 spoolss_state; + +BOOL lp_disable_spoolss( void ) +{ + if ( spoolss_state == SVCCTL_STATE_UNKNOWN ) + spoolss_state = _lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING; + + return spoolss_state == SVCCTL_STOPPED ? True : False; +} + +void lp_set_spoolss_state( uint32 state ) +{ + SMB_ASSERT( (state == SVCCTL_STOPPED) || (state == SVCCTL_RUNNING) ); + + spoolss_state = state; +} + +uint32 lp_get_spoolss_state( void ) +{ + return lp_disable_spoolss() ? SVCCTL_STOPPED : SVCCTL_RUNNING; +} + +/******************************************************************* + Ensure we don't use sendfile if server smb signing is active. +********************************************************************/ + BOOL lp_use_sendfile(int snum) { /* Using sendfile blows the brains out of any DOS or Win9x TCP stack... JRA. */ diff --git a/source/rpc_server/srv_svcctl_nt.c b/source/rpc_server/srv_svcctl_nt.c index c5570368000..230a222b8d5 100644 --- a/source/rpc_server/srv_svcctl_nt.c +++ b/source/rpc_server/srv_svcctl_nt.c @@ -318,6 +318,13 @@ WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_ if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; + /* try the service specific status call */ + + if ( info->ops ) + return info->ops->service_status( &r_u->svc_status ); + + /* default action for now */ + r_u->svc_status.type = 0x0020; r_u->svc_status.state = 0x0004; r_u->svc_status.controls_accepted = 0x0005; @@ -497,8 +504,6 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT return WERR_ACCESS_DENIED; return info->ops->start_service(); - - return WERR_OK; } /******************************************************************** @@ -521,71 +526,6 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S return WERR_ACCESS_DENIED; return info->ops->stop_service( &r_u->svc_status ); - -#if 0 - SERVICE_INFO *service_info; - POLICY_HND *handle; - pstring command; - SERVICE_STATUS *service_status; - int ret,fd; - - /* need to find the service name by the handle that is open */ - handle = &(q_u->handle); - - service_info = find_service_info_by_hnd(p, handle); - - if (!service_info) { - DEBUG(10, ("_svcctl_control_service : Can't find the service for the handle\n")); - return WERR_BADFID; - } - - /* we return a SERVICE_STATUS structure if there's an error. */ - if ( !(service_status = TALLOC_ARRAY(p->mem_ctx, SERVICE_STATUS, 1 )) ) - return WERR_NOMEM; - - DEBUG(10, ("_svcctl_control_service: Found service [%s], [%s]\n", - service_info->servicename, service_info->filename)); - - /* TODO - call the service config function here... */ - memset(command, 0, sizeof(command)); - if (q_u->control == SVCCTL_CONTROL_STOP) { - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, - service_info->filename, "stop"); - } - - if (q_u->control == SVCCTL_CONTROL_PAUSE) { - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, - service_info->filename, "stop"); - } - - if (q_u->control == SVCCTL_CONTROL_CONTINUE) { - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, - service_info->filename, "restart"); - } - - DEBUG(10, ("_svcctl_control_service: status command is [%s]\n", command)); - - /* TODO - wrap in privilege check */ - - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - close(fd); - - if(ret != 0) - DEBUG(10, ("enum_external_services: Command returned [%d]\n", ret)); - - /* SET all service_stats bits here...*/ - if (ret == 0) { - service_status->state = SVCCTL_RUNNING; - service_status->controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; - } else { - service_status->state = SVCCTL_STOPPED; - service_status->controls_accepted = 0; - } - - DEBUG(10, ("_svcctl_query_service_config: Should call the commFound service [%s], [%s]\n",service_info->servicename,service_info->filename)); - -#endif } /******************************************************************** diff --git a/source/services/svc_spoolss.c b/source/services/svc_spoolss.c index bd2f7173f19..5f8fa73ced4 100644 --- a/source/services/svc_spoolss.c +++ b/source/services/svc_spoolss.c @@ -27,6 +27,16 @@ static WERROR spoolss_stop( SERVICE_STATUS *service_status ) { + ZERO_STRUCTP( service_status ); + + lp_set_spoolss_state( SVCCTL_STOPPED ); + + service_status->type = 0x110; + service_status->state = SVCCTL_STOPPED; + service_status->controls_accepted = SVCCTL_ACCEPT_STOP; + + DEBUG(6,("spoolss_stop: spooler stopped (not really)\n")); + return WERR_OK; } @@ -35,6 +45,13 @@ static WERROR spoolss_stop( SERVICE_STATUS *service_status ) static WERROR spoolss_start( void ) { + /* see if the smb.conf will support this anyways */ + + if ( _lp_disable_spoolss() ) + return WERR_ACCESS_DENIED; + + lp_set_spoolss_state( SVCCTL_RUNNING ); + return WERR_OK; } @@ -43,6 +60,10 @@ static WERROR spoolss_start( void ) static WERROR spoolss_status( SERVICE_STATUS *service_status ) { + service_status->type = 0x110; + service_status->state = lp_get_spoolss_state(); + service_status->controls_accepted = SVCCTL_ACCEPT_STOP; + return WERR_OK; } -- 2.11.4.GIT