]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Mirror fix from master/2.5 for potential race condition with CUPS-Create-Local-Printe...
authorMichael R Sweet <msweet@msweet.org>
Thu, 4 Apr 2024 16:06:19 +0000 (12:06 -0400)
committerMichael R Sweet <msweet@msweet.org>
Thu, 4 Apr 2024 16:06:19 +0000 (12:06 -0400)
CHANGES.md
scheduler/ipp.c
scheduler/printers.c

index 44f0726aab2319cfc8880ceb480cfc51a03fe9fc..447edbe66db2687adaf2d86ec9017d59358587d5 100644 (file)
@@ -4,28 +4,33 @@ CHANGES - OpenPrinting CUPS 2.4.8 - TBA
 Changes in CUPS v2.4.8 (TBA)
 ----------------------------
 
-- Added warning if the device has to be asked for 'all,media-col-database' separately
-  (Issue #829)
+- Added warning if the device has to be asked for 'all,media-col-database'
+  separately (Issue #829)
 - Added new value for 'lpstat' option '-W' - successfull - for getting
   successfully printed jobs (Issue #830)
 - Added support for PAM modules password-auth and system-auth (Issue #892)
-- Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751)
+- Raised `cups_enum_dests()` timeout for listing available IPP printers
+  (Issue #751)
 - Fixed the web interface not showing an error for a non-existent printer
   (Issue #423)
-- Fixed printing of jobs with job name longer than 255 chars on older printers (Issue #644)
+- Fixed printing of jobs with job name longer than 255 chars on older printers
+  (Issue #644)
 - Really backport fix for Issue #742
 - Fixed memory leak when unloading a job (Issue #813)
 - Fixed memory leak when creating color profiles (Issue #815)
 - Fixed crash in `scan_ps()` if incoming argument is NULL (Issue #831)
 - Fixed setting job state reasons for successful jobs (Issue #832)
-- Fixed infinite loop in IPP backend if hostname is IP address with Kerberos (Issue #838)
+- Fixed infinite loop in IPP backend if hostname is IP address with Kerberos
+  (Issue #838)
 - Added additional check on socket if `revents` from `poll()` returns POLLHUP
   together with POLLIN or POLLOUT in `httpAddrConnect2()` (Issue #839)
 - Fixed crash in `ppdEmitString()` if `size` is NULL (Issue #850)
-- Fixed reporting `media-source-supported` when sharing printer which has numbers as strings
-  instead of keywords as `InputSlot` values (Issue #859)
+- Fixed reporting `media-source-supported` when sharing printer which has
+  numbers as strings instead of keywords as `InputSlot` values (Issue #859)
 - Fixed IPP backend to support the "print-scaling" option with IPP printers
   (Issue #862)
+- Fixed potential race condition for the creation of temporary queues
+  (Issue #871)
 - Fixed `httpGets` timeout handling (Issue #879)
 - Fixed checking for required attributes during PPD generation (Issue #890)
 - Fixed encoding of IPv6 addresses in HTTP requests (Issue #903)
index e0caa98fe41f24f2dd998be510be9538cf467ab2..79821edc0f6104d3bba48b8437efaa32477b9123 100644 (file)
@@ -5596,10 +5596,21 @@ create_local_printer(
 
   if ((printer = cupsdFindDest(name)) != NULL)
   {
-    send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Printer \"%s\" already exists."), name);
+    printer->state_time = time(NULL);
+    send_ipp_status(con, IPP_STATUS_OK, _("Printer \"%s\" already exists."), name);
     goto add_printer_attributes;
   }
 
+  for (printer = (cupsd_printer_t *)cupsArrayGetFirst(Printers); printer; printer = (cupsd_printer_t *)cupsArrayGetNext(Printers))
+  {
+    if (printer->device_uri && !strcmp(ptr, printer->device_uri))
+    {
+      printer->state_time = time(NULL);
+      send_ipp_status(con, IPP_STATUS_OK, _("Printer \"%s\" already exists."), printer->name);
+      goto add_printer_attributes;
+    }
+  }
+
  /*
   * Create the printer...
   */
index 5f9852e64f661e3242ea7f30a1ba84bc4261cc3f..fd0581e598534ec95e73a4e3c84264e3cecc9400 100644 (file)
@@ -782,11 +782,11 @@ cupsdDeleteTemporaryPrinters(int force) /* I - Force deletion instead of auto? *
                  "cupsdDeleteTemporaryPrinters: Removing unused temporary printers");
 
  /*
-  * Allow temporary printers to stick around for 60 seconds after the last job
+  * Allow temporary printers to stick around for 5 minutes after the last job
   * completes.
   */
 
-  unused_time = time(NULL) - 60;
+  unused_time = time(NULL) - 300;
 
   for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; p = (cupsd_printer_t *)cupsArrayNext(Printers))
   {