summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2021-04-05 15:57:50 -0400
committerMichael R Sweet <michael.r.sweet@gmail.com>2021-04-05 15:57:50 -0400
commit064e50fb06e83e6c1756e2a81c2fcbd4d6fca8e6 (patch)
tree45145c8db9a634af861cb1ed87a7378837e72763 /backend
parent6918883fba4942931dc455b32545d6edf18dec5c (diff)
downloadcups-064e50fb06e83e6c1756e2a81c2fcbd4d6fca8e6.tar.gz
Import all of the bug fixes from the OpenPrinting CUPS repository.
Import the improvements to ippeveprinter from OpenPrinting/ippsample. Import the improvements to ippfind and ipptool from OpenPrinting/ippsample.
Diffstat (limited to 'backend')
-rw-r--r--backend/ipp.c64
-rw-r--r--backend/network.c2
-rw-r--r--backend/org.cups.usb-quirks69
-rw-r--r--backend/snmp.c8
-rw-r--r--backend/usb-unix.c20
5 files changed, 108 insertions, 55 deletions
diff --git a/backend/ipp.c b/backend/ipp.c
index 3f3e1867d..8b1976990 100644
--- a/backend/ipp.c
+++ b/backend/ipp.c
@@ -2240,7 +2240,8 @@ main(int argc, /* I - Number of command-line args */
else if (ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED)
fputs("JOBSTATE: account-authorization-failed\n", stderr);
- if (job_canceled)
+ // job_canceled can be -1 which should not be treated as CUPS_BACKEND_OK
+ if (job_canceled > 0)
return (CUPS_BACKEND_OK);
else if (ipp_status == IPP_STATUS_ERROR_NOT_AUTHORIZED || ipp_status == IPP_STATUS_ERROR_FORBIDDEN || ipp_status == IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED)
return (CUPS_BACKEND_AUTH_REQUIRED);
@@ -2825,7 +2826,21 @@ new_request(
*/
_httpDecodeURI(phone, keyword, sizeof(phone));
- for (ptr = phone; *ptr;)
+ ptr = phone;
+
+ /*
+ * Weed out "Custom." in the beginning, this allows to put the
+ * "phone" option as custom string option into the PPD so that
+ * print dialogs not supporting fax display the option and
+ * allow entering the phone number. Print dialogs also send "None"
+ * if no phone number got entered, filter this, too.
+ */
+ if (!_cups_strcasecmp(phone, "None"))
+ *ptr = '\0';
+ if (!_cups_strncasecmp(phone, "Custom.", 7))
+ _cups_strcpy(ptr, ptr + 7);
+
+ for (; *ptr;)
{
if (*ptr == ',')
*ptr = 'p';
@@ -2835,20 +2850,36 @@ new_request(
ptr ++;
}
- httpAssembleURI(HTTP_URI_CODING_ALL, tel_uri, sizeof(tel_uri), "tel", NULL, NULL, 0, phone);
- ippAddString(destination, IPP_TAG_JOB, IPP_TAG_URI, "destination-uri", NULL, tel_uri);
-
- if ((keyword = cupsGetOption("faxPrefix", num_options,
- options)) != NULL && *keyword)
+ if (strlen(phone) > 0)
{
- char predial[1024]; /* Pre-dial string */
+ httpAssembleURI(HTTP_URI_CODING_ALL, tel_uri, sizeof(tel_uri), "tel", NULL, NULL, 0, phone);
+ ippAddString(destination, IPP_TAG_JOB, IPP_TAG_URI, "destination-uri", NULL, tel_uri);
+ fprintf(stderr, "DEBUG: Faxing to phone %s; destination-uri: %s\n", phone, tel_uri);
- _httpDecodeURI(predial, keyword, sizeof(predial));
- ippAddString(destination, IPP_TAG_JOB, IPP_TAG_TEXT, "pre-dial-string", NULL, predial);
- }
+ if ((keyword = cupsGetOption("faxPrefix", num_options, options)) != NULL && *keyword)
+ {
+ char predial[1024]; /* Pre-dial string */
+
+ _httpDecodeURI(predial, keyword, sizeof(predial));
+ ptr = predial;
+ if (!_cups_strcasecmp(ptr, "None"))
+ *ptr = '\0';
+ if (!_cups_strncasecmp(ptr, "Custom.", 7))
+ ptr += 7;
+ if (strlen(ptr) > 0)
+ {
+ ippAddString(destination, IPP_TAG_JOB, IPP_TAG_TEXT, "pre-dial-string", NULL, ptr);
+ fprintf(stderr, "DEBUG: Pre-dialing %s; pre-dial-string: %s\n", ptr, ptr);
+ }
+ else
+ fprintf(stderr, "WARNING: Pre-dial number for fax not valid! Sending fax without pre-dial number.\n");
+ }
- ippAddCollection(request, IPP_TAG_JOB, "destination-uris", destination);
- ippDelete(destination);
+ ippAddCollection(request, IPP_TAG_JOB, "destination-uris", destination);
+ ippDelete(destination);
+ }
+ else
+ fprintf(stderr, "ERROR: Phone number for fax not valid! Fax cannot be sent.\n");
}
}
else
@@ -3075,7 +3106,7 @@ report_printer_state(ipp_t *ipp) /* I - IPP response */
* Report alerts and messages...
*/
- if ((pa = ippFindAttribute(ipp, "printer-alert", IPP_TAG_TEXT)) != NULL)
+ if ((pa = ippFindAttribute(ipp, "printer-alert", IPP_TAG_STRING)) != NULL)
report_attr(pa);
if ((pam = ippFindAttribute(ipp, "printer-alert-message",
@@ -3116,11 +3147,10 @@ report_printer_state(ipp_t *ipp) /* I - IPP response */
if (*ptr < ' ' && *ptr > 0 && *ptr != '\t')
{
/*
- * Substitute "<XX>" for the control character; sprintf is safe because
- * we always leave 6 chars free at the end...
+ * Substitute "<XX>" for the control character...
*/
- sprintf(valptr, "<%02X>", *ptr);
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value), "<%02X>", *ptr);
valptr += 4;
}
else
diff --git a/backend/network.c b/backend/network.c
index 5af0a8eea..f7ee2fbbe 100644
--- a/backend/network.c
+++ b/backend/network.c
@@ -258,7 +258,7 @@ backendNetworkSideCB(
i < packet.object_value.string.num_bytes &&
dataptr < (data + sizeof(data) - 3);
i ++, dataptr += 2)
- sprintf(dataptr, "%02X", packet.object_value.string.bytes[i]);
+ snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%02X", packet.object_value.string.bytes[i]);
datalen += (int)strlen(dataptr);
break;
diff --git a/backend/org.cups.usb-quirks b/backend/org.cups.usb-quirks
index cd684d33f..83f62c165 100644
--- a/backend/org.cups.usb-quirks
+++ b/backend/org.cups.usb-quirks
@@ -68,7 +68,7 @@
# Canon, Inc. PIXMA iP6000D Printer (https://bugs.launchpad.net/bugs/1160638)
0x04a9 0x1095 unidir
-# Canon, Inc. PIXMA iP4200 Printer (Issue #4155)
+# Canon, Inc. PIXMA iP4200 Printer (Apple #4155)
0x04a9 0x10a2 unidir
# Canon, Inc. PIXMA iP4300 Printer (https://bugs.launchpad.net/bugs/1032385)
@@ -86,12 +86,15 @@
# Canon, Inc. MP540 Printer, https://bugzilla.redhat.com/967873
0x04a9 0x1730 unidir
-# Canon, Inc. MP550 Printer (Issue #4155)
+# Canon, Inc. MP550 Printer (Apple #4155)
0x04a9 0x173d unidir
-# Canon, Inc. MP560 Printer (Issue #4155)
+# Canon, Inc. MP560 Printer (Apple #4155)
0x04a9 0x173e unidir
+# Canon, Inc. PIXMA G1501 Printer (Apple #5831)
+0x04a9 0x1796 unidir
+
# Canon, Inc. MF4150 Printer (https://bugs.launchpad.net/bugs/1160638)
0x04a9 0x26a3 no-reattach
@@ -140,7 +143,7 @@
# Samsung ML-2160 Series (https://bugzilla.redhat.com/show_bug.cgi?id=873123)
0x04e8 0x330f unidir
-# All Zebra devices (https://bugs.launchpad.net/bugs/1001028) (Issue #5395)
+# All Zebra devices (https://bugs.launchpad.net/bugs/1001028) (Apple #5395)
0x0a5f unidir no-reattach
# Canon CP-10
@@ -230,75 +233,87 @@
# Lexmark E238 (<rdar://problem/14493054>)
0x043d 0x00d7 no-reattach
-# Lexmark E238 (Issue #4448)
+# Lexmark E238 (Apple #4448)
0x043d 0x009a no-reattach
-# Canon MX310 (Issue #4482)
+# Canon MX310 (Apple #4482)
0x04a9 0x1728 unidir
-# Canon MX320 (Issue #4482)
+# Canon MX320 (Apple #4482)
0x04A9 0x1736 unidir
-# All Intermec devices (Issue #4553)
+# All Intermec devices (Apple #4553)
0x067e no-reattach
-# HP LaserJet 1015 (Issue #5617)
+# HP LaserJet 1010 (Apple #5789)
+0x03f0 0x0c17 delay-close
+
+# HP LaserJet 1015 (Apple #5617)
0x03f0 0x0e17 delay-close
-# HP LaserJet 1150 (Issue #4549)
+# HP LaserJet 1150 (Apple #4549)
0x03f0 0x0f17 delay-close
-# HP LaserJet 1300 (Issue #4549)
+# HP LaserJet 1300 (Apple #4549)
0x03f0 0x1017 delay-close
0x03f0 0x1117 delay-close
-# HP LaserJet 1320 (Issue #4549)
+# HP LaserJet 1320 (Apple #4549)
0x03f0 0x1d17 delay-close
# Canon, Inc. MP530 Printer
0x04a9 0x1712 unidir
-# Xerox WorkCentre 3220 (https://bugs.launchpad.net/bugs/1406203, Issue #4789)
+# Xerox WorkCentre 3220 (https://bugs.launchpad.net/bugs/1406203, Apple #4789)
0x0924 0x4294 no-reattach
-# Lexmark C540n (Issue #4778)
+# Lexmark C540n (Apple #4778)
0x043d 0x0139 no-reattach
-# Kyocera Ecosys P6026cdn (Issue #4900)
+# Kyocera Ecosys P6026cdn (Apple #4900)
0x0482 0x063f no-reattach
-# Kyocera Ecosys P6130cdn (Issue #5102)
+# Kyocera Ecosys P6130cdn (Apple #5102)
0x0482 0x0677 no-reattach
-# Lexmark E260dn (Issue #4994)
+# Lexmark E260dn (Apple #4994)
0x043d 0x0123 no-reattach
-# HP LaserJet 1160 (Issue #5121)
+# HP LaserJet 1160 (Apple #5121)
0x03f0 0x1e17 delay-close
-# Canon, Inc. MP280 series (Issue #5221)
+# Canon, Inc. MP280 series (Apple #5221)
0x04a9 0x1746 unidir
-# Star Micronics printers (Issue #5251)
+# Star Micronics printers (Apple #5251)
0x0519 unidir
-# Lexmark Optra E310 (Issue #5259)
+# Lexmark Optra E310 (Apple #5259)
0x043d 0x000c no-reattach
-# HP LaserJet P1102 (Issue #5310)
+# HP LaserJet P1102 (Apple #5310)
0x03F0 0x002A no-reattach
# Lexmark MS317dn
0x043d 0x0226 no-reattach
-# Star TSP743 (Issue #5443)
+# Star TSP743 (Apple #5443)
0x0519 0x0001 delay-close
-# Lexmark E120n (Issue #5478)
+# Lexmark E120n (Apple #5478)
0x043d 0x00cc no-reattach
-# All Xerox printers (Issue #5523)
+# Lexmark E120n MT4506-100 (Apple #5766)
+0x043d 0x00cd no-reattach
+
+# All Xerox printers (Apple #5523)
0x0924 no-reattach
-# Dymo 450 Turbo (Issue #5521)
-0x0922 0x0021 unidir
+# Citizen CT-S4000 (Apple #5823)
+0x2730 0x2008 unidir delay-close
+
+# All Arkscan label printers (Apple #5867)
+0x2d84 unidir no-reattach
+
+# HP DesignJet 130 (Apple #5838)
+0x03f0 0x0314 no-reattach
diff --git a/backend/snmp.c b/backend/snmp.c
index 66ac884c6..9572822a8 100644
--- a/backend/snmp.c
+++ b/backend/snmp.c
@@ -154,6 +154,8 @@ static const int UriOID[] = { CUPS_OID_ppmPortServiceNameOrURI, 1, 1, -1 };
static const int LexmarkProductOID[] = { 1,3,6,1,4,1,641,2,1,2,1,2,1,-1 };
static const int LexmarkProductOID2[] = { 1,3,6,1,4,1,674,10898,100,2,1,2,1,2,1,-1 };
static const int LexmarkDeviceIdOID[] = { 1,3,6,1,4,1,641,2,1,2,1,3,1,-1 };
+static const int HPDeviceIdOID[] = { 1,3,6,1,4,1,11,2,3,9,1,1,7,0,-1 };
+static const int RicohDeviceIdOID[] = { 1,3,6,1,4,1,367,3,2,1,1,1,11,0,-1 };
static const int XeroxProductOID[] = { 1,3,6,1,4,1,128,2,1,3,1,2,0,-1 };
static cups_array_t *DeviceURIs = NULL;
static int HostNameLookups = 0;
@@ -970,8 +972,14 @@ read_snmp_response(int fd) /* I - SNMP socket file descriptor */
packet.community, CUPS_ASN1_GET_REQUEST,
DEVICE_ID, LexmarkDeviceIdOID);
_cupsSNMPWrite(fd, &(packet.address), CUPS_SNMP_VERSION_1,
+ packet.community, CUPS_ASN1_GET_REQUEST,
+ DEVICE_ID, RicohDeviceIdOID);
+ _cupsSNMPWrite(fd, &(packet.address), CUPS_SNMP_VERSION_1,
packet.community, CUPS_ASN1_GET_REQUEST,
DEVICE_PRODUCT, XeroxProductOID);
+ _cupsSNMPWrite(fd, &(packet.address), CUPS_SNMP_VERSION_1,
+ packet.community, CUPS_ASN1_GET_REQUEST,
+ DEVICE_ID, HPDeviceIdOID);
break;
case DEVICE_DESCRIPTION :
diff --git a/backend/usb-unix.c b/backend/usb-unix.c
index 81e20c524..d256a813b 100644
--- a/backend/usb-unix.c
+++ b/backend/usb-unix.c
@@ -214,21 +214,21 @@ list_devices(void)
* for USB printer devices. We get the honor of trying them all...
*/
- sprintf(device, "/dev/usblp%d", i);
+ snprintf(device, sizeof(device), "/dev/usblp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0)
{
if (errno != ENOENT)
continue;
- sprintf(device, "/dev/usb/lp%d", i);
+ snprintf(device, sizeof(device), "/dev/usb/lp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0)
{
if (errno != ENOENT)
continue;
- sprintf(device, "/dev/usb/usblp%d", i);
+ snprintf(device, sizeof(device), "/dev/usb/usblp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0)
continue;
@@ -258,7 +258,7 @@ list_devices(void)
for (i = 0; i < 8; i ++)
{
- sprintf(device, "/dev/usb/printer%d", i);
+ snprintf(device, sizeof(device), "/dev/usb/printer%d", i);
if ((fd = open(device, O_WRONLY | O_EXCL)) >= 0)
{
@@ -278,11 +278,11 @@ list_devices(void)
for (i = 0; i < 8; i ++)
{
- sprintf(device, "/dev/ulpt%d", i);
+ snprintf(device, sizeof(device), "/dev/ulpt%d", i);
if (!access(device, 0))
printf("direct usb:%s \"Unknown\" \"USB Printer #%d\"\n", device, i + 1);
- sprintf(device, "/dev/unlpt%d", i);
+ snprintf(device, sizeof(device), "/dev/unlpt%d", i);
if (!access(device, 0))
printf("direct usb:%s \"Unknown\" \"USB Printer #%d (no reset)\"\n", device, i + 1);
}
@@ -344,15 +344,15 @@ open_device(const char *uri, /* I - Device URI */
* for USB printer devices. We get the honor of trying them all...
*/
- sprintf(device, "/dev/usblp%d", i);
+ snprintf(device, sizeof(device), "/dev/usblp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT)
{
- sprintf(device, "/dev/usb/lp%d", i);
+ snprintf(device, sizeof(device), "/dev/usb/lp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT)
{
- sprintf(device, "/dev/usb/usblp%d", i);
+ snprintf(device, sizeof(device), "/dev/usb/usblp%d", i);
if ((fd = open(device, O_RDWR | O_EXCL)) < 0 && errno == ENOENT)
continue;
@@ -440,7 +440,7 @@ open_device(const char *uri, /* I - Device URI */
{
for (i = 0, busy = 0; i < 8; i ++)
{
- sprintf(device, "/dev/usb/printer%d", i);
+ snprintf(device, sizeof(device), "/dev/usb/printer%d", i);
if ((fd = open(device, O_WRONLY | O_EXCL)) >= 0)
backendGetDeviceID(fd, device_id, sizeof(device_id),