From: Michael R Sweet Date: Fri, 5 Apr 2024 21:27:23 +0000 (-0400) Subject: Report an error if you use lpadmin to set defaults for a temporary queue (Issue ... X-Git-Tag: v2.4.8~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dce85e17ee716aed8f653571202f47b572e3e4fd;p=thirdparty%2Fcups.git Report an error if you use lpadmin to set defaults for a temporary queue (Issue #237) --- diff --git a/CHANGES.md b/CHANGES.md index a4222f6df5..aec692a5c8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ Changes in CUPS v2.4.8 (TBA) - Updated IPP Everywhere printer creation error reporting (Issue #347) - Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751) +- Now report an error for temporary printer defaults with lpadmin (Issue #237) - Fixed mapping of PPD InputSlot, MediaType, and OutputBin values (Issue #238) - Fixed "document-unprintable-error" handling (Issue #391) - Fixed the web interface not showing an error for a non-existent printer diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 7408a97a02..7a8148411c 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -11015,6 +11015,9 @@ set_printer_defaults( * Only allow keywords and names... */ + if (printer->temporary) + goto temporary_printer; + if (attr->value_tag != IPP_TAG_NAME && attr->value_tag != IPP_TAG_KEYWORD) continue; @@ -11035,6 +11038,9 @@ set_printer_defaults( } else if (!strcmp(attr->name, "requesting-user-name-allowed")) { + if (printer->temporary) + goto temporary_printer; + cupsdFreeStrings(&(printer->users)); printer->deny_users = 0; @@ -11049,6 +11055,9 @@ set_printer_defaults( } else if (!strcmp(attr->name, "requesting-user-name-denied")) { + if (printer->temporary) + goto temporary_printer; + cupsdFreeStrings(&(printer->users)); printer->deny_users = 1; @@ -11063,6 +11072,9 @@ set_printer_defaults( } else if (!strcmp(attr->name, "job-quota-period")) { + if (printer->temporary) + goto temporary_printer; + if (attr->value_tag != IPP_TAG_INTEGER) continue; @@ -11074,6 +11086,9 @@ set_printer_defaults( } else if (!strcmp(attr->name, "job-k-limit")) { + if (printer->temporary) + goto temporary_printer; + if (attr->value_tag != IPP_TAG_INTEGER) continue; @@ -11085,6 +11100,9 @@ set_printer_defaults( } else if (!strcmp(attr->name, "job-page-limit")) { + if (printer->temporary) + goto temporary_printer; + if (attr->value_tag != IPP_TAG_INTEGER) continue; @@ -11099,6 +11117,9 @@ set_printer_defaults( cupsd_policy_t *p; /* Policy */ + if (printer->temporary) + goto temporary_printer; + if (attr->value_tag != IPP_TAG_NAME) continue; @@ -11120,6 +11141,9 @@ set_printer_defaults( } else if (!strcmp(attr->name, "printer-error-policy")) { + if (printer->temporary) + goto temporary_printer; + if (attr->value_tag != IPP_TAG_NAME && attr->value_tag != IPP_TAG_KEYWORD) continue; @@ -11150,6 +11174,9 @@ set_printer_defaults( namelen > (sizeof(name) - 1) || attr->num_values != 1) continue; + if (printer->temporary) + goto temporary_printer; + /* * OK, anything else must be a user-defined default... */ @@ -11223,6 +11250,17 @@ set_printer_defaults( } return (1); + + /* + * If we get here this is a temporary printer and you can't set defaults for + * this kind of queue... + */ + + temporary_printer: + + send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Unable to save value for \"%s\" with a temporary printer."), attr->name); + + return (0); }