Introduce foomatic-hash and reject unauthorized values in foomatic-rip (#648)
The change provides a way for users to have control over what values are
allowed for the foomatic-rip-related PPD keywords FoomaticRIPCommandLine,
FoomaticRIPCommandLinePDF, and FoomaticRIPOptionSetting. Since the
values can be later used when constructing a shell command, the filter
foomatic-rip was a target of several exploits (caused by issues at
different places in CUPS or in different projects of the printing stack) to
do arbitrary code execution when the filter is used.
By default the filter is run by user lp, so the issue is mitigated, but
this PR gives admin complete control over what can be run in
foomatic-rip and reject anything injected into system via different
ways.
First, the new tool - foomatic-hash - can be called on a PPD file or
directory with drivers/PPDs, with scan output and file with hexadecimal
representation of hashed values. Once the scan output is reviewed by
admin, admin can decide to put the resulting hashes into
/etc/foomatic/hashes.d and allow them for the filter.
Michael Weghorn [Fri, 5 Jul 2024 11:29:39 +0000 (13:29 +0200)]
pclmtoraster: Properly set CFLAGS (#588)
As this is a C program, set
`pclmtoraster_CFLAGS`, not `pclmtoraster_CXXFLAGS`.
This fixes building pclmtoraster when libcupsfilter
headers are installed in a non-standard directory.
Previously, when configuring and installing libcupsfilters
with e.g. `--prefix=$HOME/temp/cpdb` and then configuring
cups-filters with `PKG_CONFIG_PATH=$HOME/temp/cpdb/lib/pkgconfig/`,
`make pclmtoraster` would fail like this:
CC filter/pclmtoraster.o
filter/pclmtoraster.c:14:10: fatal error: cupsfilters/filter.h: No such file or directory
14 | #include <cupsfilters/filter.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
For this to actually work, recent libcupsfilters
commit [1] is also needed:
Eli Schwartz [Fri, 8 Mar 2024 12:02:33 +0000 (07:02 -0500)]
configure: Fix broken bashism resulting in logic failure (#567)
After carefully using configure checks designed to work on pre-unix wars
bourne shells -- that is, the `test "$var" = ""` construct once upon a
time wasn't specified to treat "" as a distinct argument, and various
buggy implementations mishandled various forms where the first argument
started with a dash, so the "x" padding provided a guaranteed comparison
-- the configure.ac check then fails to run on any shells at all other
than GNU bash.
Bash provides the standard `test XXX = YYY` or `[ XXX = YYY ]`
utilities. It also provides the ability to spell the equals sign as a
double equals. This does nothing whatsoever -- it adds no new
functionality to bash, it forbids nothing, it is *literally* an exact
alias.
It should never be used under any circumstances. All developers must
immediately forget that it exists. Using it is non-portable and does not
work in /bin/sh scripts such as configure scripts, and it results in
dangerous muscle memory when used in bash scripts because it makes
people unthinkingly use the double equals even in /bin/sh scripts. To
add insult to injury, it makes scripts take up more disk space (by a
whole byte! and sometimes even a few bytes...)
Delete this accidental bashism, and restore the ability to get correct
./configure behavior on systems where /bin/sh is something other than a
symlink to GNU bash.
Enable application/vnd.cups-postscript in conversion tables (#534)
Unfortunately there are filters which produce this MIME type (such as
hpps from hplip), and if someone uses such driver on client and server
has IPP Everywhere/driverless driver, job fails.
The patch (together with change in libcupsfilters, which will come later)
fixes the issue.
Till Kamppeter [Wed, 17 May 2023 09:12:37 +0000 (11:12 +0200)]
Merge pull request from GHSA-gpxc-v2m8-fr3x
* beh backend: Use execv() instead of system() - CVE-2023-24805
With execv() command line arguments are passed as separate strings and
not the full command line in a single string. This prevents arbitrary
command execution by escaping the quoting of the arguments in a job
with forged job title.
* beh backend: Extra checks against odd/forged input - CVE-2023-24805
- Do not allow '/' in the scheme of the URI (= backend executable
name), to assure that only backends inside /usr/lib/cups/backend/
are used.
- Pre-define scheme buffer to empty string, to be defined for case of
uri being NULL.
- URI must have ':', to split off scheme, otherwise error.
- Check return value of snprintf() to create call path for backend, to
error out on truncation of a too long scheme or on complete failure
due to a completely odd scheme.
* beh backend: Further improvements - CVE-2023-24805
- Use strncat() instead of strncpy() for getting scheme from URI, the latter
does not require setting terminating zero byte in case of truncation.
- Also exclude "." or ".." as scheme, as directories are not valid CUPS
backends.
- Do not use fprintf() in sigterm_handler(), to not interfere with a
fprintf() which could be running in the main process when
sigterm_handler() is triggered.
- Use "static volatile int" for global variable job_canceled.
Adam Majer [Mon, 10 Apr 2023 14:22:46 +0000 (16:22 +0200)]
Drop C++ references and obsolete C standards (#513)
With no C++ compiler needed, there is no need to set the
CXXFLAGS or log it during configure. Furthermore, forcing
outdated C11 standard is not a good idea considering compilers
have moved on. We should not limit our feature set, including
compiler warnings, to old standards.
Steve Langasek [Fri, 17 Mar 2023 20:02:43 +0000 (13:02 -0700)]
foomatic-rip: Fix a SIGPIPE error when calling gs (#517)
https://autopkgtest.ubuntu.com/packages/f/foo2zjs/lunar/ppc64el shows
foo2zjs's testsuite failing with cups-filters 2.0beta3 on ppc64el because
the gs command here to check page count is failing with a SIGPIPE when
trying to write back to the parent. To fix this, we close gs's input fd as
soon as we know we're done writing to it. Since gs may not have started
processing its input until this happens, also give the final poll() a longer
timeout (5s instead of 1s); without this we see race conditions because
foomatic-rip gives up before gs has had a chance to finish processing.
Till Kamppeter [Wed, 18 Jan 2023 20:48:10 +0000 (17:48 -0300)]
COPYING, NOTICE: Simplification for autotools-generated files
autotools-generated files can be included under the license of the
upstream code, and FSF copyright added to upstream copyright
list. Simplified debian/copyright appropriately.
Till Kamppeter [Tue, 17 Jan 2023 16:53:23 +0000 (13:53 -0300)]
Build system: Do not explicitly check for libpoppler-cpp
The cups-filters does not contain any code using libpoppler-cpp,
therefore we let ./configure not check for it. This makes building
distribution packages easier.
Till Kamppeter [Fri, 6 Jan 2023 19:13:29 +0000 (16:13 -0300)]
README.md: Removed Printer Application links
The package cups-filters only contains classic CUPS filters and
backends, not relevant for Printer Applications, as they would use the
underlying filter functions of libcupsfilters.
Till Kamppeter [Thu, 17 Nov 2022 12:58:03 +0000 (13:58 +0100)]
Removed everything which got split out
In the New Architecture for printing we switch to an all-IPP workflow
with PPD files being abolished and classic CUPS printer drivers
replaced by Printer Applications (software emulation of driverless IPP
printers).
To conserve the functionality of the CUPS filters which got developed
over the last 20+ years into a PPD-less, IPP-driven world without
having to maintain and include the legacy PPD support in OS
distributions and other system environments, the original cups-filters
package got split into 5 separate packages: libcupsfilters, libppd,
cups-filters, braille-printer-app, and cups-browsed, with
libcupsfilters and braille-printer-app not containing PPD file support
code any more and cups-browsed being planned to drop explicit use of
PPD files.
This commit drops everything from the cups-filters repository which
got split out into the other 4, new repositories.
What remains are the CUPS filter executables, from which most are
wrappers around filter functions implemented in the libcupsfilters and
libppd libraries, backends, the "driverless" utility for setting up
driverless printers with classic printer setup tools, and auxiliary
files (PPD files, *.drv files, MIME rules, ...).
This package is needed for using CUPS 2.x with filters from
libcupsfilters (2.x) and libppd.
It is not needed/does not make sense to be used with CUPS 3.x or the
CUPS Snap (or any other containerized CUPS implementation). If you
need printer drivers for such CUPS versions, use Printer Applications.
Till Kamppeter [Mon, 14 Nov 2022 22:33:16 +0000 (23:33 +0100)]
Added DEVELOPING.md and CONTRIBUTING.md
These files are mainly overtaken from CUPS. They provide information
for contributors: Coding style, contact, where to report bugs/post
feature requests, ...
- Renamed NEWS to CHANGES.md
- Moved changes on 1.x to CHANGES-1.x.md
- As changes for 2.0b1 listed all changes compared to the last 1.x release
(1.28.16), in preparation for the separation already divided up by the
components.
- Converted README to README.md, some updates of the text.
Till Kamppeter [Fri, 11 Nov 2022 19:19:57 +0000 (20:19 +0100)]
Data files: Changed license info to Apache 2.0
Changed the license info in the file headers to the license used by
CUPS, on PostScript files, *.drv PPD generator files, M4 files, MIME
rules, and PPD files.
Till Kamppeter [Sun, 23 Oct 2022 19:21:41 +0000 (21:21 +0200)]
cups-browsed, driverless: Code clean-up for code of the utilities
Cleaned up the code in the utils/ drirectory following the coding
style rules in the DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, all the file's header comments reflect the new license,
Apache 2.0, the same license as used for CUPS.
Note that we did not clean up driverless.c, as here we still accept a
major code contribution from the GSoC.
Till Kamppeter [Sat, 22 Oct 2022 14:32:45 +0000 (16:32 +0200)]
CUPS backends: Code clean-up for code in backend/
Cleaned up the code of the legacy CUPS backends following the coding
style rules in the DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, all the file's header comments reflect the new license
now, Apache 2.0, the same license as used for CUPS.
Till Kamppeter [Fri, 21 Oct 2022 21:56:00 +0000 (23:56 +0200)]
CUPS filters: Code clean-up for code in filter/
Cleaned up the code of the legacy CUPS filters/filter function
wrappers following the coding style rules in the DEVELOPING.md file of
the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, all the file's header comments reflect the new license
now, Apache 2.0, the same license as used for CUPS.
Till Kamppeter [Wed, 19 Oct 2022 21:38:59 +0000 (23:38 +0200)]
libppd: Code clean-up for code of foomatic-rip
Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
The indent width is set to 2 spaces instead of 4, to match the other
files.
This way we get rid of the mix of many different coding styles which
came together from the many code contributions received during more
than a decade, even before the start of the cups-filters project.
libcupsfilters 2.x (cfFilterGhostscript() filter function) requires
Ghostscript 10.00.0 for a "cups"/"pwgraster"/"appleraster"/"urf"
output device with full support for PPD-less use. Ghostscript 10.01.0
is recommended, to fix
Till Kamppeter [Sun, 16 Oct 2022 07:19:26 +0000 (09:19 +0200)]
libcupsfilters, libppd: cfFilterExternal() filter function
Moved the core functionality of the ppdFilterExternalCUPS() filter
function from libppd into libcupsfilters, as the new
cfFilterExternal() filter function.
This way also in applications without PPD file support, not using
libppd, external filter executables can be easily integrated in filter
function chains. This is for example needed if filters are not written
in C and conversion gets too awkward and error-prone, or is not even
possible (like with closed-source filters).
The Braille embosser printer driver for example contains filters which
are shell scripts.
External filters must use the call scheme of either CUPS filters or
System V interface scripts. Both call schemes are merely the same,
only in the CUPS filters there got added that input can come from
stdin instead of only via files named in the 6th and further command
line arguments.
ppdFilterExternalCUPS() is a wrapper around cfFilterExternal() now and
does not more than setting the cups-specific environment variables
CUPS_DATADIR, CUPS_SERVERBIN, CUPS_SERVERROOT, CUPS_STATEDIR,
SOFTWARE, CONTENT_TYPE, FINAL_CONTENT_TYPE, PRINTER, PPD, DEVICE_URI
to emulate a cUPS environment as good as possible. The PPD's file name
for the PPD environment variable is taken from the "libppd" extension
for the filter data.
For calling CUPS backends for job execution, the DEVICE_URI
environment variable must be set to the CUPS device URI of the
printer. This can be done by setting the variable right away or adding
it to the environment variable list in the parameters.
The parameters data structure for both cfFilterExternal() and
ppdFilterExternalCUPS() is cf_filter_external_t (in
cupsfilters/filter.h) now and not ppd_filter_external_cups_t any
more. Here the device_uri field got removed (the DEVICE_URI
environment variable has to be used instead) and the is_backend field
got replaced by exec_mode. exec_mode allows 4 setting: -1 for System V
interface scripts (input is file named by 6th command line argument),
0 for CUPS filter (input via stdin), 1 for CUPS backend in job
execution mode, 2 for CUPS backend in device discovery mode (no
command line arguments).
To allow easy handling of the environment variable list in the
parameters, the envp field, the internal helper functions
add_env_var() and get_env_var() got promoted into the API, as
cfFilterAddEnvVar() and cfFilterGetEnvVar(). This allows also libppd
to use these functions.
For testing and debugging any changes on cfFilterExternal() and
ppdFilterExternalCUPS() a new wrapper pseudo CUPS filter,
"test-external", source file filter/test-external.c, got added. This
one is mainly intended to be called manually. To tell which filter or
backend should be called and in which mode, one of the environment
variables INTERFACE, FILTER, CUPSFILTER, or CUPSBACKEND has to be set
to the filter/backend executable.
Till Kamppeter [Sat, 15 Oct 2022 14:13:50 +0000 (16:13 +0200)]
libcupsfilters: Added info about source of human-readable option strings
The files cupsfilters/catalog.c and cupsfilters/catalog.h contain an
API to obtain human-readable and translated strings for printer
options and choices. Document where the actual strings are taken from.
Till Kamppeter [Sat, 15 Oct 2022 13:23:10 +0000 (15:23 +0200)]
libppd: Code clean-up for code of libppd
Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, all the file's header comments reflect the new license,
Apache 2.0, the same license as used for CUPS.
Till Kamppeter [Tue, 11 Oct 2022 23:02:42 +0000 (01:02 +0200)]
libcupsfilters: Code clean-up for code of testpdf1 and testpdf2
Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, one can now supply a fon file as argument to testpdf2, so
that this program embeds the supplied font instead of a standard one.
Till Kamppeter [Tue, 11 Oct 2022 22:40:52 +0000 (00:40 +0200)]
libcupsfilters: Move test suite programs to cupsfilters/
Two test suite programs for libcupsfilters, test_pdf1.c and
test_pdf2.c were still in the filter/ directory. This commit moves
them into cupsfilters and correct their naming style.
Till Kamppeter [Tue, 11 Oct 2022 06:49:40 +0000 (08:49 +0200)]
libcupsfilters: Renamed functions and types in fontembed code
Renamed all functions and types in the source files in the fontembed/
subdirectory tofollow the rules of DEVELOPING.md of CUPS.
To distinguish functions and types internal to only fontembed/ and
internal to the whole libcupsfilters, the ones internal to fontembed/
have two underscores in the beginning of their names now
("__cfFontEmbed...", "__cf_fontembed_...") while the ones which form
the internal API to libcupsfilters have only one ("_cfFontEmbed...",
"_cf_fontembed_...").
Also considered the API of fontembed as internal to
libcupsfilters. Therefore renamed cupsfilters/fontembed.h to
cupsfilters/fontembed-private.h and not installing it into
/usr/include.
Till Kamppeter [Mon, 10 Oct 2022 18:34:12 +0000 (20:34 +0200)]
libfontembed, libcupsfilters: Merge libfontembed into libcupsfilters
libfontembed is only used by cups-filters, and here only by the
cfFilterTextToPDF() filter function ("texttopdf" CUPS filter, also
part of "universal" CUPS filter). It is also not used by any other
package (at least of Ubuntu Main and Universe).
To ease the separation of cups-filters into their components (similar
to CUPDS 3.x we will separate, into libcupsfilters, libppd,
cups-filters, and cups-browsed, to cleanly separate off the PPD file
support) we merge the functionality of libfontembed into
Libcupsfilters, to keep the cfFilterTextToPDF() filter function for
plain text file printing support.
Till Kamppeter [Mon, 10 Oct 2022 12:16:03 +0000 (14:16 +0200)]
libfontembed: Code clean-up for code of libfontembed
Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
Till Kamppeter [Fri, 7 Oct 2022 12:03:22 +0000 (14:03 +0200)]
libcupsfilters: Added RGBW support to cfFilterPCLmToRaster()
Requesting RGBW as destination color space (to test, use pclmtoraster
CUPS filter wrapper and PPD for HP inkjet with hpcups driver of HPLIP)
leads to wrong color output on some input files and even to a crash on
others.
This is cause by missing support for RGBW and this, instead RGB being
output into the destination file with RGBW declared as the color space
in its header.
This commit adds explicit support for RGBW output and this way solves
the problem.
Till Kamppeter [Thu, 6 Oct 2022 15:59:38 +0000 (17:59 +0200)]
libcupsfilters: Code clean-up for code of libcupsfilters
Completed the code clean-up of the source files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding style rules in the DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
Till Kamppeter [Thu, 29 Sep 2022 22:41:46 +0000 (00:41 +0200)]
libcupsfilters: Code clean-up for code of libcupsfilters
Cleaned up the second bunch of source code files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding style rules in the DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions rteceived during more than a
decade, even before the start of the cups-filters project.
Till Kamppeter [Sun, 25 Sep 2022 21:03:08 +0000 (23:03 +0200)]
libcupsfilters: Removed portability implementationsn of functions
For portability implementations of the GNU C functions getline() and
strcasestr() were included in the source code but there is nothing in
the build system making them actually used if the system does not
provide them.
Therefor we do not take them to 2.x and remove them here.
Till Kamppeter [Sat, 10 Sep 2022 06:48:48 +0000 (08:48 +0200)]
libcupsfilters: Code clean-up for code of cfFilterPDFToPDF()
Cleaned up the first bunch of source code files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding stype rules in the DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions rteceived during more than a
decade, even before the start of the cups-filters project.
Till Kamppeter [Mon, 5 Sep 2022 22:06:10 +0000 (00:06 +0200)]
libcupsfilters: Code clean-up for code of cfFilterPDFToPDF()
Cleaned up all the source code files of the cfFilterPDFToPDF() filter
function (all files in cupsfilters/pdftopdf/) following the coding
stype rules in the DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Till Kamppeter [Sun, 4 Sep 2022 13:22:57 +0000 (15:22 +0200)]
Removed PHP and Perl APIs
The included PHP and Perl APIs did not get actually maintained and
especially never used by anyone. They still were on the API level of
CUPS 1.2. And the Perl part was not even supported by the build system
(only the scripting/perl/ directory in EXTRA_DIST to get it into the
source tarball).
Therefore we do not take it over into cups-filters 2.x and drop it
here.
Till Kamppeter [Sun, 4 Sep 2022 12:59:33 +0000 (14:59 +0200)]
libcupsfilters: Removed support for legacy image formats
Removed support for the legacy image formats GIF, Photo CD, X Pixmap,
X Bitmap, PNM (Portable Anymap/Bitmap/Graymap/Pixmap), BMP, SGI RGB,
Sun Raster. This is to avoid the requirement to maintain gthe code
supporting these mostly obsolete image formats.
Till Kamppeter [Sat, 3 Sep 2022 18:08:14 +0000 (20:08 +0200)]
libcupsfilters: Update comments about filter functions in filter.h
The filter functions cfFilterGhostscript() and cfFilterPWGtoPDF()
allow the output format also to be supplied as parameter and not
only via filter data structure.
Till Kamppeter [Sat, 3 Sep 2022 18:00:30 +0000 (20:00 +0200)]
libcupsfilters: Let cfFilterUniversal() not se unnecessary parameters
With the new fields content_type and final_content_type in the filter
data structure the output format does not need to get supplied as
parameter any more for most filter functions. So let
cfFilterUniversal() not supply any parameters any more to filter
functions which do not use them any more.
Till Kamppeter [Sat, 3 Sep 2022 16:31:42 +0000 (18:31 +0200)]
libcupsfilters: Do not feed CUPS Raster into cfFilterPWGToPDF()
- In cfFilterUniversal() correct filter chains to always feed PWG
Raster (or Apple Raster) into cfFilterPWGToPDF():
o After cfFilterImageToRaster() call cfFilterRasterToPWG() before
cfFilterPWGToPDF()
o Do not accept CUPS Raster as input format for cfFilterUniversal(),
so we only need to convert PWG Raster and Apple Raster to PDF,
which works with cfFilterPWGToPDF(). CUPS Raster as input is
actually not needed, as it is not used as network format for print
jobs but only internally by CUPS, usually for Raster drivers. Also
updated the MIME rules to not accept CUPS Raster.
o Convert application/vnd.adobe-reader-postscript (PostScript from
Adobe Reader) always to PDF via cfFilterGhostscript() (to PWG
Raster) and cfFilterPWGToPDF() (to PDF). Removed the other paths
for simplification. Also made sure that the filters to convert PDF
to the final format get added to the chain.
- Let cfFilterRasterToPWG() also accept the final output format PCLm
and then create PWG Raster, in preparation for cfFilterPWGToPDF().
- Let cfFilterPWGToRaster() not accept PCLm as final output format as
its input format (PWG or Apple Raster) is directly accepted by
cfFilterPWGToPDF() and so this filter is not needed for PCLm as
final output format.
- These changes also fix printing
application/vnd.adobe-reader-postscript (PostScript from Adobe
Reader) with the cfFilterUniversal() filter function.
Till Kamppeter [Fri, 2 Sep 2022 23:31:37 +0000 (01:31 +0200)]
libcupsfilters: Renamed cfFilterRasterToPDF() to cfFilterPWGToPDF()
Renamed the filter function cfFilterRasterToPDF() to
cfFilterPWGToPDF() as it actually does not work with CUPS Raster input
but only with PWG Raster input (or URF/Apple Raster).
Also renamed the corresponding CUPS filters to pwgtopdf and pwgtopclm.
Till Kamppeter [Fri, 2 Sep 2022 22:58:48 +0000 (00:58 +0200)]
libcupsfilters: In cfFilterPDFToRaster() Fixed margins of output pages
The PDF rasterizing filter function cfFilterPDFToRaster() which is
based on Poppler and usually only used when Ghostscript is not
available did not get enough testing and produced raster files with
wrong margins.
This commit fixes the problems:
- Apply "MediaClass"/"media-class" option only if final output format
is CUPS Raster or PWG Raster. Let the option do not change any thing
if not present. When switching the format due to this option, also
change the outformat variable.
- Supply a pointer to the outformat to parse_opts(), so that if
parse_opts() changes the outformat the caller gets this change.
- The cfFilterRasterToPCLm() filter function only accepts PWG Raster
as input, not CUPS Raster.
Till Kamppeter [Fri, 2 Sep 2022 11:24:51 +0000 (13:24 +0200)]
libcupsfilters: cfFilterUniversal() supports also Poppler's pdftops now
Added support for Poppler's pdftops instead of Ghostscript for PDF
rendering by the universal filter function cfFilterUniversal().
By conditional compiling either the filter functions to use
Ghostscript or the ones to use pdftops are used. This can be
controlled via ./configure script, by using the "--disable-..."
argument for the unwished PDF renderer. If both PDF renderers are
enabled, Ghostscript is preferred.
If pdftops is used, the cfFilterUniversal() filter function does not
support PostScript input. For this Ghostscript is required.
If both Ghostscript and pdftops are disabled by ./configure arguments,
the "universal" CUPS filter wrapper is not installed, to not use the
then rather crippled cfFilterUniversal() filter function as CUPS
filter.
Till Kamppeter [Thu, 1 Sep 2022 21:58:21 +0000 (23:58 +0200)]
Build system: Improvements for ./configure script
- Make sure that always a valid PDF-to-PostScript renderer is
selected, especially if one or another renderer is disabled, like
"hybrid" ("--with-pdftops=hybrid") does not make sense if Ghostscipt
is disabled ("--disable ghostscript"). In this case the first valid
renderer found will beused.
- In the summary at the end report which PDF-to-PostScript renderer
gets actually used.
- Changed oder of treating the PDF-to-PostScript renderer, so that as
first choice Ghostscript would be taken and as second choice
Poppler's pdftops.
- Generate for each supported PDF renderer a "HAVE_..." macro in
config.h, for easily excluding unnecessary code.
Till Kamppeter [Tue, 30 Aug 2022 18:02:49 +0000 (20:02 +0200)]
libppd: In ppdFilterUniversal() set output data type also if no PPD supplied
Now both cfFilterUniversal() and its PPD file support wrapper
ppdFilterUniversal() are absolutely compatible if no PPD file got
supplied via named extension to the filter data.
Before, if no PPD was supplied and no actual_output_type in the
parameters, the output data type stayed undetermined and the function
errored out not being able to find a filter combination for the
requested conversion.
Now always final_content_type of thef ilter data is used if there is
no actual_output_type specified in the parameters, regardless of
whether we have a PPD file or not.
Till Kamppeter [Mon, 29 Aug 2022 16:13:06 +0000 (18:13 +0200)]
libppd: Improvements on ppdLoadAttributes() PPD-to-printer-IPP-attributes
As this function is for telling filters and drivers how to print a job
on the printer for which the supplied PPD is and NOT for a PPD
retro-fitting Printer Application (or any other PPD-supporting IPP
print server) to answer a get-printer-attributes IPP request several
changes were needed.
- More sophisticated way to find the default resolution. Do not only
look for "*DefaultResolution:" but also the result of a
ppdRasterInterpretPPD() call, what is marked in the "Resolution"
option, "*cupsUrfSupported:", "*cupsPwgRaster...", "*cupsPclm..."
(from PPD generator of libppd).
- To determine the supported output formats take care that in
"*cupsFilter2: ..." lines in the PPD the final output format is the
second word and no the first, as in "*cupsFilter: ..." lines.
- For media-col-ready use the same entry as for media-col-default and
for media-ready use the same entry as for media-default.
- For print-content-optimize-supported, use the 5 standard values, no
just "auto".
- Removed the irrelevant parts about supplies. They produced constant,
device-independent output anyway.
- Removed the document-password-supported attribute.
- When synthesizing a device ID, also create a CMD: field from the
MIME rules in the "*cupsFilter(2): ..." lines.
Till Kamppeter [Sun, 28 Aug 2022 21:49:32 +0000 (23:49 +0200)]
libppd: Corrections for determining resolution in ppdFilterPDFToPS()
If we have a PPD file we use ppdRasterInterpretPPD() to determine the
actual resolution of the current job. Only consider the resolution
invalid if both horizontal and vertical resolution are 100 dpi.
When getting resolution from PPD's "Resolution" option setting or
default resolution, set y resolution to x resolution if we have only
one number ("600dpi").
Till Kamppeter [Sun, 28 Aug 2022 15:55:56 +0000 (17:55 +0200)]
libppd: In ppdLoadAttributes() complete custom page size support
If the user has sent a job on a custom page size, these custom size is
correctly set as default size in the printer IPP attributes derived
from the PPD file, as media-col, with dimensions, margins, and PWG
specifying the size in the units originally used for it.
Also added the custom page size range keywords to the
"media-supported" printer IPP attribute.
Till Kamppeter [Sat, 27 Aug 2022 23:16:02 +0000 (01:16 +0200)]
libcupsfilters: Compare case-insesitively in cfFilterUniversal()
Case-sensitive comparing of MIME types does not make sense, there are
no two MIME types where the names only differ by lower/uppar
case. This way wrongly written MIME types (like application/pclm
instead of application/PCLm) are no problem any more.
Till Kamppeter [Sat, 27 Aug 2022 23:04:32 +0000 (01:04 +0200)]
libppd: In ppdFilterLoadPPD() let PDF filter log pages when output is PS
PostScript output is going through the ppdFilterPSToPS() filter to
insert the PostScript code of the option settings into the PostScript
output data stream. The ppdFilterPSToPS() filter only logs pages if
the PPD is a pure PostScript PPD (without "*cupsFilter(2): ..."
lines). If it is not, the PDF filter has to log. This change lets the
PDF filter log the pages in such a case.
Till Kamppeter [Sat, 27 Aug 2022 20:53:45 +0000 (22:53 +0200)]
libppd: In ppdFilterLoadPPD() correct check for final output type
To determine whether the PDF filter (usually cfFilterPDFToPDF()) has
to do the page logging for CUPS ("PAGE: XX YY" log messages) or the
driver filter, we check the final output type (FINAL_CONTENT_TYPE
environment cariable from CUPS) to see whether a driver filter is
involved which should log the pages by itself.
The code to compare the final output type with the "*cupsFilter(2):
..." lines in the PPD file was broken, which is fixed with this
commit.