From: Michael R Sweet Date: Fri, 20 Sep 2024 17:08:09 +0000 (-0400) Subject: Add a temporary queue before setting the defaults for lpoptions (Issue #833) X-Git-Tag: v2.4.11~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=141153e6d6d9c20c119f176b9cec0ba6d3597bd6;p=thirdparty%2Fcups.git Add a temporary queue before setting the defaults for lpoptions (Issue #833) --- diff --git a/CHANGES.md b/CHANGES.md index 50827dfc64..250d0a2275 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes in CUPS v2.4.11 (YYYY-MM-DD) ------------------------------------ - Updated the maximum file descriptor limit for `cupsd` to 64k-1 (Issue #989) +- Fixed `lpoptions -d` with a discovered but not added printer (Issue #833) - Fixed incorrect error message for HTTP/IPP errors (Issue #893) - Fixed JobPrivateAccess and SubscriptionPrivateAccess support for "all" (Issue #990) diff --git a/cups/dest.c b/cups/dest.c index e971e6df62..b48d8f219c 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -2058,6 +2058,35 @@ cupsSetDests2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_ if (!num_dests || !dests) return (-1); + /* + * See if the default destination has a printer URI associated with it... + */ + + if ((dest = cupsGetDest(/*name*/NULL, /*instance*/NULL, num_dests, dests)) != NULL && !cupsGetOption("printer-uri-supported", dest->num_options, dest->options)) + { + /* + * No, try adding it... + */ + + const char *uri; /* Device/printer URI */ + + if ((uri = cupsGetOption("device-uri", dest->num_options, dest->options)) != NULL) + { + char tempresource[1024]; /* Temporary resource path */ + +#ifdef HAVE_DNSSD + if (strstr(uri, "._tcp")) + uri = cups_dnssd_resolve(dest, uri, /*msec*/30000, /*cancel*/NULL, /*cb*/NULL, /*user_data*/NULL); +#endif /* HAVE_DNSSD */ + + if (uri) + uri = _cupsCreateDest(dest->name, cupsGetOption("printer-info", dest->num_options, dest->options), NULL, uri, tempresource, sizeof(tempresource)); + + if (uri) + dest->num_options = cupsAddOption("printer-uri-supported", uri, dest->num_options, &dest->options); + } + } + /* * Get the server destinations... */