]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Added NewBrowsePollQueuesShared and AllowResharingcupsQueues directives to cups-browsed 218/head
authorV1krant <vikrantmalik051@gmail.com>
Thu, 12 Mar 2020 07:05:45 +0000 (12:35 +0530)
committerVikrant <vikrantmalik051@gmail.com>
Fri, 20 Mar 2020 14:03:16 +0000 (19:33 +0530)
utils/cups-browsed.c
utils/cups-browsed.conf.5
utils/cups-browsed.conf.in

index dd0fcbb3d73175939201b2bce782b2a41bf7a00d..c649eab63a559594eefa801773da6cb46b65b8d2 100644 (file)
@@ -430,6 +430,8 @@ static unsigned int BrowseInterval = 60;
 static unsigned int BrowseTimeout = 300;
 static uint16_t BrowsePort = 631;
 static browsepoll_t **BrowsePoll = NULL;
+static unsigned int NewBrowsePollQueuesShared = 0;
+static unsigned int AllowResharingRemoteCUPSPrinters = 0;
 static size_t NumBrowsePoll = 0;
 static guint update_netifs_sourceid = 0;
 static char local_server_str[1024];
@@ -7897,7 +7899,7 @@ gboolean update_cups_queues(gpointer unused) {
             * only if we have CUPS older than 2.2.
             * When you have remote queue, clean up and break from the loop.
             */
-           if (p->netprinter != 0 || !HAVE_CUPS_2_2)
+           if (p->netprinter != 0 || !HAVE_CUPS_2_2 || AllowResharingRemoteCUPSPrinters)
              ippDelete(cupsDoRequest(http, request, "/admin/"));
            else {
              ippDelete(request);
@@ -8465,7 +8467,8 @@ gboolean update_cups_queues(gpointer unused) {
            if (p->netprinter == 0 &&
                strncmp(line, "*%", 2) &&
                strncmp(line, "*PPD-Adobe:", 11) &&
-               ap_remote_queue_id_line_inserted == 0) {
+               ap_remote_queue_id_line_inserted == 0 &&
+              !AllowResharingRemoteCUPSPrinters) {
              ap_remote_queue_id_line_inserted = 1;
              cupsFilePrintf(out, "*APRemoteQueueID: \"\"\n");
            }
@@ -8605,6 +8608,12 @@ gboolean update_cups_queues(gpointer unused) {
        num_options = cupsAddOption("printer-is-shared", "true",
                                    num_options, &options);
        debug_printf("Setting printer-is-shared bit.\n");
+      } else if (NewBrowsePollQueuesShared &&
+      (val = cupsGetOption("printer-to-be-shared", p->num_options,
+               p->options)) != NULL) {
+       num_options = cupsAddOption("printer-is-shared", "true",
+                                   num_options, &options);
+       debug_printf("Setting printer-is-shared bit.\n");
       } else {
        num_options = cupsAddOption("printer-is-shared", "false",
                                    num_options, &options);
@@ -8617,7 +8626,7 @@ gboolean update_cups_queues(gpointer unused) {
        * network printer or if we have remote CUPS queue, do IPP request
        * only if we have CUPS older than 2.2.
        */
-      if (p->netprinter != 0 || !HAVE_CUPS_2_2)
+      if (p->netprinter != 0 || !HAVE_CUPS_2_2 || AllowResharingRemoteCUPSPrinters)
         ippDelete(cupsDoRequest(http, request, "/admin/"));
       else
         ippDelete(request);
@@ -10417,12 +10426,18 @@ found_cups_printer (const char *remote_host, const char *uri,
       (printer->domain == NULL || printer->domain[0] == '\0' ||
        printer->type == NULL || printer->type[0] == '\0')) {
     printer->is_legacy = 1;
+
     if (printer->status != STATUS_TO_BE_CREATED) {
       printer->timeout = time(NULL) + BrowseTimeout;
       debug_printf("starting BrowseTimeout timer for %s (%ds)\n",
                   printer->queue_name, BrowseTimeout);
     }
   }
+
+  if (printer && NewBrowsePollQueuesShared &&
+      (HAVE_CUPS_1_6 || (!HAVE_CUPS_1_6 && !printer->is_legacy)))
+    printer->num_options = cupsAddOption("printer-to-be-shared", "true", printer->num_options, &(printer->options));
+
 }
 
 gboolean
@@ -11588,6 +11603,20 @@ read_configuration (const char *filename)
       else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
               !strcasecmp(value, "off") || !strcasecmp(value, "0"))
        NewIPPPrinterQueuesShared = 0;
+    } else if (!strcasecmp(line, "AllowResharingRemoteCUPSPrinters") && value) {
+      if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") ||
+         !strcasecmp(value, "on") || !strcasecmp(value, "1"))
+       AllowResharingRemoteCUPSPrinters = 1;
+      else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
+              !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+       AllowResharingRemoteCUPSPrinters = 0;
+    } else if (!strcasecmp(line, "NewBrowsePollQueuesShared") && value) {
+      if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") ||
+         !strcasecmp(value, "on") || !strcasecmp(value, "1"))
+       NewBrowsePollQueuesShared = 1;
+      else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
+              !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+       NewBrowsePollQueuesShared = 0;
     } else if (!strcasecmp(line, "AutoClustering") && value) {
       if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") ||
          !strcasecmp(value, "on") || !strcasecmp(value, "1"))
index c592ac7a51d160b2ade7d15c08962265ba5d7cfa..99ed3796ee71fc8183f7c10bb1113167104fb7c6 100644 (file)
@@ -466,6 +466,31 @@ this timeout if no further broadcast from the server happens.
 .fam C
         BrowseTimeout 300
 
+.fam T
+.fi
+The AllowResharingRemoteCUPSPrinters directive determines whether a
+print queue pointing to a remote CUPS queue will be re-shared to the
+local network or not. Since the queues generated using the BrowsePoll
+directive are also pointing to remote queues, they are also shared
+automatically if the following option is set. Default is not to share
+remote queues.
+.PP
+.nf
+.fam C
+        AllowResharingRemoteCUPSPrinters Yes
+
+.fam T
+.fi
+The NewBrowsePollQueuesShared directive determines whether a print
+queue for a newly discovered printer (discovered by the BrowsePoll directive)
+will be shared to the local network or not. This directive will only work
+if AllowResharingRemoteCUPSPrinters is set to yes. Default is
+not to share printers discovered using BrowsePoll.
+.PP
+.nf
+.fam C
+        NewBrowsePollQueuesShared Yes
+
 .fam T
 .fi
 Set OnlyUnsupportedByCUPS to "Yes" will make cups-browsed not create
index 82536aaf1ef336045460469587ebeb7884bdcb6a..ca4371fe58375de2bc600137ced919605dd257ef 100644 (file)
@@ -125,7 +125,6 @@ BrowseRemoteProtocols @BROWSEREMOTEPROTOCOLS@
 
 # BrowseTimeout 300
 
-
 # Filtering of remote printers by other properties than IP addresses
 # of their servers
 
@@ -436,6 +435,22 @@ BrowseRemoteProtocols @BROWSEREMOTEPROTOCOLS@
 # IPBasedDeviceURIs IPv4
 # IPBasedDeviceURIs IPv6
 
+# The AllowResharingRemoteCUPSPrinters directive determines whether a
+# print queue pointing to a remote CUPS queue will be re-shared to the
+# local network or not. Since the queues generated using the BrowsePoll
+# directive are also pointing to remote queues, they are also shared
+# automatically if the following option is set. Default is not to share
+# remote printers.
+
+# AllowResharingRemoteCUPSPrinters Yes
+
+# The NewBrowsePollQueuesShared directive determines whether a print
+# queue for a newly discovered printer (discovered by the BrowsePoll directive)
+# will be shared to the local network or not. This directive will only work
+# if AllowResharingRemoteCUPSPrinters is set to yes. Default is
+# not to share printers discovered using BrowsePoll.
+
+# NewBrowsePollQueuesShared Yes
 
 # Set CreateRemoteRawPrinterQueues to "Yes" to let cups-browsed also
 # create local queues pointing to remote raw CUPS queues. Normally,