From: Michael R Sweet Date: Tue, 15 Oct 2019 21:06:53 +0000 (-0400) Subject: Merge pull request #5621 from zdohnal/cgigetarray-sigsegv X-Git-Tag: v2.3.1~42 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fcups.git;a=commitdiff_plain;h=e35d176c54420e940c32cff2fe8d638b89630dde;hp=eda46e3aac94d42e4199d95befe99ff83afb098f Merge pull request #5621 from zdohnal/cgigetarray-sigsegv SIGSEGV in CUPS web ui when adding a printer --- diff --git a/.gitignore b/.gitignore index dd9be570a..2a8d1e42a 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ cups/testppd cups/testpwg cups/testraster cups/testsnmp +cups/testthreads cups/tlscheck desktop/cups.desktop doc/index.html diff --git a/CHANGES.md b/CHANGES.md index 9a434e750..c2635dddd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,11 +1,30 @@ -CHANGES - 2.3.0 - 2019-07-16 +CHANGES - 2.3.1 - 2019-10-15 ============================ +Changes in CUPS v2.3.1 +---------------------- + +- Documentation updates (Issue #5661) +- PPD files containing "custom" option keywords did not work (Issue #5639) +- Added a workaround for the scheduler's systemd support (Issue #5640) +- Fixed spelling of "fold-accordion". +- Fixed the default common name for TLS certificates used by `ippeveprinter`. +- Fixed a bug in the handling of printer resource files (Issue #5652) +- The libusb-based USB backend now reports an error when the distribution + permissions are wrong (Issue #5658) +- Added paint can labels to Dymo driver (Issue #5662) +- The IPP backend did not detect all cases where a job should be retried using + a raster format (rdar://56021091) + + Changes in CUPS v2.3.0 ---------------------- +- CVE-2019-8696 and CVE-2019-8675: Fixed SNMP buffer overflows (rdar://51685251) +- Added a GPL2/LGPL2 exception to the new CUPS license terms. - Documentation updates (Issue #5604) +- Localization updates (Issue #5637) - Fixed a bug in the scheduler job cleanup code (Issue #5588) - Fixed builds when there is no TLS library (Issue #5590) - Eliminated some new GCC compiler warnings (Issue #5591) @@ -14,6 +33,7 @@ Changes in CUPS v2.3.0 - Fixed potential excess logging from the scheduler when removing job files (Issue #5597) - Fixed a NULL pointer dereference bug in `httpGetSubField2` (Issue #5598) +- Added FIPS-140 workarounds for GNU TLS (Issue #5601, Issue #5622) - The scheduler no longer provides a default value for the description (Issue #5603) - The scheduler now logs jobs held for authentication using the error level so @@ -23,12 +43,23 @@ Changes in CUPS v2.3.0 - The scheduler now uses both the group's membership list as well as the various OS-specific membership functions to determine whether a user belongs to a named group (Issue #5613) +- Added USB quirks rule for HP LaserJet 1015 (Issue #5617) +- Fixed some PPD parser issues (Issue #5623, Issue #5624) +- The IPP parser no longer allows invalid member attributes in collections + (Issue #5630) +- The configure script now treats the "wheel" group as a potential system + group (Issue #5638) +- Fixed a USB printing issue on macOS (rdar://31433931) +- Fixed IPP buffer overflow (rdar://50035411) +- Fixed memory disclosure issue in the scheduler (rdar://51373853) +- Fixed DoS issues in the scheduler (rdar://51373929) - Fixed an issue with unsupported "sides" values in the IPP backend (rdar://51775322) - The scheduler would restart continuously when idle and printers were not shared (rdar://52561199) - Fixed an issue with `EXPECT !name WITH-VALUE ...` tests. - Fixed a command ordering issue in the Zebra ZPL driver. +- Fixed a memory leak in `ppdOpen`. Changes in CUPS v2.3rc1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index be2ab40d5..2421d0d9c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,13 +2,14 @@ Contributing to CUPS ==================== CUPS is developed by Apple Inc. and distributed as open source software under -the Apache License, Version 2.0. Significant contributions to CUPS must be -licensed to Apple using the Apple Contributor Agreement: +the Apache License, Version 2.0 with exceptions to allow linking to GPL2/LGPL2 +code. Significant contributions to CUPS must be licensed to Apple using the +Apple Contributor Agreement: https://www.cups.org/AppleContributorAgreement_2011-03-10.pdf -Contributions should be submitted as attachments to bug reports on the CUPS web -site. Changes to existing source files should be submitted as unified diffs -(both Subversion and Git produce this format by default) while new source files +Contributions should be submitted as attachments to bug reports on the +[CUPS Github project](https://github.com/apple/cups). Changes to existing +source files should be submitted as unified diffs while new source files should be provided as-is or in an archive. Github pull requests can also be used to submit changes. diff --git a/CREDITS.md b/CREDITS.md index 7d5a8b9c5..8b1a15df8 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -1,4 +1,4 @@ -CREDITS - 2017-05-01 +CREDITS - 2019-08-21 ==================== Few projects are completed by one person, and CUPS is no exception. We'd like diff --git a/DEVELOPING.md b/DEVELOPING.md index 027ddc12f..df76323c8 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -63,7 +63,9 @@ major, minor, and patch release numbers. Major release numbers indicate large design changes or backwards-incompatible changes to the CUPS API or CUPS Imaging API. Minor release numbers indicate new features and other smaller changes which are backwards-compatible with previous CUPS releases. Patch -numbers indicate bug fixes to the previous feature or patch release. +numbers indicate bug fixes to the previous feature or patch release. This +version numbering scheme is consistent with the +[Semantic Versioning](http://semver.org) specification. > Note: > @@ -114,6 +116,10 @@ Contributed source code must follow the guidelines below. While the examples are for C and C++ source files, source code for other languages should conform to the same guidelines as allowed by the language. +Source code comments provide the reference portion of the CUPS Programming +Manual, which is generated using the [codedoc](https://www.msweet.org/codedoc) +software. + ### Source Files @@ -270,15 +276,17 @@ Return/output values are indicated using an "O" prefix, input values are indicated using the "I" prefix, and values that are both input and output use the "IO" prefix for the corresponding in-line comment. -The Mini-XML documentation generator also understands the following special -text in the function description comment: +The [codedoc](https://www.msweet.org/codedoc) documentation generator also +understands the following special text in the function description comment: - @deprecated@ - Marks the function as deprecated (not recommended - for new development and scheduled for removal) + @deprecated@ - Marks the function as deprecated: not recommended + for new development and scheduled for removal. + @link name@ - Provides a hyperlink to the corresponding function + or type definition. @since CUPS version@ - Marks the function as new in the specified version of CUPS. - @private@ - Marks the function as private (same as starting the - function name with an underscore) + @private@ - Marks the function as private so it will not be + included in the documentation. ### Variables diff --git a/INSTALL.md b/INSTALL.md index 16ba32899..d2afc4cf9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,4 +1,4 @@ -INSTALL - CUPS v2.3.0 - 2019-05-24 +INSTALL - CUPS v2.3.0 - 2019-08-21 ================================== This file describes how to compile and install CUPS from source code. For more diff --git a/NOTICE b/NOTICE index 5393010d2..bf088fdb0 100644 --- a/NOTICE +++ b/NOTICE @@ -1,6 +1,6 @@ CUPS -Copyright © 2007-2018 by Apple Inc. +Copyright © 2007-2019 by Apple Inc. Copyright © 1997-2007 by Easy Software Products. CUPS and the CUPS logo are trademarks of Apple Inc. @@ -32,3 +32,20 @@ the following restrictions: 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. + + +-- CUPS Exceptions to the Apache 2.0 License -- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. diff --git a/README.md b/README.md index 59c09c699..ee1125b34 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,9 @@ -README - CUPS v2.3.0 - 2019-05-24 +README - CUPS v2.3.1 - 2019-10-07 ================================= -Looking for compile instructions? Read the file `INSTALL.md` instead... - - INTRODUCTION ------------ - CUPS is a standards-based, open source printing system developed by Apple Inc. for macOS® and other UNIX®-like operating systems. CUPS uses the Internet Printing Protocol ("IPP") and provides System V and Berkeley command-line @@ -29,8 +25,21 @@ CUPS is licensed under the Apache License Version 2.0. See the file READING THE DOCUMENTATION ------------------------- +Initial documentation to get you started is provided in the root directory of +the CUPS sources: + +- `CHANGES.md`: A list of changes in the current major release of CUPS. +- `CONTRIBUTING.md`: Guidelines for contributing to the CUPS project. +- `CREDITS.md`: A list of past contributors to the CUPS project. +- `DEVELOPING.md`: Guidelines for developing code for the CUPS project. +- `INSTALL.md`: Instructions for building and installing CUPS. +- `LICENSE`: The CUPS license agreement (Apache 2.0). +- `NOTICE`: Copyright notices and exceptions to the CUPS license agreement. +- `README.md`: This file. + Once you have installed the software you can access the documentation (and a -bunch of other stuff) online at . +bunch of other stuff) online at and using the `man` +command, for example `man cups`. If you're having trouble getting that far, the documentation is located under the `doc/help` and `man` directories. @@ -56,11 +65,11 @@ in your browser to access the printer administration tools: *Do not* use the hostname for your machine - it will not work with the default CUPS configuration. To enable administration access on other addresses, check -the `Allow Remote Administration` box and click on the `Change Settings button. +the `Allow Remote Administration` box and click on the `Change Settings` button. You will be asked for the administration password (root or any other user in the -sys/system/root/admin/lpadmin group on your system) when performing any -administrative function. +"sys", "system", "root", "admin", or "lpadmin" group on your system) when +performing any administrative function. SETTING UP PRINTER QUEUES FROM THE COMMAND-LINE @@ -70,28 +79,28 @@ CUPS currently uses PPD (PostScript Printer Description) files that describe printer capabilities and driver programs needed for each printer. The `everywhere` PPD is used for nearly all modern networks printers sold since about 2009. For example, the following command creates a print queue for a -printer at address 11.22.33.44: +printer at address "11.22.33.44": lpadmin -p printername -E -v ipp://11.22.33.44/ipp/print -m everywhere CUPS also includes several sample PPD files you can use for "legacy" printers: - Driver PPD Name - ----------------------------- ------------------------------ - Dymo Label Printers drv:///sample.drv/dymo.ppd - Intellitech Intellibar drv:///sample.drv/intelbar.ppd - EPSON 9-pin Series drv:///sample.drv/epson9.ppd - EPSON 24-pin Series drv:///sample.drv/epson24.ppd - Generic PCL Laser Printer drv:///sample.drv/generpcl.ppd - Generic PostScript Printer drv:///sample.drv/generic.ppd - HP DeskJet Series drv:///sample.drv/deskjet.ppd - HP LaserJet Series drv:///sample.drv/laserjet.ppd - OKIDATA 9-Pin Series drv:///sample.drv/okidata9.ppd - OKIDATA 24-Pin Series drv:///sample.drv/okidat24.ppd - Zebra CPCL Label Printer drv:///sample.drv/zebracpl.ppd - Zebra EPL1 Label Printer drv:///sample.drv/zebraep1.ppd - Zebra EPL2 Label Printer drv:///sample.drv/zebraep2.ppd - Zebra ZPL Label Printer drv:///sample.drv/zebra.ppd + Driver | PPD Name + ----------------------------- | ------------------------------ + Dymo Label Printers | drv:///sample.drv/dymo.ppd + Intellitech Intellibar | drv:///sample.drv/intelbar.ppd + EPSON 9-pin Series | drv:///sample.drv/epson9.ppd + EPSON 24-pin Series | drv:///sample.drv/epson24.ppd + Generic PCL Laser Printer | drv:///sample.drv/generpcl.ppd + Generic PostScript Printer | drv:///sample.drv/generic.ppd + HP DeskJet Series | drv:///sample.drv/deskjet.ppd + HP LaserJet Series | drv:///sample.drv/laserjet.ppd + OKIDATA 9-Pin Series | drv:///sample.drv/okidata9.ppd + OKIDATA 24-Pin Series | drv:///sample.drv/okidat24.ppd + Zebra CPCL Label Printer | drv:///sample.drv/zebracpl.ppd + Zebra EPL1 Label Printer | drv:///sample.drv/zebraep1.ppd + Zebra EPL2 Label Printer | drv:///sample.drv/zebraep2.ppd + Zebra ZPL Label Printer | drv:///sample.drv/zebra.ppd You can run the `lpinfo -m` command to list all of the available drivers: @@ -151,9 +160,9 @@ LEGAL STUFF Copyright © 2007-2019 by Apple Inc. Copyright © 1997-2007 by Easy Software Products. -CUPS is provided under the terms of the Apache License, Version 2.0. A copy of -this license can be found in the file `LICENSE`. Additional legal information -is provided in the file `NOTICE`. +CUPS is provided under the terms of the Apache License, Version 2.0 with +exceptions for GPL2/LGPL2 software. A copy of this license can be found in the +file `LICENSE`. Additional legal information is provided in the file `NOTICE`. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR diff --git a/backend/ipp.c b/backend/ipp.c index 8226acc7b..b2b22065e 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -1450,6 +1450,8 @@ main(int argc, /* I - Number of command-line args */ monitor.printer_state = IPP_PSTATE_IDLE; monitor.retryable = argc == 6 && document_format && strcmp(document_format, "image/pwg-raster") && strcmp(document_format, "image/urf"); + fprintf(stderr, "DEBUG: retryable=%d\n", monitor.retryable); + if (create_job) { monitor.job_name = argv[3]; @@ -1867,21 +1869,29 @@ main(int argc, /* I - Number of command-line args */ response = cupsGetResponse(http, resource); ippDelete(request); - fprintf(stderr, "DEBUG: Send-Document: %s (%s)\n", - ippErrorString(cupsLastError()), cupsLastErrorString()); + fprintf(stderr, "DEBUG: Send-Document: %s (%s)\n", ippErrorString(cupsLastError()), cupsLastErrorString()); debug_attributes(response); - ippDelete(response); if (cupsLastError() > IPP_STATUS_OK_CONFLICTING && !job_canceled) { + ipp_attribute_t *reasons = ippFindAttribute(response, "job-state-reasons", IPP_TAG_KEYWORD); + /* job-state-reasons values */ + ipp_status = cupsLastError(); - _cupsLangPrintFilter(stderr, "ERROR", - _("Unable to add document to print job.")); + if (ippContainsString(reasons, "document-format-error")) + ipp_status = IPP_STATUS_ERROR_DOCUMENT_FORMAT_ERROR; + else if (ippContainsString(reasons, "document-unprintable")) + ipp_status = IPP_STATUS_ERROR_DOCUMENT_UNPRINTABLE; + + ippDelete(response); + _cupsLangPrintFilter(stderr, "ERROR", _("Unable to add document to print job.")); break; } else { + ippDelete(response); + password_tries = 0; if (num_files == 0 || fd < 0) @@ -1898,7 +1908,7 @@ main(int argc, /* I - Number of command-line args */ fprintf(stderr, "PAGE: 1 %d\n", copies_sup ? atoi(argv[4]) : 1); copies_remaining --; } - else if ((ipp_status == IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED || ipp_status == IPP_STATUS_ERROR_DOCUMENT_UNPRINTABLE) && + else if ((ipp_status == IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED || ipp_status == IPP_STATUS_ERROR_DOCUMENT_FORMAT_ERROR || ipp_status == IPP_STATUS_ERROR_DOCUMENT_UNPRINTABLE) && argc == 6 && document_format && strcmp(document_format, "image/pwg-raster") && strcmp(document_format, "image/urf")) { diff --git a/backend/org.cups.usb-quirks b/backend/org.cups.usb-quirks index 44d6bb8cb..cd684d33f 100644 --- a/backend/org.cups.usb-quirks +++ b/backend/org.cups.usb-quirks @@ -242,6 +242,9 @@ # All Intermec devices (Issue #4553) 0x067e no-reattach +# HP LaserJet 1015 (Issue #5617) +0x03f0 0x0e17 delay-close + # HP LaserJet 1150 (Issue #4549) 0x03f0 0x0f17 delay-close diff --git a/backend/usb-darwin.c b/backend/usb-darwin.c index d6ad5875d..1c412da6f 100644 --- a/backend/usb-darwin.c +++ b/backend/usb-darwin.c @@ -1280,6 +1280,9 @@ static Boolean find_device_cb(io_service_t obj, printer_interface_t printerIntf, (*printerIntf)->GetInterfaceNumber(printerIntf, &intfNumber); (*printerIntf)->GetLocationID(printerIntf, &intfLocation); + if (intfProtocol == kUSBPrintingProtocolIPP) + return keepLooking; + if (g.serial != NULL && CFStringGetLength(g.serial) > 0) { if (serial != NULL && CFStringCompare(serial, g.serial, kCFCompareCaseInsensitive) == kCFCompareEqualTo) @@ -1287,12 +1290,9 @@ static Boolean find_device_cb(io_service_t obj, printer_interface_t printerIntf, g.interfaceProtocol = intfProtocol; g.location = intfLocation; g.alternateSetting = intfAltSetting; - if (intfProtocol != kUSBPrintingProtocolIPP) - { - g.printer_obj = obj; - IOObjectRetain(obj); - } - keepLooking = (intfProtocol == kUSBPrintingProtocolIPP); + g.printer_obj = obj; + IOObjectRetain(obj); + keepLooking = false; } } else @@ -1300,14 +1300,14 @@ static Boolean find_device_cb(io_service_t obj, printer_interface_t printerIntf, if (g.printer_obj != 0) IOObjectRelease(g.printer_obj); + if (g.location == 0 || g.location == intfLocation) + keepLooking = false; + g.location = intfLocation; g.alternateSetting = intfAltSetting; g.interfaceProtocol = intfProtocol; g.printer_obj = obj; IOObjectRetain(obj); - - if (g.location == 0 || g.location == intfLocation) - keepLooking = false; } if (!keepLooking) diff --git a/backend/usb-libusb.c b/backend/usb-libusb.c index 87606ac13..1c4d9f117 100644 --- a/backend/usb-libusb.c +++ b/backend/usb-libusb.c @@ -826,8 +826,7 @@ find_device(usb_cb_t cb, /* I - Callback function */ err = libusb_init(NULL); if (err) { - fprintf(stderr, "DEBUG: Unable to initialize USB access via libusb, " - "libusb error %i\n", (int)err); + fprintf(stderr, "ERROR: Unable to initialize USB access via libusb, libusb error %i (%s)\n", (int)err, libusb_strerror((int)err)); return (NULL); } diff --git a/berkeley/lpr.c b/berkeley/lpr.c index a9aed3ca4..627fa6a4e 100644 --- a/berkeley/lpr.c +++ b/berkeley/lpr.c @@ -1,7 +1,7 @@ /* * "lpr" command for CUPS. * - * Copyright © 2007-2018 by Apple Inc. + * Copyright © 2007-2019 by Apple Inc. * Copyright © 1997-2007 by Easy Software Products. * * Licensed under Apache License v2.0. See the file "LICENSE" for more @@ -445,9 +445,9 @@ usage(void) " Specify 2-sided portrait printing")); _cupsLangPuts(stdout, _("-o sides=two-sided-short-edge\n" " Specify 2-sided landscape printing")); + _cupsLangPuts(stdout, _("-P destination Specify the destination")); _cupsLangPuts(stdout, _("-q Specify the job should be held for printing")); _cupsLangPuts(stdout, _("-r Remove the file(s) after submission")); - _cupsLangPuts(stdout, _("-P destination Specify the destination")); _cupsLangPuts(stdout, _("-T title Specify the job title")); _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index f8c57639f..f087809f7 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -2929,6 +2929,9 @@ do_set_options(http_t *http, /* I - HTTP connection */ switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_POINTS : if (!_cups_strncasecmp(option->defchoice, "Custom.", 7)) { @@ -3528,6 +3531,9 @@ get_option_value( switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_CURVE : case PPD_CUSTOM_INVCURVE : case PPD_CUSTOM_REAL : @@ -3606,6 +3612,9 @@ get_option_value( switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_CURVE : case PPD_CUSTOM_INVCURVE : case PPD_CUSTOM_REAL : diff --git a/config-scripts/cups-compiler.m4 b/config-scripts/cups-compiler.m4 index 86e8bc488..63ea1f470 100644 --- a/config-scripts/cups-compiler.m4 +++ b/config-scripts/cups-compiler.m4 @@ -175,8 +175,10 @@ if test -n "$GCC"; then # doesn't trigger... gccversion=`$CC --version | head -1 | awk '{print $NF}'` case "$gccversion" in - 7.* | 8.*) - WARNING_OPTIONS="$WARNING_OPTIONS -Wno-format-truncation -Wno-tautological-compare" + 1.* | 2.* | 3.* | 4.* | 5.* | 6.* | \(clang-*) + ;; + *) + WARNING_OPTIONS="$WARNING_OPTIONS -Wno-format-truncation -Wno-format-overflow -Wno-tautological-compare" ;; esac diff --git a/config-scripts/cups-defaults.m4 b/config-scripts/cups-defaults.m4 index b3d96ef0a..517539e1f 100644 --- a/config-scripts/cups-defaults.m4 +++ b/config-scripts/cups-defaults.m4 @@ -245,7 +245,7 @@ AC_ARG_WITH(system_groups, [ --with-system-groups set default system groups AC_MSG_CHECKING(for default system groups) if test -f /etc/group; then CUPS_SYSTEM_GROUPS="" - GROUP_LIST="lpadmin sys system root" + GROUP_LIST="lpadmin sys system root wheel" for group in $GROUP_LIST; do if test "`grep \^${group}: /etc/group`" != ""; then if test "x$CUPS_SYSTEM_GROUPS" = x; then diff --git a/configure b/configure index 840b42c34..8c6e6e8f4 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for CUPS 2.3.0. +# Generated by GNU Autoconf 2.69 for CUPS 2.3.1. # # Report bugs to . # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='CUPS' PACKAGE_TARNAME='cups' -PACKAGE_VERSION='2.3.0' -PACKAGE_STRING='CUPS 2.3.0' +PACKAGE_VERSION='2.3.1' +PACKAGE_STRING='CUPS 2.3.1' PACKAGE_BUGREPORT='https://github.com/apple/cups/issues' PACKAGE_URL='https://www.cups.org/' @@ -1467,7 +1467,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures CUPS 2.3.0 to adapt to many kinds of systems. +\`configure' configures CUPS 2.3.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1532,7 +1532,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of CUPS 2.3.0:";; + short | recursive ) echo "Configuration of CUPS 2.3.1:";; esac cat <<\_ACEOF @@ -1713,7 +1713,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -CUPS configure 2.3.0 +CUPS configure 2.3.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2177,7 +2177,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by CUPS $as_me 2.3.0, which was +It was created by CUPS $as_me 2.3.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2694,7 +2694,7 @@ done ac_config_headers="$ac_config_headers config.h" -CUPS_VERSION="2.3.0" +CUPS_VERSION="2.3.1" CUPS_REVISION="" CUPS_BUILD="cups-$CUPS_VERSION" @@ -6911,8 +6911,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # doesn't trigger... gccversion=`$CC --version | head -1 | awk '{print $NF}'` case "$gccversion" in - 7.* | 8.*) - WARNING_OPTIONS="$WARNING_OPTIONS -Wno-format-truncation -Wno-tautological-compare" + 1.* | 2.* | 3.* | 4.* | 5.* | 6.* | \(clang-*) + ;; + *) + WARNING_OPTIONS="$WARNING_OPTIONS -Wno-format-truncation -Wno-format-overflow -Wno-tautological-compare" ;; esac @@ -9593,7 +9595,7 @@ else $as_echo_n "checking for default system groups... " >&6; } if test -f /etc/group; then CUPS_SYSTEM_GROUPS="" - GROUP_LIST="lpadmin sys system root" + GROUP_LIST="lpadmin sys system root wheel" for group in $GROUP_LIST; do if test "`grep \^${group}: /etc/group`" != ""; then if test "x$CUPS_SYSTEM_GROUPS" = x; then @@ -10385,7 +10387,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by CUPS $as_me 2.3.0, which was +This file was extended by CUPS $as_me 2.3.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -10448,7 +10450,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -CUPS config.status 2.3.0 +CUPS config.status 2.3.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 7eca9e37f..23abe870e 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,7 @@ dnl We need at least autoconf 2.60... AC_PREREQ(2.60) dnl Package name and version... -AC_INIT([CUPS], [2.3.0], [https://github.com/apple/cups/issues], [cups], [https://www.cups.org/]) +AC_INIT([CUPS], [2.3.1], [https://github.com/apple/cups/issues], [cups], [https://www.cups.org/]) sinclude(config-scripts/cups-opsys.m4) sinclude(config-scripts/cups-common.m4) diff --git a/cups/Dependencies b/cups/Dependencies index b30c76994..1cb291bd9 100644 --- a/cups/Dependencies +++ b/cups/Dependencies @@ -188,7 +188,7 @@ tls.o: tls.c cups-private.h string-private.h ../config.h \ ipp-private.h ../cups/cups.h file.h ipp.h http.h array.h language.h \ pwg.h http-private.h ../cups/language.h ../cups/http.h \ language-private.h ../cups/transcode.h pwg-private.h thread-private.h \ - debug-internal.h debug-private.h tls-darwin.c + debug-internal.h debug-private.h tls-darwin.c tls-darwin.h transcode.o: transcode.c cups-private.h string-private.h ../config.h \ ../cups/versioning.h array-private.h ../cups/array.h versioning.h \ ipp-private.h ../cups/cups.h file.h ipp.h http.h array.h language.h \ @@ -214,7 +214,7 @@ adminutil.o: adminutil.c cups-private.h string-private.h ../config.h \ language-private.h ../cups/transcode.h pwg-private.h thread-private.h \ debug-internal.h debug-private.h ppd.h cups.h raster.h adminutil.h backchannel.o: backchannel.c cups.h file.h versioning.h ipp.h http.h \ - array.h language.h pwg.h + array.h language.h pwg.h sidechannel.h backend.o: backend.c cups-private.h string-private.h ../config.h \ ../cups/versioning.h array-private.h ../cups/array.h versioning.h \ ipp-private.h ../cups/cups.h file.h ipp.h http.h array.h language.h \ @@ -401,6 +401,9 @@ testsnmp.o: testsnmp.c cups-private.h string-private.h ../config.h \ pwg.h http-private.h ../cups/language.h ../cups/http.h \ language-private.h ../cups/transcode.h pwg-private.h thread-private.h \ snmp-private.h +testthreads.o: testthreads.c ../cups/cups.h file.h versioning.h ipp.h \ + http.h array.h language.h pwg.h ../cups/thread-private.h ../config.h \ + ../cups/versioning.h tlscheck.o: tlscheck.c cups-private.h string-private.h ../config.h \ ../cups/versioning.h array-private.h ../cups/array.h versioning.h \ ipp-private.h ../cups/cups.h file.h ipp.h http.h array.h language.h \ diff --git a/cups/Makefile b/cups/Makefile index 87d85babc..4e2aa6d37 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -106,6 +106,7 @@ TESTOBJS = \ testpwg.o \ testraster.o \ testsnmp.o \ + testthreads.o \ tlscheck.o OBJS = \ $(LIBOBJS) \ @@ -191,6 +192,7 @@ UNITTARGETS = \ testpwg \ testraster \ testsnmp \ + testthreads \ tlscheck TARGETS = \ @@ -700,6 +702,16 @@ testsnmp: testsnmp.o $(LIBCUPSSTATIC) $(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@ +# +# testthreads (dependency on static CUPS library is intentional) +# + +testthreads: testthreads.o $(LIBCUPSSTATIC) + echo Linking $@... + $(LD_CC) $(ALL_LDFLAGS) -o $@ testthreads.o $(LINKCUPSSTATIC) + $(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@ + + # # tlscheck (dependency on static CUPS library is intentional) # diff --git a/cups/cups.h b/cups/cups.h index e64fdcc96..77a66c17b 100644 --- a/cups/cups.h +++ b/cups/cups.h @@ -42,10 +42,10 @@ extern "C" { * Constants... */ -# define CUPS_VERSION 2.0300 +# define CUPS_VERSION 2.0301 # define CUPS_VERSION_MAJOR 2 # define CUPS_VERSION_MINOR 3 -# define CUPS_VERSION_PATCH 0 +# define CUPS_VERSION_PATCH 1 # define CUPS_BC_FD 3 /* Back-channel file descriptor for diff --git a/cups/dest-options.c b/cups/dest-options.c index f4d75105c..8c5fe666c 100644 --- a/cups/dest-options.c +++ b/cups/dest-options.c @@ -59,7 +59,7 @@ static void cups_update_ready(http_t *http, cups_dinfo_t *dinfo); /* * 'cupsAddDestMediaOptions()' - Add the option corresponding to the specified media size. * - * @since CUPS 2.3@ + * @since CUPS 2.3/macOS 10.14@ */ int /* O - New number of options */ diff --git a/cups/encode.c b/cups/encode.c index bda910be7..2469406e2 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -1,7 +1,7 @@ /* * Option encoding routines for CUPS. * - * Copyright © 2007-2018 by Apple Inc. + * Copyright © 2007-2019 by Apple Inc. * Copyright © 1997-2007 by Easy Software Products. * * Licensed under Apache License v2.0. See the file "LICENSE" for more @@ -673,7 +673,7 @@ _cupsEncodeOption( /* * 'cupsEncodeOption()' - Encode a single option into an IPP attribute. * - * @since CUPS 2.3@ + * @since CUPS 2.3/macOS 10.14@ */ ipp_attribute_t * /* O - New attribute or @code NULL@ on error */ diff --git a/cups/hash.c b/cups/hash.c index 061486076..4fbb443db 100644 --- a/cups/hash.c +++ b/cups/hash.c @@ -16,6 +16,7 @@ # include #elif defined(HAVE_GNUTLS) # include +# include "md5-internal.h" #else # include "md5-internal.h" #endif /* __APPLE__ */ @@ -185,8 +186,24 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */ unsigned char temp[64]; /* Temporary hash buffer */ size_t tempsize = 0; /* Truncate to this size? */ + if (!strcmp(algorithm, "md5")) - alg = GNUTLS_DIG_MD5; + { + /* + * Some versions of GNU TLS disable MD5 without warning... + */ + + _cups_md5_state_t state; /* MD5 state info */ + + if (hashsize < 16) + goto too_small; + + _cupsMD5Init(&state); + _cupsMD5Append(&state, data, datalen); + _cupsMD5Finish(&state, hash); + + return (16); + } else if (!strcmp(algorithm, "sha")) alg = GNUTLS_DIG_SHA1; else if (!strcmp(algorithm, "sha2-224")) @@ -242,6 +259,9 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */ { _cups_md5_state_t state; /* MD5 state info */ + if (hashsize < 16) + goto too_small; + _cupsMD5Init(&state); _cupsMD5Append(&state, data, datalen); _cupsMD5Finish(&state, hash); diff --git a/cups/http.c b/cups/http.c index 266a15791..fbb1bf13c 100644 --- a/cups/http.c +++ b/cups/http.c @@ -1860,7 +1860,7 @@ httpPrintf(http_t *http, /* I - HTTP connection */ ...) /* I - Additional args as needed */ { ssize_t bytes; /* Number of bytes to write */ - char buf[16384]; /* Buffer for formatted string */ + char buf[65536]; /* Buffer for formatted string */ va_list ap; /* Variable argument pointer */ @@ -1872,7 +1872,12 @@ httpPrintf(http_t *http, /* I - HTTP connection */ DEBUG_printf(("3httpPrintf: (" CUPS_LLFMT " bytes) %s", CUPS_LLCAST bytes, buf)); - if (http->data_encoding == HTTP_ENCODING_FIELDS) + if (bytes > (ssize_t)(sizeof(buf) - 1)) + { + http->error = ENOMEM; + return (-1); + } + else if (http->data_encoding == HTTP_ENCODING_FIELDS) return ((int)httpWrite2(http, buf, (size_t)bytes)); else { diff --git a/cups/ipp-support.c b/cups/ipp-support.c index 7d028b4f2..192f5b6b8 100644 --- a/cups/ipp-support.c +++ b/cups/ipp-support.c @@ -460,7 +460,7 @@ static const char * const ipp_document_states[] = "punch-multiple-top", /* IPP Finishings 2.1/Canon */ "punch-multiple-right",/* IPP Finishings 2.1/Canon */ "punch-multiple-bottom",/* IPP Finishings 2.1/Canon */ - "fold-accordian", /* IPP Finishings 2.0 */ + "fold-accordion", /* IPP Finishings 2.0 */ "fold-double-gate", /* IPP Finishings 2.0 */ "fold-gate", /* IPP Finishings 2.0 */ "fold-half", /* IPP Finishings 2.0 */ @@ -571,7 +571,7 @@ static const char * const ipp_document_states[] = "0x40000057", "0x40000058", "0x40000059", - "cups-fold-accordian", + "cups-fold-accordion", "cups-fold-double-gate", "cups-fold-gate", "cups-fold-half", diff --git a/cups/ipp.c b/cups/ipp.c index 0248cb9d2..1bd59cef1 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -3040,8 +3040,13 @@ ippReadIO(void *src, /* I - Data source */ DEBUG_printf(("2ippReadIO: name length=%d", n)); - if (n == 0 && tag != IPP_TAG_MEMBERNAME && - tag != IPP_TAG_END_COLLECTION) + if (n && parent) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid named IPP attribute in collection."), 1); + DEBUG_puts("1ippReadIO: bad attribute name in collection."); + return (IPP_STATE_ERROR); + } + else if (n == 0 && tag != IPP_TAG_MEMBERNAME && tag != IPP_TAG_END_COLLECTION) { /* * More values for current attribute... @@ -4545,9 +4550,7 @@ ippSetValueTag( break; case IPP_TAG_NAME : - if (temp_tag != IPP_TAG_KEYWORD && temp_tag != IPP_TAG_URI && - temp_tag != IPP_TAG_URISCHEME && temp_tag != IPP_TAG_LANGUAGE && - temp_tag != IPP_TAG_MIMETYPE) + if (temp_tag != IPP_TAG_KEYWORD) return (0); (*attr)->value_tag = (ipp_tag_t)(IPP_TAG_NAME | ((*attr)->value_tag & IPP_TAG_CUPS_CONST)); @@ -4555,10 +4558,7 @@ ippSetValueTag( case IPP_TAG_NAMELANG : case IPP_TAG_TEXTLANG : - if (value_tag == IPP_TAG_NAMELANG && - (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD && - temp_tag != IPP_TAG_URI && temp_tag != IPP_TAG_URISCHEME && - temp_tag != IPP_TAG_LANGUAGE && temp_tag != IPP_TAG_MIMETYPE)) + if (value_tag == IPP_TAG_NAMELANG && (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD)) return (0); if (value_tag == IPP_TAG_TEXTLANG && temp_tag != IPP_TAG_TEXT) diff --git a/cups/ipp.h b/cups/ipp.h index 6402855a7..b7412a40c 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -145,11 +145,11 @@ typedef enum ipp_finishings_e /**** Finishings values ****/ IPP_FINISHINGS_PUNCH_QUAD_TOP, /* Punch 4 holes top edge */ IPP_FINISHINGS_PUNCH_QUAD_RIGHT, /* Punch 4 holes right side */ IPP_FINISHINGS_PUNCH_QUAD_BOTTOM, /* Punch 4 holes bottom edge */ - IPP_FINISHINGS_PUNCH_MULTIPLE_LEFT, /* Pucnh multiple holes left side */ - IPP_FINISHINGS_PUNCH_MULTIPLE_TOP, /* Pucnh multiple holes top edge */ - IPP_FINISHINGS_PUNCH_MULTIPLE_RIGHT, /* Pucnh multiple holes right side */ - IPP_FINISHINGS_PUNCH_MULTIPLE_BOTTOM, /* Pucnh multiple holes bottom edge */ - IPP_FINISHINGS_FOLD_ACCORDIAN = 90, /* Accordian-fold the paper vertically into four sections */ + IPP_FINISHINGS_PUNCH_MULTIPLE_LEFT, /* Punch multiple holes left side */ + IPP_FINISHINGS_PUNCH_MULTIPLE_TOP, /* Punch multiple holes top edge */ + IPP_FINISHINGS_PUNCH_MULTIPLE_RIGHT, /* Punch multiple holes right side */ + IPP_FINISHINGS_PUNCH_MULTIPLE_BOTTOM, /* Punch multiple holes bottom edge */ + IPP_FINISHINGS_FOLD_ACCORDION = 90, /* Accordion-fold the paper vertically into four sections */ IPP_FINISHINGS_FOLD_DOUBLE_GATE, /* Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically */ IPP_FINISHINGS_FOLD_GATE, /* Fold the top and bottom quarters of the paper towards the midline */ IPP_FINISHINGS_FOLD_HALF, /* Fold the paper in half vertically */ @@ -184,8 +184,8 @@ typedef enum ipp_finishings_e /**** Finishings values ****/ IPP_FINISHINGS_CUPS_PUNCH_QUAD_RIGHT, /* Punch 4 holes right side @exclude all@ */ IPP_FINISHINGS_CUPS_PUNCH_QUAD_BOTTOM,/* Punch 4 holes bottom edge @exclude all@ */ - IPP_FINISHINGS_CUPS_FOLD_ACCORDIAN = 0x4000005A, - /* Accordian-fold the paper vertically into four sections @exclude all@ */ + IPP_FINISHINGS_CUPS_FOLD_ACCORDION = 0x4000005A, + /* Accordion-fold the paper vertically into four sections @exclude all@ */ IPP_FINISHINGS_CUPS_FOLD_DOUBLE_GATE, /* Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically @exclude all@ */ IPP_FINISHINGS_CUPS_FOLD_GATE, /* Fold the top and bottom quarters of the paper towards the midline @exclude all@ */ IPP_FINISHINGS_CUPS_FOLD_HALF, /* Fold the paper in half vertically @exclude all@ */ @@ -198,8 +198,10 @@ typedef enum ipp_finishings_e /**** Finishings values ****/ IPP_FINISHINGS_CUPS_FOLD_Z /* Fold the paper vertically into three sections, forming a Z @exclude all@ */ } ipp_finishings_t; # ifndef _CUPS_NO_DEPRECATED +# define IPP_FINISHINGS_CUPS_FOLD_ACCORDIAN IPP_FINISHINGS_CUPS_FOLD_ACCORDION +# define IPP_FINISHINGS_FOLD_ACCORDIAN IPP_FINISHINGS_FOLD_ACCORDION # define IPP_FINISHINGS_JOB_OFFSET IPP_FINISHINGS_JOG_OFFSET - /* Long-time misspelling... */ + /* Long-time misspellings... */ typedef enum ipp_finishings_e ipp_finish_t; # endif /* !_CUPS_NO_DEPRECATED */ diff --git a/cups/md5.c b/cups/md5.c index c3b2768dd..a94646c72 100644 --- a/cups/md5.c +++ b/cups/md5.c @@ -43,7 +43,7 @@ #include "md5-internal.h" #include "string-private.h" -#if !defined(__APPLE__) && !defined(HAVE_GNUTLS) +#if !defined(__APPLE__) # define T1 0xd76aa478 # define T2 0xe8c7b756 # define T3 0x242070db @@ -338,4 +338,4 @@ _cupsMD5Finish(_cups_md5_state_t *pms, unsigned char digest[16]) for (i = 0; i < 16; ++i) digest[i] = (unsigned char)(pms->abcd[i >> 2] >> ((i & 3) << 3)); } -#endif /* !__APPLE__ && !HAVE_GNUTLS */ +#endif /* !__APPLE__ */ diff --git a/cups/ppd-emit.c b/cups/ppd-emit.c index b9b0e5ad0..8bffb2bc3 100644 --- a/cups/ppd-emit.c +++ b/cups/ppd-emit.c @@ -664,6 +664,9 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ { switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_CURVE : case PPD_CUSTOM_INVCURVE : case PPD_CUSTOM_POINTS : @@ -710,6 +713,9 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ { switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_CURVE : case PPD_CUSTOM_INVCURVE : case PPD_CUSTOM_POINTS : @@ -805,6 +811,9 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ { switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_CURVE : case PPD_CUSTOM_INVCURVE : case PPD_CUSTOM_POINTS : @@ -1007,6 +1016,9 @@ ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ { switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_CURVE : case PPD_CUSTOM_INVCURVE : case PPD_CUSTOM_POINTS : diff --git a/cups/ppd-mark.c b/cups/ppd-mark.c index 9eca0cec7..7ec0df473 100644 --- a/cups/ppd-mark.c +++ b/cups/ppd-mark.c @@ -851,6 +851,9 @@ ppd_mark_option(ppd_file_t *ppd, /* I - PPD file */ switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_CURVE : case PPD_CUSTOM_INVCURVE : case PPD_CUSTOM_REAL : @@ -928,6 +931,9 @@ ppd_mark_option(ppd_file_t *ppd, /* I - PPD file */ switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + break; + case PPD_CUSTOM_CURVE : case PPD_CUSTOM_INVCURVE : case PPD_CUSTOM_REAL : diff --git a/cups/ppd.c b/cups/ppd.c index 862201127..ff52df2e1 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -705,6 +705,8 @@ _ppdOpen( strncmp(ll, keyword, ll_len))) { DEBUG_printf(("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword)); + free(string); + string = NULL; continue; } else if (localization == _PPD_LOCALIZATION_ICC_PROFILES) @@ -724,6 +726,8 @@ _ppdOpen( if (i >= (int)(sizeof(color_keywords) / sizeof(color_keywords[0]))) { DEBUG_printf(("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword)); + free(string); + string = NULL; continue; } } @@ -988,6 +992,13 @@ _ppdOpen( goto error; } + if (cparam->type != PPD_CUSTOM_UNKNOWN) + { + pg->ppd_status = PPD_BAD_CUSTOM_PARAM; + + goto error; + } + /* * Get the parameter data... */ @@ -1861,6 +1872,13 @@ _ppdOpen( } else if (!strcmp(keyword, "PaperDimension")) { + if (!_cups_strcasecmp(name, "custom") || !_cups_strncasecmp(name, "custom.", 7)) + { + char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */ + snprintf(cname, sizeof(cname), "_%s", name); + strlcpy(name, cname, sizeof(name)); + } + if ((size = ppdPageSize(ppd, name)) == NULL) size = ppd_add_size(ppd, name); @@ -1883,6 +1901,13 @@ _ppdOpen( } else if (!strcmp(keyword, "ImageableArea")) { + if (!_cups_strcasecmp(name, "custom") || !_cups_strncasecmp(name, "custom.", 7)) + { + char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */ + snprintf(cname, sizeof(cname), "_%s", name); + strlcpy(name, cname, sizeof(name)); + } + if ((size = ppdPageSize(ppd, name)) == NULL) size = ppd_add_size(ppd, name); @@ -1912,6 +1937,13 @@ _ppdOpen( { DEBUG_printf(("2_ppdOpen: group=%p, subgroup=%p", group, subgroup)); + if (!_cups_strcasecmp(name, "custom") || !_cups_strncasecmp(name, "custom.", 7)) + { + char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */ + snprintf(cname, sizeof(cname), "_%s", name); + strlcpy(name, cname, sizeof(name)); + } + if (!strcmp(keyword, "PageSize")) { /* @@ -2636,6 +2668,7 @@ ppd_get_cparam(ppd_coption_t *opt, /* I - PPD file */ if ((cparam = calloc(1, sizeof(ppd_cparam_t))) == NULL) return (NULL); + cparam->type = PPD_CUSTOM_UNKNOWN; strlcpy(cparam->name, param, sizeof(cparam->name)); strlcpy(cparam->text, text[0] ? text : param, sizeof(cparam->text)); diff --git a/cups/ppd.h b/cups/ppd.h index 108f20e2a..f2ba50db8 100644 --- a/cups/ppd.h +++ b/cups/ppd.h @@ -226,6 +226,7 @@ typedef struct ppd_profile_s /**** sRGB Color Profiles @deprecated@ ****/ /**** New in CUPS 1.2/macOS 10.5 ****/ typedef enum ppd_cptype_e /**** Custom Parameter Type @deprecated@ ****/ { + PPD_CUSTOM_UNKNOWN = -1, /* Unknown type (error) */ PPD_CUSTOM_CURVE, /* Curve value for f(x) = x^value */ PPD_CUSTOM_INT, /* Integer number value */ PPD_CUSTOM_INVCURVE, /* Curve value for f(x) = x^(1/value) */ diff --git a/cups/sidechannel.c b/cups/sidechannel.c index b43123a8c..56a5d0116 100644 --- a/cups/sidechannel.c +++ b/cups/sidechannel.c @@ -1,10 +1,11 @@ /* * Side-channel API code for CUPS. * - * Copyright 2007-2014 by Apple Inc. - * Copyright 2006 by Easy Software Products. + * Copyright © 2007-2019 by Apple Inc. + * Copyright © 2006 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -589,8 +590,8 @@ cupsSideChannelWrite( if ((buffer = _cupsBufferGet((size_t)datalen + 4)) == NULL) return (-1); - buffer[0] = command; - buffer[1] = status; + buffer[0] = (char)command; + buffer[1] = (char)status; buffer[2] = (char)(datalen >> 8); buffer[3] = (char)(datalen & 255); diff --git a/cups/snmp.c b/cups/snmp.c index 5cefee454..6da119d76 100644 --- a/cups/snmp.c +++ b/cups/snmp.c @@ -1,7 +1,7 @@ /* * SNMP functions for CUPS. * - * Copyright © 2007-2014 by Apple Inc. + * Copyright © 2007-2019 by Apple Inc. * Copyright © 2006-2007 by Easy Software Products, all rights reserved. * * Licensed under Apache License v2.0. See the file "LICENSE" for more @@ -1167,7 +1167,7 @@ asn1_encode_snmp(unsigned char *buffer, /* I - Buffer */ memcpy(bufptr, packet->community, commlen); bufptr += commlen; - *bufptr++ = packet->request_type; /* Get-Request-PDU/Get-Next-Request-PDU */ + *bufptr++ = (unsigned char)packet->request_type; /* Get-Request-PDU/Get-Next-Request-PDU */ asn1_set_length(&bufptr, reqlen); asn1_set_integer(&bufptr, (int)packet->request_id); @@ -1233,6 +1233,9 @@ asn1_get_integer( int value; /* Integer value */ + if (*buffer >= bufend) + return (0); + if (length > sizeof(int)) { (*buffer) += length; @@ -1259,6 +1262,9 @@ asn1_get_length(unsigned char **buffer, /* IO - Pointer in buffer */ unsigned length; /* Length */ + if (*buffer >= bufend) + return (0); + length = **buffer; (*buffer) ++; @@ -1301,6 +1307,9 @@ asn1_get_oid( int number; /* OID number */ + if (*buffer >= bufend) + return (0); + valend = *buffer + length; oidptr = oid; oidend = oid + oidsize - 1; @@ -1349,9 +1358,12 @@ asn1_get_packed( int value; /* Value */ + if (*buffer >= bufend) + return (0); + value = 0; - while ((**buffer & 128) && *buffer < bufend) + while (*buffer < bufend && (**buffer & 128)) { value = (value << 7) | (**buffer & 127); (*buffer) ++; @@ -1379,6 +1391,9 @@ asn1_get_string( char *string, /* I - String buffer */ size_t strsize) /* I - String buffer size */ { + if (*buffer >= bufend) + return (NULL); + if (length > (unsigned)(bufend - *buffer)) length = (unsigned)(bufend - *buffer); @@ -1421,6 +1436,9 @@ asn1_get_type(unsigned char **buffer, /* IO - Pointer in buffer */ int type; /* Type */ + if (*buffer >= bufend) + return (0); + type = **buffer; (*buffer) ++; diff --git a/cups/testipp.c b/cups/testipp.c index 3514b94d5..aad53e46f 100644 --- a/cups/testipp.c +++ b/cups/testipp.c @@ -1,10 +1,11 @@ /* * IPP test program for CUPS. * - * Copyright © 2007-2018 by Apple Inc. + * Copyright © 2007-2019 by Apple Inc. * Copyright © 1997-2005 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -44,7 +45,7 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x01, 0x01, /* IPP version */ 0x00, 0x02, /* Print-Job operation */ 0x00, 0x00, 0x00, 0x01, - /* Request ID */ + /* Request ID */ IPP_TAG_OPERATION, @@ -74,7 +75,7 @@ static ipp_uchar_t collection[] = /* Collection buffer */ IPP_TAG_JOB, /* job group tag */ IPP_TAG_BEGIN_COLLECTION, - /* begCollection tag */ + /* begCollection tag */ 0x00, 0x09, /* Name length + name */ 'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l', 0x00, 0x00, /* No value */ @@ -83,11 +84,11 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x00, 0x0a, /* Value length + value */ 'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e', IPP_TAG_BEGIN_COLLECTION, - /* begCollection tag */ + /* begCollection tag */ 0x00, 0x00, /* Name length + name */ 0x00, 0x00, /* No value */ IPP_TAG_MEMBERNAME, - /* memberAttrName tag */ + /* memberAttrName tag */ 0x00, 0x00, /* No name */ 0x00, 0x0b, /* Value length + value */ 'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n', @@ -96,7 +97,7 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x00, 0x04, /* Value length + value */ 0x00, 0x00, 0x54, 0x56, IPP_TAG_MEMBERNAME, - /* memberAttrName tag */ + /* memberAttrName tag */ 0x00, 0x00, /* No name */ 0x00, 0x0b, /* Value length + value */ 'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n', @@ -105,7 +106,7 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x00, 0x04, /* Value length + value */ 0x00, 0x00, 0x6d, 0x24, IPP_TAG_END_COLLECTION, - /* endCollection tag */ + /* endCollection tag */ 0x00, 0x00, /* No name */ 0x00, 0x00, /* No value */ IPP_TAG_MEMBERNAME, /* memberAttrName tag */ @@ -126,12 +127,12 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x00, 0x05, /* Value length + value */ 'p', 'l', 'a', 'i', 'n', IPP_TAG_END_COLLECTION, - /* endCollection tag */ + /* endCollection tag */ 0x00, 0x00, /* No name */ 0x00, 0x00, /* No value */ IPP_TAG_BEGIN_COLLECTION, - /* begCollection tag */ + /* begCollection tag */ 0x00, 0x00, /* No name */ 0x00, 0x00, /* No value */ IPP_TAG_MEMBERNAME, /* memberAttrName tag */ @@ -139,11 +140,11 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x00, 0x0a, /* Value length + value */ 'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e', IPP_TAG_BEGIN_COLLECTION, - /* begCollection tag */ + /* begCollection tag */ 0x00, 0x00, /* Name length + name */ 0x00, 0x00, /* No value */ IPP_TAG_MEMBERNAME, - /* memberAttrName tag */ + /* memberAttrName tag */ 0x00, 0x00, /* No name */ 0x00, 0x0b, /* Value length + value */ 'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n', @@ -152,7 +153,7 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x00, 0x04, /* Value length + value */ 0x00, 0x00, 0x52, 0x08, IPP_TAG_MEMBERNAME, - /* memberAttrName tag */ + /* memberAttrName tag */ 0x00, 0x00, /* No name */ 0x00, 0x0b, /* Value length + value */ 'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n', @@ -161,7 +162,7 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x00, 0x04, /* Value length + value */ 0x00, 0x00, 0x74, 0x04, IPP_TAG_END_COLLECTION, - /* endCollection tag */ + /* endCollection tag */ 0x00, 0x00, /* No name */ 0x00, 0x00, /* No value */ IPP_TAG_MEMBERNAME, /* memberAttrName tag */ @@ -182,7 +183,72 @@ static ipp_uchar_t collection[] = /* Collection buffer */ 0x00, 0x06, /* Value length + value */ 'g', 'l', 'o', 's', 's', 'y', IPP_TAG_END_COLLECTION, - /* endCollection tag */ + /* endCollection tag */ + 0x00, 0x00, /* No name */ + 0x00, 0x00, /* No value */ + + IPP_TAG_END /* end tag */ + }; +static ipp_uchar_t bad_collection[] = /* Collection buffer (bad encoding) */ + { + 0x01, 0x01, /* IPP version */ + 0x00, 0x02, /* Print-Job operation */ + 0x00, 0x00, 0x00, 0x01, + /* Request ID */ + + IPP_TAG_OPERATION, + + IPP_TAG_CHARSET, + 0x00, 0x12, /* Name length + name */ + 'a','t','t','r','i','b','u','t','e','s','-', + 'c','h','a','r','s','e','t', + 0x00, 0x05, /* Value length + value */ + 'u','t','f','-','8', + + IPP_TAG_LANGUAGE, + 0x00, 0x1b, /* Name length + name */ + 'a','t','t','r','i','b','u','t','e','s','-', + 'n','a','t','u','r','a','l','-','l','a','n', + 'g','u','a','g','e', + 0x00, 0x02, /* Value length + value */ + 'e','n', + + IPP_TAG_URI, + 0x00, 0x0b, /* Name length + name */ + 'p','r','i','n','t','e','r','-','u','r','i', + 0x00, 0x1c, /* Value length + value */ + 'i','p','p',':','/','/','l','o','c','a','l', + 'h','o','s','t','/','p','r','i','n','t','e', + 'r','s','/','f','o','o', + + IPP_TAG_JOB, /* job group tag */ + + IPP_TAG_BEGIN_COLLECTION, + /* begCollection tag */ + 0x00, 0x09, /* Name length + name */ + 'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l', + 0x00, 0x00, /* No value */ + IPP_TAG_BEGIN_COLLECTION, + /* begCollection tag */ + 0x00, 0x0a, /* Name length + name */ + 'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e', + 0x00, 0x00, /* No value */ + IPP_TAG_INTEGER, /* integer tag */ + 0x00, 0x0b, /* Name length + name */ + 'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n', + 0x00, 0x04, /* Value length + value */ + 0x00, 0x00, 0x54, 0x56, + IPP_TAG_INTEGER, /* integer tag */ + 0x00, 0x0b, /* Name length + name */ + 'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n', + 0x00, 0x04, /* Value length + value */ + 0x00, 0x00, 0x6d, 0x24, + IPP_TAG_END_COLLECTION, + /* endCollection tag */ + 0x00, 0x00, /* No name */ + 0x00, 0x00, /* No value */ + IPP_TAG_END_COLLECTION, + /* endCollection tag */ 0x00, 0x00, /* No name */ 0x00, 0x00, /* No value */ @@ -194,7 +260,7 @@ static ipp_uchar_t mixed[] = /* Mixed value buffer */ 0x01, 0x01, /* IPP version */ 0x00, 0x02, /* Print-Job operation */ 0x00, 0x00, 0x00, 0x01, - /* Request ID */ + /* Request ID */ IPP_TAG_OPERATION, @@ -223,6 +289,7 @@ static ipp_uchar_t mixed[] = /* Mixed value buffer */ void hex_dump(const char *title, ipp_uchar_t *buffer, size_t bytes); void print_attributes(ipp_t *ipp, int indent); ssize_t read_cb(_ippdata_t *data, ipp_uchar_t *buffer, size_t bytes); +ssize_t read_hex(cups_file_t *fp, ipp_uchar_t *buffer, size_t bytes); int token_cb(_ipp_file_t *f, _ipp_vars_t *v, void *user_data, const char *token); ssize_t write_cb(_ippdata_t *data, ipp_uchar_t *buffer, size_t bytes); @@ -584,12 +651,33 @@ main(int argc, /* I - Number of command-line arguments */ ippDelete(request); + /* + * Read the bad collection data and confirm we get an error... + */ + + fputs("Read Bad Collection from Memory: ", stdout); + + request = ippNew(); + data.rpos = 0; + data.wused = sizeof(bad_collection); + data.wsize = sizeof(bad_collection); + data.wbuffer = bad_collection; + + while ((state = ippReadIO(&data, (ipp_iocb_t)read_cb, 1, NULL, request)) != IPP_STATE_DATA) + if (state == IPP_STATE_ERROR) + break; + + if (state != IPP_STATE_ERROR) + puts("FAIL (read successful)"); + else + puts("PASS"); + /* * Read the mixed data and confirm we converted everything to rangeOfInteger * values... */ - printf("Read Mixed integer/rangeOfInteger from Memory: "); + fputs("Read Mixed integer/rangeOfInteger from Memory: ", stdout); request = ippNew(); data.rpos = 0; @@ -719,6 +807,33 @@ main(int argc, /* I - Number of command-line arguments */ request = _ippFileParse(&v, argv[i], NULL); _ippVarsDeinit(&v); } + else if (strlen(argv[i]) > 4 && !strcmp(argv[i] + strlen(argv[i]) - 4, ".hex")) + { + /* + * Read a hex-encoded IPP message... + */ + + if ((fp = cupsFileOpen(argv[i], "r")) == NULL) + { + printf("Unable to open \"%s\" - %s\n", argv[i], strerror(errno)); + status = 1; + continue; + } + + request = ippNew(); + while ((state = ippReadIO(fp, (ipp_iocb_t)read_hex, 1, NULL, request)) == IPP_STATE_ATTRIBUTE); + + if (state != IPP_STATE_DATA) + { + printf("Error reading IPP message from \"%s\": %s\n", argv[i], cupsLastErrorString()); + status = 1; + + ippDelete(request); + request = NULL; + } + + cupsFileClose(fp); + } else { /* @@ -886,6 +1001,48 @@ read_cb(_ippdata_t *data, /* I - Data */ } +/* + * 'read_hex()' - Read a hex dump of an IPP request. + */ + +ssize_t /* O - Number of bytes read */ +read_hex(cups_file_t *fp, /* I - File to read from */ + ipp_uchar_t *buffer, /* I - Buffer to read */ + size_t bytes) /* I - Number of bytes to read */ +{ + size_t total = 0; /* Total bytes read */ + static char hex[256] = ""; /* Line from file */ + static char *hexptr = NULL; /* Pointer in line */ + + + while (total < bytes) + { + if (!hexptr || (isspace(hexptr[0] & 255) && isspace(hexptr[1] & 255))) + { + if (!cupsFileGets(fp, hex, sizeof(hex))) + break; + + hexptr = hex; + while (isxdigit(*hexptr & 255)) + hexptr ++; + while (isspace(*hexptr & 255)) + hexptr ++; + + if (!isxdigit(*hexptr & 255)) + { + hexptr = NULL; + continue; + } + } + + *buffer++ = (ipp_uchar_t)strtol(hexptr, &hexptr, 16); + total ++; + } + + return (total == 0 ? -1 : (ssize_t)total); +} + + /* * 'token_cb()' - Token callback for ASCII IPP data file parser. */ diff --git a/cups/testppd.c b/cups/testppd.c index 914abbd42..36707f29a 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -1245,6 +1245,10 @@ main(int argc, /* I - Number of command-line arguments */ { switch (cparam->type) { + case PPD_CUSTOM_UNKNOWN : + printf(" %s(%s): PPD_CUSTOM_UNKNOWN (error)\n", cparam->name, cparam->text); + break; + case PPD_CUSTOM_CURVE : printf(" %s(%s): PPD_CUSTOM_CURVE (%g to %g)\n", cparam->name, cparam->text, diff --git a/cups/testthreads.c b/cups/testthreads.c new file mode 100644 index 000000000..441bc9f15 --- /dev/null +++ b/cups/testthreads.c @@ -0,0 +1,268 @@ +/* + * Threaded test program for CUPS. + * + * Copyright © 2012-2019 by Apple Inc. + * + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. + */ + +/* + * Include necessary headers... + */ + +#include +#include +#include +#include + + +/* + * Local functions... + */ + +static int enum_dests_cb(void *_name, unsigned flags, cups_dest_t *dest); +static void *run_query(cups_dest_t *dest); +static void show_supported(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option, const char *value); + + +/* + * 'main()' - Main entry. + */ + +int /* O - Exit status */ +main(int argc, /* I - Number of command-line arguments */ + char *argv[]) /* I - Command-line arguments */ +{ + /* + * Go through all the available destinations to find the requested one... + */ + + (void)argc; + + cupsEnumDests(CUPS_DEST_FLAGS_NONE, -1, NULL, 0, 0, enum_dests_cb, argv[1]); + + return (0); +} + + +/* + * 'enum_dests_cb()' - Destination enumeration function... + */ + +static int /* O - 1 to continue, 0 to stop */ +enum_dests_cb(void *_name, /* I - Printer name, if any */ + unsigned flags, /* I - Enumeration flags */ + cups_dest_t *dest) /* I - Found destination */ +{ + const char *name = (const char *)_name; + /* Printer name */ + cups_dest_t *cdest; /* Copied destination */ + + + (void)flags; + + /* + * If a name was specified, compare it... + */ + + if (name && strcasecmp(name, dest->name)) + return (1); /* Continue */ + + /* + * Copy the destination and run the query on a separate thread... + */ + + cupsCopyDest(dest, 0, &cdest); + _cupsThreadWait(_cupsThreadCreate((_cups_thread_func_t)run_query, cdest)); + + cupsFreeDests(1, cdest); + + /* + * Continue if no name was specified or the name matches... + */ + + return (!name || !strcasecmp(name, dest->name)); +} + + +/* + * 'run_query()' - Query printer capabilities on a separate thread. + */ + +static void * /* O - Return value (not used) */ +run_query(cups_dest_t *dest) /* I - Destination to query */ +{ + http_t *http; /* Connection to destination */ + cups_dinfo_t *dinfo; /* Destination info */ + unsigned dflags = CUPS_DEST_FLAGS_NONE; + /* Destination flags */ + + + if ((http = cupsConnectDest(dest, dflags, 300, NULL, NULL, 0, NULL, NULL)) == NULL) + { + printf("testthreads: Unable to connect to destination \"%s\": %s\n", dest->name, cupsLastErrorString()); + return (NULL); + } + + if ((dinfo = cupsCopyDestInfo(http, dest)) == NULL) + { + printf("testdest: Unable to get information for destination \"%s\": %s\n", dest->name, cupsLastErrorString()); + return (NULL); + } + + printf("\n%s:\n", dest->name); + + show_supported(http, dest, dinfo, NULL, NULL); + + return (NULL); +} + + + +/* + * 'show_supported()' - Show supported options, values, etc. + */ + +static void +show_supported(http_t *http, /* I - Connection to destination */ + cups_dest_t *dest, /* I - Destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + const char *option, /* I - Option, if any */ + const char *value) /* I - Value, if any */ +{ + ipp_attribute_t *attr; /* Attribute */ + int i, /* Looping var */ + count; /* Number of values */ + + + if (!option) + { + attr = cupsFindDestSupported(http, dest, dinfo, "job-creation-attributes"); + if (attr) + { + count = ippGetCount(attr); + for (i = 0; i < count; i ++) + show_supported(http, dest, dinfo, ippGetString(attr, i, NULL), NULL); + } + else + { + static const char * const options[] = + { /* List of standard options */ + CUPS_COPIES, + CUPS_FINISHINGS, + CUPS_MEDIA, + CUPS_NUMBER_UP, + CUPS_ORIENTATION, + CUPS_PRINT_COLOR_MODE, + CUPS_PRINT_QUALITY, + CUPS_SIDES + }; + + puts(" No job-creation-attributes-supported attribute, probing instead."); + + for (i = 0; i < (int)(sizeof(options) / sizeof(options[0])); i ++) + if (cupsCheckDestSupported(http, dest, dinfo, options[i], NULL)) + show_supported(http, dest, dinfo, options[i], NULL); + } + } + else if (!value) + { + printf(" %s (%s - %s)\n", option, cupsLocalizeDestOption(http, dest, dinfo, option), cupsCheckDestSupported(http, dest, dinfo, option, NULL) ? "supported" : "not-supported"); + + if ((attr = cupsFindDestSupported(http, dest, dinfo, option)) != NULL) + { + count = ippGetCount(attr); + + switch (ippGetValueTag(attr)) + { + case IPP_TAG_INTEGER : + for (i = 0; i < count; i ++) + printf(" %d\n", ippGetInteger(attr, i)); + break; + + case IPP_TAG_ENUM : + for (i = 0; i < count; i ++) + { + int val = ippGetInteger(attr, i); + char valstr[256]; + + snprintf(valstr, sizeof(valstr), "%d", val); + printf(" %s (%s)\n", ippEnumString(option, ippGetInteger(attr, i)), cupsLocalizeDestValue(http, dest, dinfo, option, valstr)); + } + break; + + case IPP_TAG_RANGE : + for (i = 0; i < count; i ++) + { + int upper, lower = ippGetRange(attr, i, &upper); + + printf(" %d-%d\n", lower, upper); + } + break; + + case IPP_TAG_RESOLUTION : + for (i = 0; i < count; i ++) + { + int xres, yres; + ipp_res_t units; + xres = ippGetResolution(attr, i, &yres, &units); + + if (xres == yres) + printf(" %d%s\n", xres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); + else + printf(" %dx%d%s\n", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); + } + break; + + case IPP_TAG_KEYWORD : + for (i = 0; i < count; i ++) + printf(" %s (%s)\n", ippGetString(attr, i, NULL), cupsLocalizeDestValue(http, dest, dinfo, option, ippGetString(attr, i, NULL))); + break; + + case IPP_TAG_TEXTLANG : + case IPP_TAG_NAMELANG : + case IPP_TAG_TEXT : + case IPP_TAG_NAME : + case IPP_TAG_URI : + case IPP_TAG_URISCHEME : + case IPP_TAG_CHARSET : + case IPP_TAG_LANGUAGE : + case IPP_TAG_MIMETYPE : + for (i = 0; i < count; i ++) + printf(" %s\n", ippGetString(attr, i, NULL)); + break; + + case IPP_TAG_STRING : + for (i = 0; i < count; i ++) + { + int j, len; + unsigned char *data = ippGetOctetString(attr, i, &len); + + fputs(" ", stdout); + for (j = 0; j < len; j ++) + { + if (data[j] < ' ' || data[j] >= 0x7f) + printf("<%02X>", data[j]); + else + putchar(data[j]); + } + putchar('\n'); + } + break; + + case IPP_TAG_BOOLEAN : + break; + + default : + printf(" %s\n", ippTagString(ippGetValueTag(attr))); + break; + } + } + + } + else if (cupsCheckDestSupported(http, dest, dinfo, option, value)) + puts("YES"); + else + puts("NO"); +} diff --git a/cups/tls-darwin.c b/cups/tls-darwin.c index f18ff215f..e8c4fb713 100644 --- a/cups/tls-darwin.c +++ b/cups/tls-darwin.c @@ -15,32 +15,7 @@ */ #include - -extern char **environ; - - -#ifndef _SECURITY_VERSION_GREATER_THAN_57610_ -typedef CF_OPTIONS(uint32_t, SecKeyUsage) { - kSecKeyUsageAll = 0x7FFFFFFF -}; -#endif /* !_SECURITY_VERSION_GREATER_THAN_57610_ */ -extern const void * kSecCSRChallengePassword; -extern const void * kSecSubjectAltName; -extern const void * kSecCertificateKeyUsage; -extern const void * kSecCSRBasicContraintsPathLen; -extern const void * kSecCertificateExtensions; -extern const void * kSecCertificateExtensionsEncoded; -extern const void * kSecOidCommonName; -extern const void * kSecOidCountryName; -extern const void * kSecOidStateProvinceName; -extern const void * kSecOidLocalityName; -extern const void * kSecOidOrganization; -extern const void * kSecOidOrganizationalUnit; -extern bool SecCertificateIsValid(SecCertificateRef certificate, CFAbsoluteTime verifyTime); -extern CFAbsoluteTime SecCertificateNotValidAfter(SecCertificateRef certificate); -extern SecCertificateRef SecGenerateSelfSignedCertificate(CFArrayRef subject, CFDictionaryRef parameters, SecKeyRef publicKey, SecKeyRef privateKey); -extern SecIdentityRef SecIdentityCreate(CFAllocatorRef allocator, SecCertificateRef certificate, SecKeyRef privateKey); - +#include "tls-darwin.h" /* * Constants, very secure stuff... diff --git a/cups/tls-darwin.h b/cups/tls-darwin.h new file mode 100644 index 000000000..ca4136e3a --- /dev/null +++ b/cups/tls-darwin.h @@ -0,0 +1,35 @@ +/* + * TLS support header for CUPS on macOS. + * + * Copyright © 2007-2019 by Apple Inc. + * Copyright © 1997-2007 by Easy Software Products, all rights reserved. + * + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. + */ + +/**** This file is included from tls-darwin.c ****/ + +extern char **environ; + +#ifndef _SECURITY_VERSION_GREATER_THAN_57610_ +typedef CF_OPTIONS(uint32_t, SecKeyUsage) { + kSecKeyUsageAll = 0x7FFFFFFF +}; +#endif /* !_SECURITY_VERSION_GREATER_THAN_57610_ */ +extern const void * kSecCSRChallengePassword; +extern const void * kSecSubjectAltName; +extern const void * kSecCertificateKeyUsage; +extern const void * kSecCSRBasicContraintsPathLen; +extern const void * kSecCertificateExtensions; +extern const void * kSecCertificateExtensionsEncoded; +extern const void * kSecOidCommonName; +extern const void * kSecOidCountryName; +extern const void * kSecOidStateProvinceName; +extern const void * kSecOidLocalityName; +extern const void * kSecOidOrganization; +extern const void * kSecOidOrganizationalUnit; +extern bool SecCertificateIsValid(SecCertificateRef certificate, CFAbsoluteTime verifyTime); +extern CFAbsoluteTime SecCertificateNotValidAfter(SecCertificateRef certificate); +extern SecCertificateRef SecGenerateSelfSignedCertificate(CFArrayRef subject, CFDictionaryRef parameters, SecKeyRef publicKey, SecKeyRef privateKey); +extern SecIdentityRef SecIdentityCreate(CFAllocatorRef allocator, SecCertificateRef certificate, SecKeyRef privateKey); diff --git a/cups/versioning.h b/cups/versioning.h index aae2138e8..14c218fee 100644 --- a/cups/versioning.h +++ b/cups/versioning.h @@ -116,9 +116,9 @@ # define _CUPS_API_1_7 API_AVAILABLE(macos(10.9), ios(11.0)) _CUPS_PUBLIC # define _CUPS_API_2_0 API_AVAILABLE(macos(10.10), ios(11.0)) _CUPS_PUBLIC # define _CUPS_API_2_2 API_AVAILABLE(macos(10.12), ios(11.0)) _CUPS_PUBLIC -# define _CUPS_API_2_2_4 API_AVAILABLE(macos(10.13), ios(11.0)) _CUPS_PUBLIC -# define _CUPS_API_2_2_7 API_AVAILABLE(macos(10.14), ios(11.0)) _CUPS_PUBLIC -# define _CUPS_API_2_3 _CUPS_PUBLIC +# define _CUPS_API_2_2_4 API_AVAILABLE(macos(10.13), ios(12.0)) _CUPS_PUBLIC +# define _CUPS_API_2_2_7 API_AVAILABLE(macos(10.14), ios(13.0)) _CUPS_PUBLIC +# define _CUPS_API_2_3 API_AVAILABLE(macos(10.14), ios(13.0)) _CUPS_PUBLIC # else # define _CUPS_API_1_1_19 _CUPS_PUBLIC # define _CUPS_API_1_1_20 _CUPS_PUBLIC diff --git a/doc/help/api-admin.html b/doc/help/api-admin.html index f9969d4a9..7e6b40702 100644 --- a/doc/help/api-admin.html +++ b/doc/help/api-admin.html @@ -5,7 +5,7 @@ Administration APIs - + @@ -450,6 +450,7 @@ h3.title { --> +
+
+
+
-

CUPS Programming Manual

-

Michael R Sweet

-

Copyright © 2007-2019 by Apple Inc. All Rights Reserved.

+
+

CUPS Programming Manual

+

Michael R Sweet

+

Copyright © 2007-2019 by Apple Inc. All Rights Reserved.

+

Contents

  • Functions
  • -
  • Variables
  • Enumerations
    • cups_ptype_e
    • http_encoding_e
    • @@ -520,16 +506,20 @@ h3.title {

      Please file issues on Github to provide feedback on this document.

      -

      Introduction

      +

      Introduction

      CUPS provides the "cups" library to talk to the different parts of CUPS and with Internet Printing Protocol (IPP) printers. The "cups" library functions are accessed by including the <cups/cups.h> header.

      CUPS is based on the Internet Printing Protocol ("IPP"), which allows clients (applications) to communicate with a server (the scheduler, printers, etc.) to get a list of destinations, send print jobs, and so forth. You identify which server you want to communicate with using a pointer to the opaque structure http_t. The CUPS_HTTP_DEFAULT constant can be used when you want to talk to the CUPS scheduler.

      -

      Guidelines

      +

      Guidelines

      When writing software (other than printer drivers) that uses the "cups" library:

        -
      • Do not use undocumented or deprecated APIs,
      • -
      • Do not rely on pre-configured printers,
      • -
      • Do not assume that printers support specific features or formats, and
      • -
      • Do not rely on implementation details (PPDs, etc.)
      • +
      • Do not use undocumented or deprecated APIs,

        +
      • +
      • Do not rely on pre-configured printers,

        +
      • +
      • Do not assume that printers support specific features or formats, and

        +
      • +
      • Do not rely on implementation details (PPDs, etc.)

        +

      CUPS is designed to insulate users and developers from the implementation details of printers and file formats. The goal is to allow an application to supply a print file in a standard format with the user intent ("print four copies, two-sided on A4 media, and staple each copy") and have the printing system manage the printer communication and format conversion needed.

      Similarly, printer and job management applications can use standard query operations to obtain the status information in a common, generic form and use standard management operations to control the state of those printers and jobs.

      @@ -537,9 +527,9 @@ h3.title {

      Note:

      CUPS printer drivers necessarily depend on specific file formats and certain implementation details of the CUPS software. Please consult the Postscript and raster printer driver developer documentation on CUPS.org for more information.

      -

      Terms Used in This Document

      -

      A Destination is a printer or print queue that accepts print jobs. A Print Job is a collection of one or more documents that are processed by a destination using options supplied when creating the job. A Document is a file (JPEG image, PDF file, etc.) suitable for printing. An Option controls some aspect of printing, such as the media used. Media is the sheets or roll that is printed on. An Attribute is an option encoded for an Internet Printing Protocol (IPP) request.

      -

      Compiling Programs That Use the CUPS API

      +

      Terms Used in This Document

      +

      A Destination is a printer or print queue that accepts print jobs. A Print Job is a collection of one or more documents that are processed by a destination using options supplied when creating the job. A Document is a file (JPEG image, PDF file, etc.) suitable for printing. An Option controls some aspect of printing, such as the media used. Media is the sheets or roll that is printed on. An Attribute is an option encoded for an Internet Printing Protocol (IPP) request.

      +

      Compiling Programs That Use the CUPS API

      The CUPS libraries can be used from any C, C++, or Objective C program. The method of compiling against the libraries varies depending on the operating system and installation of CUPS. The following sections show how to compile a simple program (shown below) in two common environments.

      The following simple program lists the available destinations:

      #include <stdio.h>
      @@ -562,20 +552,20 @@ int main(void)
         return (0);
       }
       
      -

      Compiling with Xcode

      -

      In Xcode, choose New Project... from the File menu (or press SHIFT+CMD+N), then select the Command Line Tool under the macOS Application project type. Click Next and enter a name for the project, for example "firstcups". Click Next and choose a project directory. The click Next to create the project.

      -

      In the project window, click on the Build Phases group and expand the Link Binary with Libraries section. Click +, type "libcups" to show the library, and then double-click on libcups.tbd.

      +

      Compiling with Xcode

      +

      In Xcode, choose New Project... from the File menu (or press SHIFT+CMD+N), then select the Command Line Tool under the macOS Application project type. Click Next and enter a name for the project, for example "firstcups". Click Next and choose a project directory. The click Next to create the project.

      +

      In the project window, click on the Build Phases group and expand the Link Binary with Libraries section. Click +, type "libcups" to show the library, and then double-click on libcups.tbd.

      Finally, click on the main.c file in the sidebar and copy the example program to the file. Build and run (CMD+R) to see the list of destinations.

      -

      Compiling with GCC

      +

      Compiling with GCC

      From the command-line, create a file called sample.c using your favorite editor, copy the example to this file, and save. Then run the following command to compile it with GCC and run it:

      gcc -o simple `cups-config --cflags` simple.c `cups-config --libs`
       ./simple
       

      The cups-config command provides the compiler flags (cups-config --cflags) and libraries (cups-config --libs) needed for the local system.

      -

      Working with Destinations

      +

      Working with Destinations

      Destinations, which in CUPS represent individual printers or classes (collections or pools) of printers, are represented by the cups_dest_t structure which includes the name (name), instance (instance, saved options/settings), whether the destination is the default for the user (is_default), and the options and basic information associated with that destination (num_options and options).

      Historically destinations have been manually maintained by the administrator of a system or network, but CUPS also supports dynamic discovery of destinations on the current network.

      -

      Finding Available Destinations

      +

      Finding Available Destinations

      The cupsEnumDests function finds all of the available destinations:

       int
        cupsEnumDests(unsigned flags, int msec, int *cancel,
      @@ -587,24 +577,42 @@ int main(void)
           

      The cancel argument points to an integer variable that, when set to a non-zero value, will cause enumeration to stop as soon as possible. It can be NULL if not needed.

      The type and mask arguments are bitfields that allow the caller to filter the destinations based on categories and/or capabilities. The destination's "printer-type" value is masked by the mask value and compared to the type value when filtering. For example, to only enumerate destinations that are hosted on the local system, pass CUPS_PRINTER_LOCAL for the type argument and CUPS_PRINTER_DISCOVERED for the mask argument. The following constants can be used for filtering:

        -
      • CUPS_PRINTER_CLASS: A collection of destinations.
      • -
      • CUPS_PRINTER_FAX: A facsimile device.
      • -
      • CUPS_PRINTER_LOCAL: A local printer or class. This constant has the value 0 (no bits set) and is only used for the type argument and is paired with the CUPS_PRINTER_REMOTE or CUPS_PRINTER_DISCOVERED constant passed in the mask argument.
      • -
      • CUPS_PRINTER_REMOTE: A remote (shared) printer or class.
      • -
      • CUPS_PRINTER_DISCOVERED: An available network printer or class.
      • -
      • CUPS_PRINTER_BW: Can do B&W printing.
      • -
      • CUPS_PRINTER_COLOR: Can do color printing.
      • -
      • CUPS_PRINTER_DUPLEX: Can do two-sided printing.
      • -
      • CUPS_PRINTER_STAPLE: Can staple output.
      • -
      • CUPS_PRINTER_COLLATE: Can quickly collate copies.
      • -
      • CUPS_PRINTER_PUNCH: Can punch output.
      • -
      • CUPS_PRINTER_COVER: Can cover output.
      • -
      • CUPS_PRINTER_BIND: Can bind output.
      • -
      • CUPS_PRINTER_SORT: Can sort output (mailboxes, etc.)
      • -
      • CUPS_PRINTER_SMALL: Can print on Letter/Legal/A4-size media.
      • -
      • CUPS_PRINTER_MEDIUM: Can print on Tabloid/B/C/A3/A2-size media.
      • -
      • CUPS_PRINTER_LARGE: Can print on D/E/A1/A0-size media.
      • -
      • CUPS_PRINTER_VARIABLE: Can print on rolls and custom-size media.
      • +
      • CUPS_PRINTER_CLASS: A collection of destinations.

        +
      • +
      • CUPS_PRINTER_FAX: A facsimile device.

        +
      • +
      • CUPS_PRINTER_LOCAL: A local printer or class. This constant has the value 0 (no bits set) and is only used for the type argument and is paired with the CUPS_PRINTER_REMOTE or CUPS_PRINTER_DISCOVERED constant passed in the mask argument.

        +
      • +
      • CUPS_PRINTER_REMOTE: A remote (shared) printer or class.

        +
      • +
      • CUPS_PRINTER_DISCOVERED: An available network printer or class.

        +
      • +
      • CUPS_PRINTER_BW: Can do B&W printing.

        +
      • +
      • CUPS_PRINTER_COLOR: Can do color printing.

        +
      • +
      • CUPS_PRINTER_DUPLEX: Can do two-sided printing.

        +
      • +
      • CUPS_PRINTER_STAPLE: Can staple output.

        +
      • +
      • CUPS_PRINTER_COLLATE: Can quickly collate copies.

        +
      • +
      • CUPS_PRINTER_PUNCH: Can punch output.

        +
      • +
      • CUPS_PRINTER_COVER: Can cover output.

        +
      • +
      • CUPS_PRINTER_BIND: Can bind output.

        +
      • +
      • CUPS_PRINTER_SORT: Can sort output (mailboxes, etc.)

        +
      • +
      • CUPS_PRINTER_SMALL: Can print on Letter/Legal/A4-size media.

        +
      • +
      • CUPS_PRINTER_MEDIUM: Can print on Tabloid/B/C/A3/A2-size media.

        +
      • +
      • CUPS_PRINTER_LARGE: Can print on D/E/A1/A0-size media.

        +
      • +
      • CUPS_PRINTER_VARIABLE: Can print on rolls and custom-size media.

        +

      The cb argument specifies a function to call for every destination that is found:

      typedef int (*cups_dest_cb_t)(void *user_data,
      @@ -613,9 +621,12 @@ int main(void)
       

      The callback function receives a copy of the user_data argument along with a bitfield (flags) and the destination that was found. The flags argument can have any of the following constant (bit) values set:

        -
      • CUPS_DEST_FLAGS_MORE: There are more destinations coming.
      • -
      • CUPS_DEST_FLAGS_REMOVED: The destination has gone away and should be removed from the list of destinations a user can select.
      • -
      • CUPS_DEST_FLAGS_ERROR: An error occurred. The reason for the error can be found by calling the cupsLastError and/or cupsLastErrorString functions.
      • +
      • CUPS_DEST_FLAGS_MORE: There are more destinations coming.

        +
      • +
      • CUPS_DEST_FLAGS_REMOVED: The destination has gone away and should be removed from the list of destinations a user can select.

        +
      • +
      • CUPS_DEST_FLAGS_ERROR: An error occurred. The reason for the error can be found by calling the cupsLastError and/or cupsLastErrorString functions.

        +

      The callback function returns 0 to stop enumeration or 1 to continue.

      @@ -689,34 +700,45 @@ my_get_dests(cups_ptype_t type, cups_ptype_t mask, return (user_data.num_dests); }
      -

      Basic Destination Information

      +

      Basic Destination Information

      The num_options and options members of the cups_dest_t structure provide basic attributes about the destination in addition to the user default options and values for that destination. The following names are predefined for various destination attributes:

        -
      • "auth-info-required": The type of authentication required for printing to this destination: "none", "username,password", "domain,username,password", or "negotiate" (Kerberos).
      • -
      • "printer-info": The human-readable description of the destination such as "My Laser Printer".
      • -
      • "printer-is-accepting-jobs": "true" if the destination is accepting new jobs, "false" otherwise.
      • -
      • "printer-is-shared": "true" if the destination is being shared with other computers, "false" otherwise.
      • -
      • "printer-location": The human-readable location of the destination such as "Lab 4".
      • -
      • "printer-make-and-model": The human-readable make and model of the destination such as "ExampleCorp LaserPrinter 4000 Series".
      • -
      • "printer-state": "3" if the destination is idle, "4" if the destination is printing a job, and "5" if the destination is stopped.
      • -
      • "printer-state-change-time": The UNIX time when the destination entered the current state.
      • -
      • "printer-state-reasons": Additional comma-delimited state keywords for the destination such as "media-tray-empty-error" and "toner-low-warning".
      • -
      • "printer-type": The cups_ptype_t value associated with the destination.
      • -
      • "printer-uri-supported": The URI associated with the destination; if not set, this destination was discovered but is not yet setup as a local printer.
      • +
      • "auth-info-required": The type of authentication required for printing to this destination: "none", "username,password", "domain,username,password", or "negotiate" (Kerberos).

        +
      • +
      • "printer-info": The human-readable description of the destination such as "My Laser Printer".

        +
      • +
      • "printer-is-accepting-jobs": "true" if the destination is accepting new jobs, "false" otherwise.

        +
      • +
      • "printer-is-shared": "true" if the destination is being shared with other computers, "false" otherwise.

        +
      • +
      • "printer-location": The human-readable location of the destination such as "Lab 4".

        +
      • +
      • "printer-make-and-model": The human-readable make and model of the destination such as "ExampleCorp LaserPrinter 4000 Series".

        +
      • +
      • "printer-state": "3" if the destination is idle, "4" if the destination is printing a job, and "5" if the destination is stopped.

        +
      • +
      • "printer-state-change-time": The UNIX time when the destination entered the current state.

        +
      • +
      • "printer-state-reasons": Additional comma-delimited state keywords for the destination such as "media-tray-empty-error" and "toner-low-warning".

        +
      • +
      • "printer-type": The cups_ptype_t value associated with the destination.

        +
      • +
      • "printer-uri-supported": The URI associated with the destination; if not set, this destination was discovered but is not yet setup as a local printer.

        +

      Use the cupsGetOption function to retrieve the value. For example, the following code gets the make and model of a destination:

      const char *model = cupsGetOption("printer-make-and-model",
                                         dest->num_options,
                                         dest->options);
       
      -

      Detailed Destination Information

      +

      Detailed Destination Information

      Once a destination has been chosen, the cupsCopyDestInfo function can be used to gather detailed information about the destination:

      cups_dinfo_t *
       cupsCopyDestInfo(http_t *http, cups_dest_t *dest);
       

      The http argument specifies a connection to the CUPS scheduler and is typically the constant CUPS_HTTP_DEFAULT. The dest argument specifies the destination to query.

      The cups_dinfo_t structure that is returned contains a snapshot of the supported options and their supported, ready, and default values. It also can report constraints between different options and values, and recommend changes to resolve those constraints.

      -

      Getting Supported Options and Values

      +

      Getting Supported Options and Values

      The cupsCheckDestSupported function can be used to test whether a particular option or option and value is supported:

      int
       cupsCheckDestSupported(http_t *http, cups_dest_t *dest,
      @@ -726,16 +748,26 @@ cupsCheckDestSupported(http_t *http, cups_dest_t *dest,
       

      The option argument specifies the name of the option to check. The following constants can be used to check the various standard options:

        -
      • CUPS_COPIES: Controls the number of copies that are produced.
      • -
      • CUPS_FINISHINGS: A comma-delimited list of integer constants that control the finishing processes that are applied to the job, including stapling, punching, and folding.
      • -
      • CUPS_MEDIA: Controls the media size that is used, typically one of the following: CUPS_MEDIA_3X5, CUPS_MEDIA_4X6, CUPS_MEDIA_5X7, CUPS_MEDIA_8X10, CUPS_MEDIA_A3, CUPS_MEDIA_A4, CUPS_MEDIA_A5, CUPS_MEDIA_A6, CUPS_MEDIA_ENV10, CUPS_MEDIA_ENVDL, CUPS_MEDIA_LEGAL, CUPS_MEDIA_LETTER, CUPS_MEDIA_PHOTO_L, CUPS_MEDIA_SUPERBA3, or CUPS_MEDIA_TABLOID.
      • -
      • CUPS_MEDIA_SOURCE: Controls where the media is pulled from, typically either CUPS_MEDIA_SOURCE_AUTO or CUPS_MEDIA_SOURCE_MANUAL.
      • -
      • CUPS_MEDIA_TYPE: Controls the type of media that is used, typically one of the following: CUPS_MEDIA_TYPE_AUTO, CUPS_MEDIA_TYPE_ENVELOPE, CUPS_MEDIA_TYPE_LABELS, CUPS_MEDIA_TYPE_LETTERHEAD, CUPS_MEDIA_TYPE_PHOTO, CUPS_MEDIA_TYPE_PHOTO_GLOSSY, CUPS_MEDIA_TYPE_PHOTO_MATTE, CUPS_MEDIA_TYPE_PLAIN, or CUPS_MEDIA_TYPE_TRANSPARENCY.
      • -
      • CUPS_NUMBER_UP: Controls the number of document pages that are placed on each media side.
      • -
      • CUPS_ORIENTATION: Controls the orientation of document pages placed on the media: CUPS_ORIENTATION_PORTRAIT or CUPS_ORIENTATION_LANDSCAPE.
      • -
      • CUPS_PRINT_COLOR_MODE: Controls whether the output is in color (CUPS_PRINT_COLOR_MODE_COLOR), grayscale (CUPS_PRINT_COLOR_MODE_MONOCHROME), or either (CUPS_PRINT_COLOR_MODE_AUTO).
      • -
      • CUPS_PRINT_QUALITY: Controls the generate quality of the output: CUPS_PRINT_QUALITY_DRAFT, CUPS_PRINT_QUALITY_NORMAL, or CUPS_PRINT_QUALITY_HIGH.
      • -
      • CUPS_SIDES: Controls whether prints are placed on one or both sides of the media: CUPS_SIDES_ONE_SIDED, CUPS_SIDES_TWO_SIDED_PORTRAIT, or CUPS_SIDES_TWO_SIDED_LANDSCAPE.
      • +
      • CUPS_COPIES: Controls the number of copies that are produced.

        +
      • +
      • CUPS_FINISHINGS: A comma-delimited list of integer constants that control the finishing processes that are applied to the job, including stapling, punching, and folding.

        +
      • +
      • CUPS_MEDIA: Controls the media size that is used, typically one of the following: CUPS_MEDIA_3X5, CUPS_MEDIA_4X6, CUPS_MEDIA_5X7, CUPS_MEDIA_8X10, CUPS_MEDIA_A3, CUPS_MEDIA_A4, CUPS_MEDIA_A5, CUPS_MEDIA_A6, CUPS_MEDIA_ENV10, CUPS_MEDIA_ENVDL, CUPS_MEDIA_LEGAL, CUPS_MEDIA_LETTER, CUPS_MEDIA_PHOTO_L, CUPS_MEDIA_SUPERBA3, or CUPS_MEDIA_TABLOID.

        +
      • +
      • CUPS_MEDIA_SOURCE: Controls where the media is pulled from, typically either CUPS_MEDIA_SOURCE_AUTO or CUPS_MEDIA_SOURCE_MANUAL.

        +
      • +
      • CUPS_MEDIA_TYPE: Controls the type of media that is used, typically one of the following: CUPS_MEDIA_TYPE_AUTO, CUPS_MEDIA_TYPE_ENVELOPE, CUPS_MEDIA_TYPE_LABELS, CUPS_MEDIA_TYPE_LETTERHEAD, CUPS_MEDIA_TYPE_PHOTO, CUPS_MEDIA_TYPE_PHOTO_GLOSSY, CUPS_MEDIA_TYPE_PHOTO_MATTE, CUPS_MEDIA_TYPE_PLAIN, or CUPS_MEDIA_TYPE_TRANSPARENCY.

        +
      • +
      • CUPS_NUMBER_UP: Controls the number of document pages that are placed on each media side.

        +
      • +
      • CUPS_ORIENTATION: Controls the orientation of document pages placed on the media: CUPS_ORIENTATION_PORTRAIT or CUPS_ORIENTATION_LANDSCAPE.

        +
      • +
      • CUPS_PRINT_COLOR_MODE: Controls whether the output is in color (CUPS_PRINT_COLOR_MODE_COLOR), grayscale (CUPS_PRINT_COLOR_MODE_MONOCHROME), or either (CUPS_PRINT_COLOR_MODE_AUTO).

        +
      • +
      • CUPS_PRINT_QUALITY: Controls the generate quality of the output: CUPS_PRINT_QUALITY_DRAFT, CUPS_PRINT_QUALITY_NORMAL, or CUPS_PRINT_QUALITY_HIGH.

        +
      • +
      • CUPS_SIDES: Controls whether prints are placed on one or both sides of the media: CUPS_SIDES_ONE_SIDED, CUPS_SIDES_TWO_SIDED_PORTRAIT, or CUPS_SIDES_TWO_SIDED_LANDSCAPE.

        +

      If the value argument is NULL, the cupsCheckDestSupported function returns whether the option is supported by the destination. Otherwise, the function returns whether the specified value of the option is supported.

      The cupsFindDestSupported function returns the IPP attribute containing the supported values for a given option:

      @@ -772,7 +804,7 @@ int i, count = ippGetCount(attrs); for (i = 0; i < count; i ++) puts(ippGetString(attrs, i, NULL)); -

      Getting Default Values

      +

      Getting Default Values

      There are two sets of default values - user defaults that are available via the num_options and options members of the cups_dest_t structure, and destination defaults that available via the cups_dinfo_t structure and the cupsFindDestDefault function which returns the IPP attribute containing the default value(s) for a given option:

      ipp_attribute_t *
       cupsFindDestDefault(http_t *http, cups_dest_t *dest,
      @@ -802,7 +834,7 @@ else
         putchar('\n');
       }
       
      -

      Getting Ready (Loaded) Values

      +

      Getting Ready (Loaded) Values

      The finishings and media options also support queries for the ready, or loaded, values. For example, a printer may have punch and staple finishers installed but be out of staples - the supported values will list both punch and staple finishing processes but the ready values will only list the punch processes. Similarly, a printer may support hundreds of different sizes of media but only have a single size loaded at any given time - the ready values are limited to the media that is actually in the printer.

      The cupsFindDestReady function finds the IPP attribute containing the ready values for a given option:

      ipp_attribute_t *
      @@ -825,7 +857,7 @@ if (ready_finishings != NULL)
       else
         puts("no finishings are ready.");
       
      -

      Media Size Options

      +

      Media Size Options

      CUPS provides functions for querying the dimensions and margins for each of the supported media size options. The cups_size_t structure is used to describe a media size:

      typedef struct cups_size_s
       {
      @@ -850,11 +882,16 @@ cupsGetDestMediaBySize(http_t *http, cups_dest_t *dest,
       

      The media, width, and length arguments specify the size to lookup. The flags argument specifies a bitfield controlling various lookup options:

        -
      • CUPS_MEDIA_FLAGS_DEFAULT: Find the closest size supported by the printer.
      • -
      • CUPS_MEDIA_FLAGS_BORDERLESS: Find a borderless size.
      • -
      • CUPS_MEDIA_FLAGS_DUPLEX: Find a size compatible with two-sided printing.
      • -
      • CUPS_MEDIA_FLAGS_EXACT: Find an exact match for the size.
      • -
      • CUPS_MEDIA_FLAGS_READY: If the printer supports media sensing or configuration of the media in each tray/source, find the size amongst the "ready" media.
      • +
      • CUPS_MEDIA_FLAGS_DEFAULT: Find the closest size supported by the printer.

        +
      • +
      • CUPS_MEDIA_FLAGS_BORDERLESS: Find a borderless size.

        +
      • +
      • CUPS_MEDIA_FLAGS_DUPLEX: Find a size compatible with two-sided printing.

        +
      • +
      • CUPS_MEDIA_FLAGS_EXACT: Find an exact match for the size.

        +
      • +
      • CUPS_MEDIA_FLAGS_READY: If the printer supports media sensing or configuration of the media in each tray/source, find the size amongst the "ready" media.

        +

      If a matching size is found for the destination, the size information is stored in the structure pointed to by the size argument and 1 is returned. Otherwise 0 is returned.

      For example, the following code prints the margins for two-sided printing on US Letter media:

      @@ -912,7 +949,7 @@ cupsGetDestMediaDefault(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size); -

      Localizing Options and Values

      +

      Localizing Options and Values

      CUPS provides three functions to get localized, human-readable strings in the user's current locale for options and values: cupsLocalizeDestMedia, cupsLocalizeDestOption, and cupsLocalizeDestValue:

      const char *
       cupsLocalizeDestMedia(http_t *http, cups_dest_t *dest,
      @@ -929,7 +966,7 @@ cupsLocalizeDestValue(http_t *http, cups_dest_t *dest,
                             cups_dinfo_t *info,
                             const char *option, const char *value);
       
      -

      Submitting a Print Job

      +

      Submitting a Print Job

      Once you are ready to submit a print job, you create a job using the cupsCreateDestJob function:

      ipp_status_t
       cupsCreateDestJob(http_t *http, cups_dest_t *dest,
      @@ -980,10 +1017,14 @@ cupsFinishDestDocument(http_t *http, cups_dest_t *dest,
       

      The docname argument specifies the name of the document, typically the original filename. The format argument specifies the MIME media type of the document, including the following constants:

        -
      • CUPS_FORMAT_JPEG: "image/jpeg"
      • -
      • CUPS_FORMAT_PDF: "application/pdf"
      • -
      • CUPS_FORMAT_POSTSCRIPT: "application/postscript"
      • -
      • CUPS_FORMAT_TEXT: "text/plain"
      • +
      • CUPS_FORMAT_JPEG: "image/jpeg"

        +
      • +
      • CUPS_FORMAT_PDF: "application/pdf"

        +
      • +
      • CUPS_FORMAT_POSTSCRIPT: "application/postscript"

        +
      • +
      • CUPS_FORMAT_TEXT: "text/plain"

        +

      The num_options and options arguments specify per-document print options, which at present must be 0 and NULL. The last_document argument specifies whether this is the last document in the job.

      For example, the following code submits a PDF file to the job that was just created:

      @@ -1010,9 +1051,9 @@ if (cupsStartDestDocument(CUPS_HTTP_DEFAULT, dest, info, fclose(fp); -

      Sending IPP Requests

      +

      Sending IPP Requests

      CUPS provides a rich API for sending IPP requests to the scheduler or printers, typically from management or utility applications whose primary purpose is not to send print jobs.

      -

      Connecting to the Scheduler or Printer

      +

      Connecting to the Scheduler or Printer

      The connection to the scheduler or printer is represented by the HTTP connection type http_t. The cupsConnectDest function connects to the scheduler or printer associated with the destination:

      http_t *
       cupsConnectDest(cups_dest_t *dest, unsigned flags, int msec,
      @@ -1033,7 +1074,7 @@ http_t *http = cupsConnectDest(dest, CUPS_DEST_FLAGS_DEVICE,
                                      30000, NULL, resource,
                                      sizeof(resource), NULL, NULL);
       
      -

      Creating an IPP Request

      +

      Creating an IPP Request

      IPP requests are represented by the IPP message type ipp_t and each IPP attribute in the request is representing using the type ipp_attribute_t. Each IPP request includes an operation code (IPP_OP_CREATE_JOB, IPP_OP_GET_PRINTER_ATTRIBUTES, etc.) and a 32-bit integer identifier.

      The ippNewRequest function creates a new IPP request:

      ipp_t *
      @@ -1071,19 +1112,30 @@ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
           

      The ippAddStrings function adds an attribute with one or more strings, in this case three. The IPP_TAG_KEYWORD argument specifies that the strings are keyword values, which are used for attribute names. All strings use the same language (NULL), and the attribute will contain the three strings in the array requested_attributes.

      CUPS provides many functions to adding attributes of different types:

        -
      • ippAddBoolean adds a boolean (IPP_TAG_BOOLEAN) attribute with one value.
      • -
      • ippAddInteger adds an enum (IPP_TAG_ENUM) or integer (IPP_TAG_INTEGER) attribute with one value.
      • -
      • ippAddIntegers adds an enum or integer attribute with one or more values.
      • -
      • ippAddOctetString adds an octetString attribute with one value.
      • -
      • ippAddOutOfBand adds a admin-defined (IPP_TAG_ADMINDEFINE), default (IPP_TAG_DEFAULT), delete-attribute (IPP_TAG_DELETEATTR), no-value (IPP_TAG_NOVALUE), not-settable (IPP_TAG_NOTSETTABLE), unknown (IPP_TAG_UNKNOWN), or unsupported (IPP_TAG_UNSUPPORTED_VALUE) out-of-band attribute.
      • -
      • ippAddRange adds a rangeOfInteger attribute with one range.
      • -
      • ippAddRanges adds a rangeOfInteger attribute with one or more ranges.
      • -
      • ippAddResolution adds a resolution attribute with one resolution.
      • -
      • ippAddResolutions adds a resolution attribute with one or more resolutions.
      • -
      • ippAddString adds a charset (IPP_TAG_CHARSET), keyword (IPP_TAG_KEYWORD), mimeMediaType (IPP_TAG_MIMETYPE), name (IPP_TAG_NAME and IPP_TAG_NAMELANG), naturalLanguage (IPP_TAG_NATURAL_LANGUAGE), text (IPP_TAG_TEXT and IPP_TAG_TEXTLANG), uri (IPP_TAG_URI), or uriScheme (IPP_TAG_URISCHEME) attribute with one value.
      • -
      • ippAddStrings adds a charset, keyword, mimeMediaType, name, naturalLanguage, text, uri, or uriScheme attribute with one or more values.
      • +
      • ippAddBoolean adds a boolean (IPP_TAG_BOOLEAN) attribute with one value.

        +
      • +
      • ippAddInteger adds an enum (IPP_TAG_ENUM) or integer (IPP_TAG_INTEGER) attribute with one value.

        +
      • +
      • ippAddIntegers adds an enum or integer attribute with one or more values.

        +
      • +
      • ippAddOctetString adds an octetString attribute with one value.

        +
      • +
      • ippAddOutOfBand adds a admin-defined (IPP_TAG_ADMINDEFINE), default (IPP_TAG_DEFAULT), delete-attribute (IPP_TAG_DELETEATTR), no-value (IPP_TAG_NOVALUE), not-settable (IPP_TAG_NOTSETTABLE), unknown (IPP_TAG_UNKNOWN), or unsupported (IPP_TAG_UNSUPPORTED_VALUE) out-of-band attribute.

        +
      • +
      • ippAddRange adds a rangeOfInteger attribute with one range.

        +
      • +
      • ippAddRanges adds a rangeOfInteger attribute with one or more ranges.

        +
      • +
      • ippAddResolution adds a resolution attribute with one resolution.

        +
      • +
      • ippAddResolutions adds a resolution attribute with one or more resolutions.

        +
      • +
      • ippAddString adds a charset (IPP_TAG_CHARSET), keyword (IPP_TAG_KEYWORD), mimeMediaType (IPP_TAG_MIMETYPE), name (IPP_TAG_NAME and IPP_TAG_NAMELANG), naturalLanguage (IPP_TAG_NATURAL_LANGUAGE), text (IPP_TAG_TEXT and IPP_TAG_TEXTLANG), uri (IPP_TAG_URI), or uriScheme (IPP_TAG_URISCHEME) attribute with one value.

        +
      • +
      • ippAddStrings adds a charset, keyword, mimeMediaType, name, naturalLanguage, text, uri, or uriScheme attribute with one or more values.

        +
      -

      Sending the IPP Request

      +

      Sending the IPP Request

      Once you have created the IPP request, you can send it using the cupsDoRequest function. For example, the following code sends the IPP Get-Printer-Attributes request to the destination and saves the response:

      ipp_t *response = cupsDoRequest(http, request, resource);
       
      @@ -1105,7 +1157,7 @@ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, printf("Request failed: %s\n", cupsLastErrorString()); }
      -

      Processing the IPP Response

      +

      Processing the IPP Response

      Each response to an IPP request is also an IPP message (ipp_t) with its own IPP attributes (ipp_attribute_t) that includes a status code (IPP_STATUS_OK, IPP_STATUS_ERROR_BAD_REQUEST, etc.) and the corresponding 32-bit integer identifier from the request.

      For example, the following code finds the printer state attributes and prints their values:

      ipp_attribute_t *attr;
      @@ -1142,7 +1194,7 @@ if ((attr = ippFindAttribute(response, "printer-state-reasons",
           

      Once you are done using the IPP response message, free it using the ippDelete function:

      ippDelete(response);
       
      -

      Authentication

      +

      Authentication

      CUPS normally handles authentication through the console. GUI applications should set a password callback using the cupsSetPasswordCB2 function:

      void
       cupsSetPasswordCB2(cups_password_cb2_t cb, void *user_data);
      @@ -1159,19 +1211,6 @@ cups_password_cb2(const char *prompt, http_t *http,
           

      The resource argument specifies the path used for the request.

      The user_data argument provides the user data pointer from the cupsSetPasswordCB2 call.

      Functions

      -

      CF_OPTIONS

      -

      -

      -typedef CF_OPTIONS(uint32_t, SecKeyUsage);

      -

      Parameters

      - - - - - -
      uint32_t
      SecKeyUsage
      -

      Return Value

      -

      cupsAddDest

      Add a destination to the list of destinations.

      @@ -1200,7 +1239,7 @@ a copy of that destination's options.

      Use the cupsSaveDests function to save the updated list of destinations to the user's lpoptions file.

      -

       CUPS 2.3 cupsAddDestMediaOptions

      +

       CUPS 2.3/macOS 10.14 cupsAddDestMediaOptions

      Add the option corresponding to the specified media size.

      int cupsAddDestMediaOptions(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size, int num_options, cups_option_t **options);

      @@ -1511,7 +1550,7 @@ int cupsDoAuthentication(http_t *http, const char *method, status, prior to resubmitting your request.

      -

       CUPS 2.3 cupsEncodeOption

      +

       CUPS 2.3/macOS 10.14 cupsEncodeOption

      Encode a single option into an IPP attribute.

      ipp_attribute_t *cupsEncodeOption(ipp_t *ipp, ipp_tag_t group_tag, const char *name, const char *value);

      @@ -6071,10 +6110,6 @@ typedef struct _ipp_s ipp_t; Top margin in hundredths of millimeters -

      Variables

      -

      kSecOidOrganizationalUnit

      -

      Constants, very secure stuff...

      -

      extern const void *kSecOidOrganizationalUnit;

      Constants

      cups_ptype_e

      Printer type/capability bit diff --git a/doc/help/license.html b/doc/help/license.html index 9c98b279a..8086c6eac 100644 --- a/doc/help/license.html +++ b/doc/help/license.html @@ -187,5 +187,21 @@ See the License for the specific language governing permissions and limitations under the License.

      +

      CUPS Exceptions to the Apache 2.0 License

      + +

      As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License.

      + +

      In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software.

      + diff --git a/doc/help/man-ipptoolfile.html b/doc/help/man-ipptoolfile.html index 341b1fdcd..e0f6727d7 100644 --- a/doc/help/man-ipptoolfile.html +++ b/doc/help/man-ipptoolfile.html @@ -143,7 +143,7 @@ The following directives are understood within a test:
      ATTR tag attribute-name value(s)
      Adds an attribute to the test request. Out-of-band tags (admin-define, delete-attribute, no-value, not-settable, unknown, unsupported) have no value. -Values for other tags are separated by the comma (",") character - escape commas using the "" character. +Values for other tags are delimited by the comma (",") character - escape commas using the "\" character. Common attributes and values are listed in the IANA IPP registry - see references below.
      ATTR collection attribute-name { MEMBER tag member-name value(s) ... } [ ... ,{ ... } ]
      Adds a collection attribute to the test request. @@ -230,7 +230,7 @@ The following predicates are understood following the EXPECT test directi
      Makes the EXPECT conditions apply only if the specified variable is not defined.
      IN-GROUP tag
      Requires the EXPECT attribute to be in the specified group tag. -
      OF-TYPE tag[,tag,...] +
      OF-TYPE tag[|tag,...]
      Requires the EXPECT attribute to use one of the specified value tag(s).
      REPEAT-LIMIT number

      diff --git a/doc/help/postscript-driver.html b/doc/help/postscript-driver.html index f94fa72fd..59832ebdc 100644 --- a/doc/help/postscript-driver.html +++ b/doc/help/postscript-driver.html @@ -5,7 +5,7 @@ Developing PostScript Printer Drivers - + @@ -450,6 +450,7 @@ h3.title { --> +
      +
      +
      +