From: Michael R Sweet Date: Thu, 4 Apr 2024 16:06:19 +0000 (-0400) Subject: Mirror fix from master/2.5 for potential race condition with CUPS-Create-Local-Printe... X-Git-Tag: v2.4.8~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c6e1b0d99417317defab30b67a591e740477a5d;p=thirdparty%2Fcups.git Mirror fix from master/2.5 for potential race condition with CUPS-Create-Local-Printer (Issue #871) --- diff --git a/CHANGES.md b/CHANGES.md index 44f0726aab..447edbe66d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/scheduler/ipp.c b/scheduler/ipp.c index e0caa98fe4..79821edc0f 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -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... */ diff --git a/scheduler/printers.c b/scheduler/printers.c index 5f9852e64f..fd0581e598 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -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)) {