[LOW] STR #4296: No PPD file for class being returned with legacy clients

Douglas Kosovic <[email protected]> Wed, 13 Mar 2013 21:30:45 -0700 (PDT)
Newsgroups gmane.comp.printing.cups.bugs
Message-ID <[email protected]>

--PART-BOUNDARY
Content-Type: text/plain

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Older clients such OS X Lion (and earlier) and various Linux software try
to obtain a PPD with a URI that looks something like the following, but
fail :

   http://servername/classes/poolname.ppd


I'm hoping something like the attached patch could be applied to fetch the
PPD file of the first printer in the class.

OS X Mountain Lion is using the CUPS API and has no issue.

Link: https://www.cups.org/str.php?L4296
Version: 1.6-current
--PART-BOUNDARY
Content-Type: text/plain
Content-Disposition: attachment; filename="cups-classes-ppd.patch.txt"

diff -up cups-1.6.1/scheduler/client.c.classes_ppd cups-1.6.1/scheduler/client.c
--- cups-1.6.1/scheduler/client.c.classes_ppd	2013-01-17 11:25:00 +1000
+++ cups-1.6.1/scheduler/client.c	2013-01-17 14:11:17 +1000
@@ -742,6 +742,7 @@ cupsdReadClient(cupsd_client_t *con)	/*
   context_t		tmpcon;		/* temp context to swap the level */
   char			*clirange;	/* SELinux sensitivity range */
   char			*cliclearance;	/* SELinux low end clearance */
+  int			i;		/* Looping var */
 #endif /* WITH_LSPP */
 
 
@@ -1359,6 +1360,35 @@ cupsdReadClient(cupsd_client_t *con)	/*
 		break;
 	      }
 	    }
+	    else if (!strncmp(con->uri, "/classes/", 9) &&
+		     !strcmp(con->uri + strlen(con->uri) - 4, ".ppd"))
+	    {
+	     /*
+	      * Send PPD file of first printer in the class
+	      */
+
+	      con->uri[strlen(con->uri) - 4] = '\0';	/* Drop ".ppd" */
+	      p = cupsdFindClass(con->uri + 9);
+
+              if (p)
+                for (i = 0; i < p->num_printers; i ++)
+                    if (!(p->printers[i]->type & CUPS_PRINTER_CLASS))
+                    {
+                        snprintf(con->uri, sizeof(con->uri), "/ppd/%s.ppd",
+                                 p->printers[i]->name);
+                        break;
+                     }
+             else
+             {
+		if (!cupsdSendError(con, HTTP_NOT_FOUND, CUPSD_AUTH_NONE))
+		{
+		  cupsdCloseClient(con);
+		  return;
+		}
+
+		break;
+	      }
+	    }
             else if ((!strncmp(con->uri, "/printers/", 10) ||
 		      !strncmp(con->uri, "/classes/", 9)) &&
 		     !strcmp(con->uri + strlen(con->uri) - 4, ".png"))

--PART-BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
cups-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/cups-bugs

--PART-BOUNDARY--