Skip to content

Commit

Permalink
Merge branch 'master' into ipptool
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet authored Jun 18, 2021
2 parents 24cecbd + 655ed29 commit 7521e42
Show file tree
Hide file tree
Showing 43 changed files with 19,923 additions and 400 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: update build environment
run: sudo apt-get update --fix-missing -y
- name: install prerequisites
run: sudo apt-get install -y avahi-daemon libavahi-client-dev libgnutls28-dev libpam-dev libusb-1.0-0-dev zlib1g-dev
- name: configure
Expand Down
1 change: 1 addition & 0 deletions .lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ queries:
- exclude: cpp/integer-multiplication-cast-to-long
- exclude: cpp/missing-header-guard
- exclude: cpp/short-global-name
- exclude: cpp/tainted-format-string
34 changes: 29 additions & 5 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ CUPS v2.4rc1 (Pending)
- Added support for AirPrint and Mopria clients (Issue #105)
- Added configure support for specifying systemd dependencies in the CUPS
service file (Issue #144)
- Added several features and improvements to `ipptool` (Issue #153)
- The `ipptool` command now correctly reports an error when a test file cannot
be found.
- Fixed Kerberos authentication for the web interface (Issue #19)
- The ZPL sample driver now supports more "standard" label sizes (Issue #70)
- Fixed reporting of printer instances when enumerating and when no options are
set for the main instance (Issue #71)
- Reverted USB read limit enforcement change from CUPS 2.2.12 (Issue #72)
- The IPP backend did not return the correct status code when a job was canceled
at the printer/server (Issue #74)
- The `testlang` unit test program now loops over all of the available locales
Expand All @@ -21,22 +27,40 @@ CUPS v2.4rc1 (Pending)
- The USB backend now runs as root (Issue #121)
- Added pkg-config file for libcups (Issue #122)
- Fixed a PPD memory leak caused by emulator definitions (Issue #124)
- Added several features and improvements to `ipptool` (Issue #153)
- Fixed a `DISPLAY` bug in `ipptool` (Issue #139)
- The scheduler now includes the `[Job N]` prefix for job log messages, even
when using syslog logging (Issue #154)
- Added support for locales using the GB18030 character set (Issue #159)
- `httpReconnect2` did not reset the socket file descriptor when the TLS
negotiation failed (Apple #5907)
- `httpUpdate` did not reset the socket file descriptor when the TLS
negotiation failed (Apple #5915)
- The IPP backend now retries Validate-Job requests (Issue #132)
- Added a workaround for Solaris in `httpAddrConnect2` (Issue #156)
- Now use a 60 second timeout for reading USB backchannel data (Issue #160)
- The USB backend now tries harder to find a serial number (Issue #170)
- Fixed `@IF(name)` handling in `cupsd.conf` (Apple #5918)
- Now always pass "localhost" in the `Host:` header when talking over a domain
socket or the loopback interface (Issue #185)
- Fixed a job history update issue in the scheduler (Issue #187)
- Fixed `job-pages-per-set` value for duplex print jobs.
- Fixed an edge case in `ippReadIO` to make sure that only complete attributes
and values are retained on an error (Issue #195)
- Hardened `ippReadIO` to prevent invalid IPP messages from being propagated
(Issue #195, Issue #196)
- Documentation fixes (Issue #92)
- Localization updates (Issue #123, Issue #129, Issue #134, Issue #146)
- Documentation fixes (Issue #92, Issue #163, Issue #177, Issue #184)
- Localization updates (Issue #123, Issue #129, Issue #134, Issue #146,
Issue #164)
- USB quirk updates (Issue #192, Apple #5766, Apple #5838, Apple #5843,
Apple #5867)
- Web interface updates (Issue #142)
- The `ippeveprinter` tool now automatically uses an available port.
- Fixed some Windows issues.
- Deprecated cups-config (Issue #97)
- Deprecated Kerberos (`AuthType Negotiate`) authentication (Issue #98)
- Removed support for the (long deprecated and unused) `FontPath`,
`LPDConfigFile`, `RIPCache`, and `SMBConfigFile` directives in `cupsd.conf`
and `cups-files.conf`.
`LPDConfigFile`, `KeepAliveTimeout`, `RIPCache`, and `SMBConfigFile`
directives in `cupsd.conf` and `cups-files.conf`.


CUPS v2.3.3op2 (February 1, 2021)
Expand Down
2 changes: 1 addition & 1 deletion Makedefs.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ LD_CXX = @LD_CXX@
LIBTOOL = @LIBTOOL@
LN = @LN@ -sf
MKDIR = @MKDIR@ -p
MV = @MV@
MV = @MV@ -f
RANLIB = @RANLIB@
RM = @RM@ -f
RMDIR = @RMDIR@
Expand Down
12 changes: 10 additions & 2 deletions backend/backend-private.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
* Backend support definitions for CUPS.
*
* Copyright © 2007-2014 by Apple Inc.
* Copyright © 2021 by OpenPrinting
* Copyright © 2007-2021 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
Expand Down Expand Up @@ -52,6 +53,14 @@ extern "C" {
# endif /* __cplusplus */


/*
* Log messages in backend signal handlers or other places where stdio cannot
* be used...
*/

# define backendMessage(msg) {const char *s = msg; write(2, s, strlen(s));}


/*
* OID constants...
*/
Expand Down Expand Up @@ -320,7 +329,6 @@ extern int backendSNMPSupplies(int snmp_fd, http_addr_t *addr,
extern int backendWaitLoop(int snmp_fd, http_addr_t *addr,
int use_bc, _cups_sccb_t side_cb);


# ifdef __cplusplus
}
# endif /* __cplusplus */
Expand Down
25 changes: 21 additions & 4 deletions backend/ipp.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
* IPP backend for CUPS.
*
* Copyright © 2007-2019 by Apple Inc.
* Copyright © 2021 by OpenPrinting
* Copyright © 2007-2021 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
Expand Down Expand Up @@ -256,6 +257,7 @@ main(int argc, /* I - Number of command-line args */
get_job_attrs = 0, /* Does printer support Get-Job-Attributes? */
send_document = 0, /* Does printer support Send-Document? */
validate_job = 0, /* Does printer support Validate-Job? */
validate_retried = 0, /* Was Validate-Job request retried? */
copies, /* Number of copies for job */
copies_remaining; /* Number of copies remaining */
const char *content_type, /* CONTENT_TYPE environment variable */
Expand Down Expand Up @@ -1559,7 +1561,17 @@ main(int argc, /* I - Number of command-line args */
ipp_status == IPP_STATUS_ERROR_BAD_REQUEST)
break;
else if (job_auth == NULL && ipp_status > IPP_STATUS_ERROR_BAD_REQUEST)
{
if (!validate_retried)
{
// Retry Validate-Job operation once, to work around known printer bug...
validate_retried = 1;
sleep(10);
continue;
}

goto cleanup;
}
}

/*
Expand Down Expand Up @@ -3233,7 +3245,8 @@ run_as_user(char *argv[], /* I - Command-line arguments */
const char *device_uri, /* I - Device URI */
int fd) /* I - File to print */
{
const char *auth_negotiate;/* AUTH_NEGOTIATE env var */
const char *auth_negotiate,/* AUTH_NEGOTIATE env var */
*content_type; /* [FINAL_]CONTENT_TYPE env vars */
xpc_connection_t conn; /* Connection to XPC service */
xpc_object_t request; /* Request message dictionary */
__block xpc_object_t response; /* Response message dictionary */
Expand Down Expand Up @@ -3296,6 +3309,10 @@ run_as_user(char *argv[], /* I - Command-line arguments */
getenv("AUTH_INFO_REQUIRED"));
if ((auth_negotiate = getenv("AUTH_NEGOTIATE")) != NULL)
xpc_dictionary_set_string(request, "auth-negotiate", auth_negotiate);
if ((content_type = getenv("CONTENT_TYPE")) != NULL)
xpc_dictionary_set_string(request, "content-type", content_type);
if ((content_type = getenv("FINAL_CONTENT_TYPE")) != NULL)
xpc_dictionary_set_string(request, "final-content-type", content_type);
xpc_dictionary_set_fd(request, "stdin", fd);
xpc_dictionary_set_fd(request, "stderr", 2);
xpc_dictionary_set_fd(request, "side-channel", CUPS_SC_FD);
Expand Down Expand Up @@ -3418,7 +3435,7 @@ sigterm_handler(int sig) /* I - Signal */
{
(void)sig; /* remove compiler warnings... */

write(2, "DEBUG: Got SIGTERM.\n", 20);
backendMessage("DEBUG: Got SIGTERM.\n");

#if defined(HAVE_GSSAPI) && defined(HAVE_XPC)
if (child_pid)
Expand All @@ -3434,7 +3451,7 @@ sigterm_handler(int sig) /* I - Signal */
* Flag that the job should be canceled...
*/

write(2, "DEBUG: sigterm_handler: job_canceled = 1.\n", 25);
backendMessage("DEBUG: sigterm_handler: job_canceled = 1.\n");

job_canceled = 1;
return;
Expand Down
2 changes: 1 addition & 1 deletion backend/snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ alarm_handler(int sig) /* I - Signal number */
#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */

if (DebugLevel)
write(2, "DEBUG: ALARM!\n", 14);
backendMessage("DEBUG: ALARM!\n");
}


Expand Down
5 changes: 3 additions & 2 deletions backend/testbackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <fcntl.h>
#include <sys/wait.h>
#include <signal.h>
#include "backend-private.h"


/*
Expand Down Expand Up @@ -395,15 +396,15 @@ main(int argc, /* I - Number of command-line args */
data = ps_data;

write(1, data, strlen(data));
write(2, "DEBUG: START\n", 13);
backendMessage("DEBUG: START\n");
timeout = 60.0;
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer),
timeout)) > 0)
{
write(2, buffer, (size_t)bytes);
timeout = 5.0;
}
write(2, "\nDEBUG: END\n", 12);
backendMessage("\nDEBUG: END\n");
}

exit(0);
Expand Down
57 changes: 41 additions & 16 deletions backend/usb-darwin.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
* Copyright 2005-2016 Apple Inc. All rights reserved.
* USB backend for macOS.
*
* Copyright © 2005-2021 Apple Inc. All rights reserved.
*
* IMPORTANT: This Apple software is supplied to you by Apple Computer,
* Inc. ("Apple") in consideration of your agreement to the following
Expand Down Expand Up @@ -1668,11 +1670,34 @@ static CFStringRef copy_printer_interface_deviceid(printer_interface_t printer,
CFStringAppendFormat(extras, NULL, CFSTR("MDL:%@;"), model);
}

if (serial == NULL && desc.iSerialNumber != 0)
if (desc.iSerialNumber != 0)
{
serial = copy_printer_interface_indexed_description(printer, desc.iSerialNumber, kUSBLanguageEnglish);
if (serial && CFStringGetLength(serial) > 0)
CFStringAppendFormat(extras, NULL, CFSTR("SERN:%@;"), serial);
// Always look at the USB serial number since some printers
// incorrectly include a bogus static serial number in their
// IEEE-1284 device ID string...
CFStringRef userial = copy_printer_interface_indexed_description(printer, desc.iSerialNumber, kUSBLanguageEnglish);
if (userial && CFStringGetLength(userial) > 0 && (serial == NULL || CFStringCompare(serial, userial, kCFCompareCaseInsensitive) != kCFCompareEqualTo))
{
if (serial != NULL)
{
// 1284 serial number doesn't match USB serial number, so replace the existing SERN: in device ID
CFRange range = CFStringFind(ret, serial, 0);
CFMutableStringRef deviceIDString = CFStringCreateMutableCopy(NULL, 0, ret);
CFStringReplace(deviceIDString, range, userial);
CFRelease(ret);
ret = deviceIDString;

CFRelease(serial);
}
else
{
// No 1284 serial number so add SERN: with USB serial number to device ID
CFStringAppendFormat(extras, NULL, CFSTR("SERN:%@;"), userial);
}
serial = userial;
}
else if (userial != NULL)
CFRelease(userial);
}

if (ret != NULL)
Expand All @@ -1691,18 +1716,18 @@ static CFStringRef copy_printer_interface_deviceid(printer_interface_t printer,

if (ret != NULL)
{
/* Remove special characters from the serial number */
CFRange range = (serial != NULL ? CFStringFind(serial, CFSTR("+"), 0) : CFRangeMake(0, 0));
if (range.length == 1)
{
range = CFStringFind(ret, serial, 0);
/* Remove special characters from the serial number */
CFRange range = (serial != NULL ? CFStringFind(serial, CFSTR("+"), 0) : CFRangeMake(0, 0));
if (range.length == 1)
{
range = CFStringFind(ret, serial, 0);

CFMutableStringRef deviceIDString = CFStringCreateMutableCopy(NULL, 0, ret);
CFRelease(ret);
CFMutableStringRef deviceIDString = CFStringCreateMutableCopy(NULL, 0, ret);
CFRelease(ret);

ret = deviceIDString;
CFStringFindAndReplace(deviceIDString, CFSTR("+"), CFSTR(""), range, 0);
}
ret = deviceIDString;
CFStringFindAndReplace(deviceIDString, CFSTR("+"), CFSTR(""), range, 0);
}
}

if (manufacturer != NULL)
Expand Down Expand Up @@ -2231,7 +2256,7 @@ sigterm_handler(int sig) /* I - Signal */
_exit(0);
else
{
write(2, "DEBUG: Child crashed.\n", 22);
backendMessage("DEBUG: Child crashed.\n");
_exit(CUPS_BACKEND_STOP);
}
}
Expand Down
Loading

0 comments on commit 7521e42

Please sign in to comment.