]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/server.c
Off by one error in ipp_finishings_vendor
[thirdparty/cups.git] / scheduler / server.c
index 3dc580e535f71901598a7880aef795e90d1c1d42..bb646d8133e3a4713ccde168bddb582f6b2cfca8 100644 (file)
@@ -1,21 +1,10 @@
 /*
- * "$Id$"
+ * Server start/stop routines for the CUPS scheduler.
  *
- *   Server start/stop routines for the CUPS scheduler.
+ * Copyright 2007-2019 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
- *   Copyright 2007-2012 by Apple Inc.
- *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- *   cupsdStartServer() - Start the server.
- *   cupsdStopServer()  - Stop the server.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
@@ -45,16 +34,28 @@ void
 cupsdStartServer(void)
 {
  /*
-  * Start color management (as needed)...
+  * Create the default security profile...
   */
 
-  cupsdStartColor();
+  DefaultProfile = cupsdCreateProfile(0, 1);
+
+#ifdef HAVE_SANDBOX_H
+  if (!DefaultProfile && UseSandboxing && Sandboxing != CUPSD_SANDBOXING_OFF)
+  {
+   /*
+    * Failure to create the sandbox profile means something really bad has
+    * happened and we need to shutdown immediately.
+    */
+
+    return;
+  }
+#endif /* HAVE_SANDBOX_H */
 
  /*
-  * Create the default security profile...
+  * Start color management (as needed)...
   */
 
-  DefaultProfile = cupsdCreateProfile(0);
+  cupsdStartColor();
 
  /*
   * Startup all the networking stuff...
@@ -85,7 +86,7 @@ cupsdStartServer(void)
               CUPSD_EVENT_SERVER_STARTED;
   started   = 1;
 
-  cupsdSetBusyState();
+  cupsdSetBusyState(0);
 }
 
 
@@ -142,21 +143,24 @@ cupsdStopServer(void)
 
   if (AccessFile != NULL)
   {
-    cupsFileClose(AccessFile);
+    if (AccessFile != LogStderr)
+      cupsFileClose(AccessFile);
 
     AccessFile = NULL;
   }
 
   if (ErrorFile != NULL)
   {
-    cupsFileClose(ErrorFile);
+    if (ErrorFile != LogStderr)
+      cupsFileClose(ErrorFile);
 
     ErrorFile = NULL;
   }
 
   if (PageFile != NULL)
   {
-    cupsFileClose(PageFile);
+    if (PageFile != LogStderr)
+      cupsFileClose(PageFile);
 
     PageFile = NULL;
   }
@@ -168,6 +172,15 @@ cupsdStopServer(void)
   cupsdDestroyProfile(DefaultProfile);
   DefaultProfile = NULL;
 
+ /*
+  * Expire subscriptions and clean out old jobs...
+  */
+
+  cupsdExpireSubscriptions(NULL, NULL);
+
+  if (JobHistoryUpdate)
+    cupsdCleanJobs();
+
  /*
   * Write out any dirty files...
   */
@@ -177,8 +190,3 @@ cupsdStopServer(void)
 
   started = 0;
 }
-
-
-/*
- * End of "$Id$".
- */