Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-31 Thread Paul Szabo
> Where did you report them?

As mentioned:
https://github.com/OpenPrinting/cups/issues/917
https://github.com/OpenPrinting/cups/issues/918
https://github.com/OpenPrinting/cups/issues/919
and also
https://github.com/OpenPrinting/cups/issues/916

Cheers, Paul
-- 
Paul Szabo   p...@maths.usyd.edu.au   www.maths.usyd.edu.au/u/psz
School of Mathematics and Statistics   University of SydneyAustralia

Join the Union and fight for a better University: www.nteu.au/join



Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-31 Thread Till Kamppeter

On 31/03/2024 22:23, Paul Szabo wrote:

(Sadly, my other issues were "declined" upstream. Maybe they know what
they are doing...)


Where did you report them?

   Till



Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-31 Thread Paul Szabo
Dear Till,

Thanks for the pointer to libcupsfilters, now that issue reported also:
https://github.com/OpenPrinting/libcupsfilters/issues/53

(Sadly, my other issues were "declined" upstream. Maybe they know what
they are doing...)

Thanks, Paul
-- 
Paul Szabo   p...@maths.usyd.edu.au   www.maths.usyd.edu.au/u/psz
School of Mathematics and Statistics   University of SydneyAustralia



Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-30 Thread Till Kamppeter

On 30/03/2024 23:19, Paul Szabo wrote:

Most issues now reported upstream:
https://github.com/OpenPrinting/cups/issues/917
https://github.com/OpenPrinting/cups/issues/918
https://github.com/OpenPrinting/cups/issues/919

The issue with pdftopdf not reported upstream, because I could not find
the corresponding "current" source.

Cheers, Paul


The current source of pdftopdf is libcupsfilters:

https://github.com/OpenPrinting/libcupsfilters/issues

   Till



Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-30 Thread Paul Szabo
Most issues now reported upstream:
https://github.com/OpenPrinting/cups/issues/917
https://github.com/OpenPrinting/cups/issues/918
https://github.com/OpenPrinting/cups/issues/919

The issue with pdftopdf not reported upstream, because I could not find
the corresponding "current" source.

Cheers, Paul
-- 
Paul Szabo   p...@maths.usyd.edu.au   www.maths.usyd.edu.au/u/psz
School of Mathematics and Statistics   University of SydneyAustralia

Join the Union and fight for a better University: www.nteu.au/join



Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-04 Thread Paul Szabo
[But, there are bugs also in pstops ...]

I noticed bugs related to multiple copies in several places:
 - filter/pdftopdf (package cups-filters-core-drivers)
 - filter/pstops (package cups-core-drivers)
 - backend-available/lpd (package cups)
Please see fixes for the sources of each, below.

Maybe the essence of the issue is in the design of CUPS, so maybe cupsd
or libcups.so, in how filters and backend are asked to produce copies.
I did not change that, but only provide some comments in the source file.
(The issue does not fully affect me, since I use cupsManualCopies off.)

Below the patch file, both as plain-text and as attachment (the latter
hopefully preserving blanks and tabs).

Cheers, Paul
-- 
Paul Szabo   p...@maths.usyd.edu.au   www.maths.usyd.edu.au/u/psz
School of Mathematics and Statistics   University of SydneyAustralia


-


--- cups-2.4.2/backend/lpd.c.ORIG   2022-05-26 16:17:21.0 +1000
+++ cups-2.4.2/backend/lpd.c2024-03-05 14:09:07.739682339 +1100
@@ -214,7 +214,14 @@
   format= 'l';
   order = ORDER_CONTROL_DATA;
   reserve   = RESERVE_ANY;
-  manual_copies = 1;
+  /* PSz 29 Feb 2024
+   * Set default manual_copies "off".
+   * With manual_copies "on", we simply run the copies together.
+   * Then a job of odd number of pages sent to a duplex printer,
+   * the first page of second copy gets printed on the back of the
+   * last page of the first copy.
+   */
+  manual_copies = 0;
   timeout   = 300;
   contimeout= 7 * 24 * 60 * 60;
 
@@ -305,7 +312,7 @@
   else if (!_cups_strcasecmp(name, "mode") && value[0])
   {
/*
-* Set control/data order...
+* Set mode...
*/
 
 if (!_cups_strcasecmp(value, "standard"))
@@ -351,6 +358,13 @@
/*
 * Set manual copies...
*/
+   /* PSz 28 Feb 24
+* Should not this be
+*   cupsGetOption("manual_copies", num_jobopts, jobopts)
+* or maybe some
+*   ppd->manual_copies
+* instead?
+*/
 
 manual_copies = !value[0] || !_cups_strcasecmp(value, "on") ||
!_cups_strcasecmp(value, "yes") ||
@@ -397,7 +411,10 @@
 }
   }
 
-  if (mode == MODE_STREAM)
+  /* PSz 1 Mar 2024
+   * This override needed only if data from STDIN and in STREAM mode
+   */
+  if (argc == 6 && mode == MODE_STREAM)
 order = ORDER_CONTROL_DATA;
 
  /*
@@ -499,7 +516,13 @@
   * Queue the job...
   */
 
-  if (argc > 6)
+  /* PSz 27 Feb 2024
+   * Do not (needlessly) ignore number of copies requested.
+   * Surely can do when have file, whether named or our temporary.
+   * Can also do when data from STDIN and STREAM mode, though
+   * not in the manual_copies way.
+   */
+  if (argc > 6 || mode == MODE_STANDARD)
   {
 if (manual_copies)
 {
@@ -511,22 +534,16 @@
   manual_copies = 1;
   copies= atoi(argv[4]);
 }
+  }
 
-status = lpd_queue(hostname, addrlist, resource + 1, fd, snmp_fd, mode,
-   username, title, copies, banner, format, order, reserve,
-  manual_copies, timeout, contimeout,
-  cupsGetOption("job-originating-host-name", num_jobopts,
-jobopts));
+  status = lpd_queue(hostname, addrlist, resource + 1, fd, snmp_fd, mode,
+ username, title, copies, banner, format, order, reserve,
+manual_copies, timeout, contimeout,
+cupsGetOption("job-originating-host-name", num_jobopts,
+  jobopts));
 
-if (!status)
-  fprintf(stderr, "PAGE: 1 %d\n", atoi(argv[4]));
-  }
-  else
-status = lpd_queue(hostname, addrlist, resource + 1, fd, snmp_fd, mode,
-   username, title, 1, banner, format, order, reserve, 1,
-  timeout, contimeout,
-  cupsGetOption("job-originating-host-name", num_jobopts,
-jobopts));
+  if (!status)
+fprintf(stderr, "PAGE: 1 %d\n", atoi(argv[4]));
 
  /*
   * Remove the temporary file if necessary...
@@ -956,6 +973,10 @@
 * Next, open the print file and figure out its size...
 */
 
+/* PSz 1 Mar 2024
+ * Are we sure to get a non-zero print_fd when have file:
+ * do we "really know" that we were invoked with STDIN open?
+ */
 if (print_fd)
 {
  /*
@@ -1019,13 +1040,18 @@
   cptr   += strlen(cptr);
 }
 
-while (copies > 0)
+/* PSz 28 Feb 2024
+ * Check size remaining, do not blow with too many copies
+ */
+while (copies > 0 && ((sizeof(control) - (size_t)(cptr - control)) > 256))
 {
   snprintf(cptr, sizeof(control) - (size_t)(cptr - control), 
"%cdfA%03d%.15s\n",
format, (int)getpid() % 1000, localhost);
   cptr   += strlen(cptr);
   copies --;
 }
+if (copies > 0)
+  fprintf(stderr, "DEBUG: Limited by control size, %d copies 

Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-02 Thread Paul Szabo
[Sorry about the previous, incomplete message.]

Further testing shows that the bug is not in filter/pstops but in
filter/pdftopdf; I do not yet know what the issue is, will try to find
out.

Please re-assign this bug to package cups-filters-core-drivers.

Cheers, Paul
-- 
Paul Szabo   p...@maths.usyd.edu.au   www.maths.usyd.edu.au/u/psz
School of Mathematics and Statistics   University of SydneyAustralia

Join the Union and fight for a better University: www.nteu.au/join



Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-02 Thread Paul Szabo
Further testing shows that the bug is not in filter/pstops
but in filter/pdftopdf. (I do not yet know what 
Maybe this bug should be reassigned to package

-- 
Paul Szabo   p...@maths.usyd.edu.au   www.maths.usyd.edu.au/u/psz
School of Mathematics and Statistics   University of SydneyAustralia

Join the Union and fight for a better University: www.nteu.au/join



Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-01 Thread Paul Szabo
I attach my PPD file below.

-- 
Paul Szabo   p...@maths.usyd.edu.au   www.maths.usyd.edu.au/u/psz
School of Mathematics and Statistics   University of SydneyAustralia

Join the Union and fight for a better University: www.nteu.au/join


my.ppd
Description: application/vnd.cups-ppd


Bug#1065157: cups-core-drivers: Filters ignore cupsManualCopies

2024-03-01 Thread Paul Szabo
Package: cups-core-drivers
Version: 2.4.2-3+deb12u5
Severity: normal

Seems that the cups filters ignore the setting of either
  *cupsManualCopies: False
  *cupsManualCopies: True
in the PPD file, but anyway produce (internally handle?)
the copies requested, regardless of which one was set.
In my testing, printing a PDF file causes CUPS to run the filters
  /usr/lib/cups/filter/pdftopdf
  /usr/lib/cups/filter/pdftops
and then when the PS file gets to the backend
  /usr/lib/cups/backend/lpd
the copies are "done" already.

Or maybe, I somehow use those options wrongly?

Thanks, Paul

Paul Szabo   p...@maths.usyd.edu.au   www.maths.usyd.edu.au/u/psz
School of Mathematics and Statistics   University of SydneyAustralia