From f9cdaa3e850f18bdfde1e73caf66638d80ff9f7f Mon Sep 17 00:00:00 2001 From: abubakarsabir924-cell Date: Sun, 10 May 2026 02:07:31 -0400 Subject: [PATCH] fix duplicate local printers in DNS-SD discovery (Issue #1531) --- cups/dest.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cups/dest.c b/cups/dest.c index eafb241558..38dd66436e 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -69,6 +69,8 @@ typedef struct _cups_dnssd_data_s // Enumeration data cups_array_t *devices; // Devices found so far int num_dests; // Number of lpoptions destinations cups_dest_t *dests; // lpoptions destinations + int num_local; // Number of local cupsd queues + cups_dest_t *local_dests; // Local cupsd queues char def_name[1024], // Default printer name, if any *def_instance; // Default printer instance, if any } _cups_dnssd_data_t; @@ -2845,6 +2847,26 @@ cups_dest_query_cb( if (!have_pdf && !have_raster) device->state = _CUPS_DNSSD_INCOMPATIBLE; } + else if (!_cups_strcasecmp(key, "rp")) + { + // Suppress local printer being re-discovered via DNS-SD + const char *rp_name = value; + int i; + + if (!_cups_strncasecmp(rp_name, "printers/", 9)) + rp_name += 9; + + for (i = 0; i < data->num_local; i++) + { + if (!_cups_strcasecmp(rp_name, data->local_dests[i].name)) + { + device->state = _CUPS_DNSSD_INCOMPATIBLE; + DEBUG_printf("6cups_dest_query_cb: " + "Suppressing local printer '%s'.", rp_name); + break; + } + } + } else if (!_cups_strcasecmp(key, "printer-type")) { // Value is either NNNN or 0xXXXX @@ -3177,6 +3199,8 @@ cups_enum_dests( { // Get the list of local printers and pass them to the callback function... num_dests = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, &dests, data.type, data.mask); + data.num_local = num_dests; + data.local_dests = dests; if (data.def_name[0]) {