summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-06-15 15:18:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:57:16 -0500
commit5b678f7a8469e345a6b25fa19ea1a20fce939a21 (patch)
tree6699c3a948622073982cf78897c2f011be5e7d84
parent7cbd740c62238406e64819e3594caeca341a25c9 (diff)
downloadsamba-5b678f7a8469e345a6b25fa19ea1a20fce939a21.tar.gz
samba-5b678f7a8469e345a6b25fa19ea1a20fce939a21.tar.bz2
samba-5b678f7a8469e345a6b25fa19ea1a20fce939a21.zip
r7610: can successfully stop and start the 'spooler' service by setting the state for the 'disable spoolss' parameter in memory for an individual smbd
(This used to be commit f19c10d0c3e7701066b765c712df0636e914bf7e)
-rw-r--r--source3/include/rpc_svcctl.h1
-rw-r--r--source3/param/loadparm.c28
-rw-r--r--source3/rpc_server/srv_svcctl_nt.c74
-rw-r--r--source3/services/svc_spoolss.c21
4 files changed, 56 insertions, 68 deletions
diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h
index 8ce2cbe404..77dd004fed 100644
--- a/source3/include/rpc_svcctl.h
+++ b/source3/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/source3/param/loadparm.c b/source3/param/loadparm.c
index bfd7b650cb..0083b50820 100644
--- a/source3/param/loadparm.c
+++ b/source3/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/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c
index c557036800..230a222b8d 100644
--- a/source3/rpc_server/srv_svcctl_nt.c
+++ b/source3/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/source3/services/svc_spoolss.c b/source3/services/svc_spoolss.c
index bd2f7173f1..5f8fa73ced 100644
--- a/source3/services/svc_spoolss.c
+++ b/source3/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;
}