In the imageto...()s fixed the print-scaling=none (crop-to-fit) mode,
which prints the image in its original size (based on PPI resolution
stored in the image file or on 200 dpi resolution, which is the
standard resolution for shipping labels). Also use crop-to-fit always
when requested, do not fall back to fit-to-page when the image is
significantly larger or smaller than the page.
libcupsfilters: Changed the default ppi from 128 to 200
This is for image input files which have no PPI resolution in their metadata and are printed without scaling ("print-scaling=none"). In this case the default resolution is used. Formerly it was set to 128 PPI but we change it to 200 PPI now as many shipping labels come as image files with 200 PPI and so it is easier to print them in their original size. For photos this default value is not important though, as photos are usually printed with scaling ("print-scaling=fill" or "print-scaling=fit").
Till Kamppeter [Sat, 5 Feb 2022 19:22:10 +0000 (16:22 -0300)]
pdftopdf: Add 2% tolerance for input size larger than output page
When "print-scaling=auto" or "print-scaling=auto-fit" is used, the
input pages are scaled when they do not fit into the output page
size. Often input ad out page sizes are supposed to be equal, for
example both A4, but rounding errors could make the input considered
larger and unnecessarily scaled.
Therefore we add 2% of tolerance before considering an input page too
large.
RFC7472 requires that 'ipps' must be used over HTTPS, but driverless
does not enforce encryption and will use insecure connection by
default. This makes it unusable with a printer that expects secure
connection only on 'ipps' port.
Till Kamppeter [Thu, 3 Feb 2022 22:03:00 +0000 (19:03 -0300)]
pdftopdf: Set a default for "print-scaling"
If no setting for "print-scaling" is provided via IPP attribute or
command line option there is no default value for it and we get
undefined behavior and also a scary "should never happen" message in
the log.
Now we check after parsing the appropriate IPP attributes and command
line options whether a setting was provided. If not, we use "auto".
Till Kamppeter [Thu, 30 Dec 2021 02:12:00 +0000 (23:12 -0300)]
libcupsfilters: Fix resolver functions for DNS-SD-based URIs
CUPS and cups-browsed use DNS-SD-service-name-based URIs, so that the
printer URIs are robust against changes of network details, for
example of the port, if Printer Applications on a system come up in
different order at every boot.
To be able to access the printer these URIs have to get resolved,
which means to get converted into standard IPP URIs. This is done by
two functions with their source being in cupsfilters/ipp.c.
Unfortunately both functions have a bug and in this commit we fix
these bugs to make the functions correctly working in all cases.
1. resolve_uri()
This function calls cupsBackendDeviceURI() of libcups which resolves
device URIs for the CUPS backends. As it is designed for only using in
CUPS backends it needs some workarounds to make it usuable as
universal library function and make it work in a wide range of system
environments.
One workaround was already applied from the beginning on, re-directing
stderr into the Nirwana, to avoid messages to stderr.
Another is needed and now added: We need to unset the DEVICE_URI
environment variable as the function searches for the device URI to
resolve there at first and not as argc[0]. Otherwise, if we are
running under CUPS, in a backend, we get the print queue's device URI
resolved and not the one which we supply.
We save and restore the value of DEVICE_URI to keep the impact as low
as possible.
2. ippfind_based_uri_converter()
In this function the ippfind utility is called in a fork and the
foreground (parent process) is getting ippfind's stdout through a
pipe. The main process is picking up the data to use it for resolving
the given URI. Here the parent process has unnecessarily: "dup"ed the
read end of the pipe to stdin, and then read the lines from
stdin. This prevents the calling program to use stdin by itself, for
example to receive print job data.
Now this is fixed by directly reading from the read end of the pipe.
Till Kamppeter [Thu, 3 Feb 2022 19:01:56 +0000 (16:01 -0300)]
pdftopdf: Fix orientation-requested = 0
CUPS often adds "orientation-requested=0" to the options in the
filter/backend command line, meaning automatic selection. pdftopdf()
did not support this value and therefore did not do the correct
settings making margins of rotated landscape pages not be done
correctly.
Till Kamppeter [Sat, 15 Jan 2022 18:40:43 +0000 (15:40 -0300)]
libcupsfilters: Let PPD generator take default ColorModel from printer
Instead of selecting the "best" available color mode as default for
the PPD file generated from the response to the get-printer-attributes
IPP request we use the printer default according to the IPP attributes
(print-color-mode-default).
This way on can simply change the default on a network printer's web
interface or on a remote CUPS printer and clients using cups-browsed
or the "driverless" utility respect the change.
This solves https://github.com/OpenPrinting/cups/issues/277, together
with the changes done on CUPS for this issue.
Till Kamppeter [Tue, 4 Jan 2022 20:07:50 +0000 (17:07 -0300)]
libcupsfilters: In imagetoraster() fixed crash with SGray
As the SGray color space was not mentioned in the switch for selecting
the raster line formatting function, a 3-channel color formatting
function was selected instead of the 1-channel grayscale one, leading
to an overrun of the input pixel line, causing a crash.
This is fixed now by also mentioning the 3 standard color spaces for
driverless printing, SGray, SRGB, and AdobeRGB explicily (where for
the latter 2 the selection already worked as they are 3-channel color
options).
TinyTrebuchet [Sat, 15 Jan 2022 14:35:32 +0000 (20:05 +0530)]
Braille: In vectortopdf check inkscape version to call inkscape with the correct command line
From version 1.0.x on, Inkscape does not support the '-A' command line flag any more. Now we check the inkscape version and call inkscape always with the correct command line.
Till Kamppeter [Wed, 22 Dec 2021 22:57:32 +0000 (19:57 -0300)]
cups-browsed: Updated naming of locally created print queues
Naming of local queues created by cups-browsed is now matched to CUPS'
current naming of temporary queues (no leading or trailing
underscores), to avoid duplicates in print dialogs which support CUPS'
temporary queues.
Till Kamppeter [Tue, 12 Oct 2021 11:33:26 +0000 (13:33 +0200)]
libcupsfilters: Make cupsRasterParseIPPOptions() work correctly with PPDs
cupsRasterParseIPPOptions() interprets job options/IPP attributes and
their settings just bei their names. This works well when the
destination printer is not described by a PPD file.
If there is a PPD file, their can be weird option and choice names
which do not tell what they are good for, giving wrong
impressions. Only the PostScript or PJL code assigned to the choices
in the PPD file tells what they actually are supposed to do.
A good example for that is the "Resolution" option of Gutenprint. As
the developers of Gutenprint do not want to solely and directly set
the print resolution with this option (as was Adobe's idea for it),
and instead, do more things with it, as having an "Automatic" choice
or variants of the same resolution (for example different dithering
algorithms), but PPD standards require the choices to be "XXXxYYYdpi"
without exceptions, they come with names like "601x600dpi" for the
variants and the PPD's embedded PostScript code contains the actual
resolution.
To avoid that cupsRasterParseIPPOptions() mis-interprets such weird
PPD options, we check whether we are using a PPD (via the PPD
environment variable) and if so we refrain from parsing options which
are in the PPD. Only if set_defaults = 1 is set, we use them but via a
call of callRasterInterpretPPD() instead of interpreting them by
ourselves option/choice-name-only.
Till Kamppeter [Sun, 19 Sep 2021 17:53:30 +0000 (19:53 +0200)]
libcupsfilters: Let colord_get_profile_for_device_id() not return empty file name
If the function colord_get_profile_for_device_id() returns an empty
file name, the color generates an error message in the CUPS
error_log. Some print dialogs report every log message of level error
to the user even if the job got correctly printed.
zdohnal [Fri, 18 Jun 2021 10:27:53 +0000 (12:27 +0200)]
cups-browsed.c: Make NotifLeaseDuration configurable and renew after half the lease duration not 60 sec before end
1) NotifLeaseDuration directive for cups-browsed.conf - it will make
lease duration for notifications configurable by users. IMO it is not
useful for regular users, but it is helpful during sanity testing
(for verifying that we actually renew the subscription when time
comes). The current hardcoded 1 day is unusuable for that :( .
I implemented the lowest threshold to 300s to prevent a possible DoS.
2) Subscription renewal is set to happen in the middle of NotifLeaseDuration,
not one minute before lease expiration. This was a problem on busy servers,
where cups-browsed was busy and wasn't able to renew the subscription
before cupsd removed it. Then if some jobs had come before the subscription
was created again, the queue got disabled. The proposed approach is based
on behavior of DHCP.
cups-browsed can be set to browsepolling remote servers, browsing remote
queues via CUPS protocol or sharing local queues via CUPS protocol.
Although sharing and browsing happens via browsesocket (which can be
solved by setting socket option IP_FREEBIND), browsepolling must have
network working to communicate with a remote server.
Zdenek Dohnal [Mon, 23 Nov 2020 13:47:15 +0000 (14:47 +0100)]
cups-browsed.c: Fix nickname pointer memory leak
This memory leak was caused by losing the original pointer to allocated memory and
trying to free incomplete pointer. The fix reimplements acquiring of nickname
algorithm and allocates the precise memory for nickname. In case of error, the algorithm
reports an warning into debug log and continue with reading from PPD.
It looks like 'get_cluster_attributes()' needs to be called earlier than where it is now,
because the code checks 'printer_attributes' (where is the result of 'get_cluster_attributes()'
for clustered queues) before the first 'get_cluster_attributes()' right now, which looks like
an error. So the fix moves the 'get_cluster_attributes()' call before the first 'printer_attributes'
query.
Zdenek Dohnal [Mon, 23 Nov 2020 13:53:37 +0000 (14:53 +0100)]
cups-browsed.c: Fix conditional jumps based on uninitialized value
Strings added with IPP_TAG_MIMETYPE and IPP_TAG_KEYWORD tags use uninitialized
buffers, which causes random behavior. The buffers can be initialized via f.e.
'snprintf()'.
Zdenek Dohnal [Mon, 23 Nov 2020 13:34:04 +0000 (14:34 +0100)]
ppdgenerator.c: Free printer_sizes array
We need to free 'printer_sizes', which is allocated in 'ppdCreateFromIPP2()', instead of
'sizes', which is passed as a parameter - because it solves a memory leak and it doesn't
leave an invalid pointer.