]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
fix duplicate local printers in DNS-SD discovery (Issue #1531)
authorabubakarsabir924-cell <abubakarsabir924@gmail.com>
Sun, 10 May 2026 06:07:31 +0000 (02:07 -0400)
committerabubakarsabir924-cell <abubakarsabir924@gmail.com>
Sun, 10 May 2026 06:07:31 +0000 (02:07 -0400)
cups/dest.c

index eafb2415581bcce246cd428c5e32b6bd04499496..38dd66436eb8935b652ffe4997e2eabd0d13e087 100644 (file)
@@ -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])
     {