upgrade to cups-2.4.0

This commit is contained in:
shirely16 2021-12-09 20:13:48 +08:00
parent e42a3797c6
commit db0336e30b
25 changed files with 266 additions and 3703 deletions

View File

@ -1,52 +0,0 @@
From efbea1742bd30f842fbbfb87a473e5c84f4162f9 Mon Sep 17 00:00:00 2001
From: Michael R Sweet <msweet@msweet.org>
Date: Mon, 1 Feb 2021 15:02:32 -0500
Subject: [PATCH] Fix a buffer (read) overflow in ippReadIO (CVE-2020-10001)
---
cups/ipp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/cups/ipp.c b/cups/ipp.c
index 3d52934..84b8da6 100644
--- a/cups/ipp.c
+++ b/cups/ipp.c
@@ -2866,7 +2866,8 @@ ippReadIO(void *src, /* I - Data source */
unsigned char *buffer, /* Data buffer */
string[IPP_MAX_TEXT],
/* Small string buffer */
- *bufptr; /* Pointer into buffer */
+ *bufptr, /* Pointer into buffer */
+ *bufend; /* End of buffer */
ipp_attribute_t *attr; /* Current attribute */
ipp_tag_t tag; /* Current tag */
ipp_tag_t value_tag; /* Current value tag */
@@ -3441,6 +3442,7 @@ ippReadIO(void *src, /* I - Data source */
}
bufptr = buffer;
+ bufend = buffer + n;
/*
* text-with-language and name-with-language are composite
@@ -3454,7 +3456,7 @@ ippReadIO(void *src, /* I - Data source */
n = (bufptr[0] << 8) | bufptr[1];
- if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) || n >= (int)sizeof(string))
+ if ((bufptr + 2 + n + 2) > bufend || n >= (int)sizeof(string))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL,
_("IPP language length overflows value."), 1);
@@ -3481,7 +3483,7 @@ ippReadIO(void *src, /* I - Data source */
bufptr += 2 + n;
n = (bufptr[0] << 8) | bufptr[1];
- if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE))
+ if ((bufptr + 2 + n) > bufend)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL,
_("IPP string length overflows value."), 1);
--
2.27.0

View File

@ -1,10 +0,0 @@
diff --git a/scheduler/org.cups.cupsd.service.in b/scheduler/org.cups.cupsd.service.in
index bf308a5..add238b 100644
--- a/scheduler/org.cups.cupsd.service.in
+++ b/scheduler/org.cups.cupsd.service.in
@@ -10,4 +10,4 @@ Restart=on-failure
[Install]
Also=cups.socket cups.path
-WantedBy=printer.target
+WantedBy=printer.target multi-user.target

View File

@ -1,11 +0,0 @@
diff -up cups-2.3.1/ppdc/sample.drv.dymo-deviceid cups-2.3.1/ppdc/sample.drv
--- cups-2.3.1/ppdc/sample.drv.dymo-deviceid 2019-12-16 09:22:34.476492212 +0100
+++ cups-2.3.1/ppdc/sample.drv 2019-12-16 09:23:44.665003895 +0100
@@ -129,6 +129,7 @@ Version "2.3"
{
Manufacturer "DYMO"
ModelName "Label Printer"
+ Attribute "1284DeviceID" "" "MFG:DYMO;MDL:LabelWriter 400;"
Attribute NickName "" "DYMO Label Printer"
PCFileName "dymo.ppd"
DriverType label

View File

@ -1,130 +0,0 @@
diff -up cups-2.3.0/backend/ipp.c.eggcups cups-2.3.0/backend/ipp.c
--- cups-2.3.0/backend/ipp.c.eggcups 2019-08-23 17:19:38.000000000 +0200
+++ cups-2.3.0/backend/ipp.c 2019-10-07 12:14:25.385111933 +0200
@@ -143,6 +143,70 @@ static char tmpfilename[1024] = "";
static char mandatory_attrs[1024] = "";
/* cupsMandatory value */
+#if HAVE_DBUS
+#include <dbus/dbus.h>
+
+static DBusConnection *dbus_connection = NULL;
+
+static int
+init_dbus (void)
+{
+ DBusConnection *connection;
+ DBusError error;
+
+ if (dbus_connection &&
+ !dbus_connection_get_is_connected (dbus_connection)) {
+ dbus_connection_unref (dbus_connection);
+ dbus_connection = NULL;
+ }
+
+ dbus_error_init (&error);
+ connection = dbus_bus_get (getuid () ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ dbus_error_free (&error);
+ return -1;
+ }
+
+ dbus_connection = connection;
+ return 0;
+}
+
+int
+dbus_broadcast_queued_remote (const char *printer_uri,
+ ipp_status_t status,
+ unsigned int local_job_id,
+ unsigned int remote_job_id,
+ const char *username,
+ const char *printer_name)
+{
+ DBusMessage *message;
+ DBusMessageIter iter;
+ const char *errstr;
+
+ if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
+ if (init_dbus () || !dbus_connection)
+ return -1;
+ }
+
+ errstr = ippErrorString (status);
+ message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
+ "com.redhat.PrinterSpooler",
+ "JobQueuedRemote");
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_uri);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errstr);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &local_job_id);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &remote_job_id);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &username);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_name);
+
+ dbus_connection_send (dbus_connection, message, NULL);
+ dbus_connection_flush (dbus_connection);
+ dbus_message_unref (message);
+
+ return 0;
+}
+#endif /* HAVE_DBUS */
/*
* Local functions...
@@ -1768,6 +1832,15 @@ main(int argc, /* I - Number of comm
fprintf(stderr, "DEBUG: Print job accepted - job ID %d.\n", job_id);
}
+#if HAVE_DBUS
+ dbus_broadcast_queued_remote (argv[0],
+ ipp_status,
+ atoi (argv[1]),
+ job_id,
+ argv[2],
+ getenv ("PRINTER"));
+#endif /* HAVE_DBUS */
+
ippDelete(response);
if (job_canceled)
diff -up cups-2.3.0/backend/Makefile.eggcups cups-2.3.0/backend/Makefile
--- cups-2.3.0/backend/Makefile.eggcups 2019-10-07 12:14:25.385111933 +0200
+++ cups-2.3.0/backend/Makefile 2019-10-07 12:16:00.457569406 +0200
@@ -257,7 +257,7 @@ dnssd: dnssd.o ../cups/$(LIBCUPS) libbac
ipp: ipp.o ../cups/$(LIBCUPS) libbackend.a
echo Linking $@...
- $(LD_CC) $(ALL_LDFLAGS) -o ipp ipp.o libbackend.a $(LINKCUPS)
+ $(LD_CC) $(LDFLAGS) -o ipp ipp.o libbackend.a $(LINKCUPS) $(SERVERLIBS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
$(RM) http https ipps
for file in $(IPPALIASES); do \
diff -up cups-2.3.0/scheduler/subscriptions.c.eggcups cups-2.3.0/scheduler/subscriptions.c
--- cups-2.3.0/scheduler/subscriptions.c.eggcups 2019-08-23 17:19:38.000000000 +0200
+++ cups-2.3.0/scheduler/subscriptions.c 2019-10-07 12:18:21.736478684 +0200
@@ -1257,13 +1257,13 @@ cupsd_send_dbus(cupsd_eventmask_t event,
what = "PrinterAdded";
else if (event & CUPSD_EVENT_PRINTER_DELETED)
what = "PrinterRemoved";
- else if (event & CUPSD_EVENT_PRINTER_CHANGED)
- what = "QueueChanged";
else if (event & CUPSD_EVENT_JOB_CREATED)
what = "JobQueuedLocal";
else if ((event & CUPSD_EVENT_JOB_STATE) && job &&
job->state_value == IPP_JOB_PROCESSING)
what = "JobStartedLocal";
+ else if (event & (CUPSD_EVENT_PRINTER_CHANGED|CUPSD_EVENT_JOB_STATE_CHANGED|CUPSD_EVENT_PRINTER_STATE_CHANGED))
+ what = "QueueChanged";
else
return;
@@ -1299,7 +1299,7 @@ cupsd_send_dbus(cupsd_eventmask_t event,
dbus_message_append_iter_init(message, &iter);
if (dest)
dbus_message_iter_append_string(&iter, dest->name);
- if (job)
+ if (job && strcmp (what, "QueueChanged") != 0)
{
dbus_message_iter_append_uint32(&iter, job->id);
dbus_message_iter_append_string(&iter, job->username);

View File

@ -1,25 +0,0 @@
diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c
index e4ffc3d..a989055 100644
--- a/cups/http-addrlist.c
+++ b/cups/http-addrlist.c
@@ -240,7 +240,10 @@ httpAddrConnect2(
}
if (!addrlist && nfds == 0)
+ {
+ errno = EHOSTDOWN;
break;
+ }
/*
* See if we can connect to any of the addresses so far...
@@ -371,6 +374,9 @@ httpAddrConnect2(
remaining -= 250;
}
+ if (remaining <= 0)
+ errno = ETIMEDOUT;
+
while (nfds > 0)
{
nfds --;

View File

@ -1,876 +0,0 @@
diff -up cups-2.3.3/backend/failover.c.failover cups-2.3.3/backend/failover.c
--- cups-2.3.3/backend/failover.c.failover 2020-06-11 08:49:20.515264358 +0200
+++ cups-2.3.3/backend/failover.c 2020-06-11 08:49:20.515264358 +0200
@@ -0,0 +1,837 @@
+/*
+ * Failover Backend for the Common UNIX Printing System (CUPS).
+ *
+ * Copyright (c) 2014, Red Hat, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Red Hat, Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT,
+ * INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Original version by Clark Hale, Red Hat, Inc.
+ *
+ * This backend presents a fake printer that will choose the first
+ * available printer from a list of IPP URIs.
+ *
+ * Option failover contains a comma separated list of IPP URIs. The
+ * URIs are attempted in-order.
+ *
+ * Option failover-retries contains an integer that indicates how many
+ * times to iterate through the failover list before completely
+ * failing.
+ *
+ * Contents:
+ * main() - Checks each printer in a failover list, and
+ * sends job data to the first available printer
+ * move_job() - Sends and IPP Move-Job request
+ * check_printer() - Checks a printer's attributes to see
+ * if it's enabled and accepting jobs
+ * read_config() - Read the backends configuration from
+ * options
+ * get_printer_attributes() - Sends an IPP Get-Attributes request to
+ * a URI
+ * sigterm_handler() - Handle SIGTERM that cancels the job
+ * password_cb() - Password call back used to disable password
+ * prompt
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <cups/http-private.h>
+#include <cups/http.h>
+#include "backend-private.h"
+
+/*
+ * Return Values
+ */
+typedef enum fo_state_e
+{
+ FO_PRINTER_GOOD = 0,
+ FO_PRINTER_BAD,
+ FO_PRINTER_BUSY,
+ FO_AUTH_REQUIRED
+} fo_state_t;
+
+/*
+ * Constants
+ */
+#define FAILOVER_DEFAULT_RETRIES (3)
+#define FAILOVER_PASSWORD_RETRIES_MAX (3)
+
+/*
+ * Local Functions
+ */
+static int check_printer(const char *device_uri);
+static int read_config(cups_array_t *printer_array, int *retries,
+ const char *options);
+static int get_printer_attributes(const char *device_uri,
+ ipp_t **attributes);
+static int move_job(int jobid, const char *dest);
+static void sigterm_handler(int sig);
+static const char *password_cb(const char *);
+
+/*
+ * Global Variables
+ */
+static int job_canceled = 0; /* Job canceled */
+static char *password = NULL; /* password for device */
+static int password_retries = 0;
+static const char *auth_info_required = "none";
+
+/*
+ * 'main()' - Checks each printer in a failover list, and
+ * sends job data to the first available printer
+ * Usage:
+ * printer-uri job-id user title copies options [file]
+ *
+ * The printer-uri option is not used, but it still required to fit
+ * to the backend(7) standards.
+ */
+int
+main(int argc, char *argv[])
+{
+ const char *selected_uri = NULL; /* URI of selected printer */
+ const char *tmp_device_uri; /* Device URI to check */
+ cups_array_t *printer_array; /* Array of available printers */
+ int printer_count = 0; /* current printer array index */
+ int retry_max = 1; /* maximum retries before exit */
+ int retry_count = 0; /* current retry number */
+ int auth_failed_count = 0; /* auth failures per loop */
+ int rc = CUPS_BACKEND_OK;
+#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
+ struct sigaction action; /* Actions for POSIX signals */
+#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+
+ /*
+ * Check args
+ */
+ if (argc == 1)
+ {
+ /*
+ * print out discovery data
+ */
+ char *backendName;
+
+ if ((backendName = strrchr(argv[0], '/')) != NULL)
+ backendName++;
+ else
+ backendName = argv[0];
+
+ _cupsLangPrintf(stderr,"network %s \"Unknown\" \"%s (%s)\"\n",
+ backendName,
+ _cupsLangString(cupsLangDefault(), _("Failover Printer")),
+ backendName);
+
+ return (CUPS_BACKEND_OK);
+ }
+ else if (argc < 6)
+ {
+ _cupsLangPrintf(stderr,
+ _("Usage: %s job-id user title copies options [file]"),
+ argv[0]);
+ return (CUPS_BACKEND_STOP);
+ }
+
+ fprintf(stderr, "DEBUG: Failover backend starting up.\n");
+
+ /*
+ * Don't buffer status messages
+ */
+ setbuf(stderr, NULL);
+
+ /*
+ * Ignore SIGPIPE and catch SIGTERM signals...
+ */
+#ifdef HAVE_SIGSET
+ sigset(SIGPIPE, SIG_IGN);
+ sigset(SIGTERM, sigterm_handler);
+#elif defined(HAVE_SIGACTION)
+ memset(&action, 0, sizeof(action));
+ action.sa_handler = SIG_IGN;
+ sigaction(SIGPIPE, &action, NULL);
+
+ sigemptyset(&action.sa_mask);
+ sigaddset(&action.sa_mask, SIGTERM);
+ action.sa_handler = sigterm_handler;
+ sigaction(SIGTERM, &action, NULL);
+#else
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGTERM, sigterm_handler);
+#endif /* HAVE_SIGSET */
+
+ printer_array = cupsArrayNew(NULL, NULL);
+
+ /*
+ * Read Configuration
+ */
+ if ((rc = read_config(printer_array, &retry_max,
+ argv[5])) != CUPS_BACKEND_OK)
+ {
+ fprintf(stderr, "ERROR: Failed to read configuration options!\n");
+ goto cleanup;
+ }
+
+ /*
+ * Main Retry Loop
+ */
+ for (retry_count = 0; retry_count < retry_max; retry_count++)
+ {
+ fprintf(stderr, "DEBUG: Retry loop #%d\n", retry_count + 1);
+
+ /*
+ * Reset Counters
+ */
+ printer_count = 0;
+ auth_failed_count = 0;
+
+ tmp_device_uri = (char *)cupsArrayFirst(printer_array);
+
+ do
+ {
+ if (job_canceled)
+ {
+ fprintf(stderr, "DEBUG: Job Canceled\n");
+ goto cleanup;
+ }
+
+ fprintf(stderr,"DEBUG: Checking printer #%d: %s\n",
+ printer_count+1, tmp_device_uri);
+
+ rc = check_printer(tmp_device_uri);
+
+ // Printer is available and not busy.
+ if ( rc == FO_PRINTER_GOOD )
+ {
+ selected_uri = tmp_device_uri;
+ break;
+ }
+ // Printer is busy
+ else if (rc == FO_PRINTER_BUSY)
+ {
+ fprintf(stderr, "DEBUG: Waiting for job to complete.\n");
+ sleep(2);
+ continue;
+ }
+ // Authorization is required to access the printer.
+ else if (rc == FO_AUTH_REQUIRED)
+ {
+ auth_failed_count++;
+ fprintf(stderr, "DEBUG: auth_failed_count = %d\n", auth_failed_count);
+ }
+ // Printer is stopped or not accepting jobs
+ else
+ {
+ if (!printer_count)
+ fprintf(stderr, "INFO: Primary Printer, %s, not available. "
+ "Attempting Failovers...\n",
+ tmp_device_uri);
+ else
+ fprintf(stderr, "INFO: Failover Printer, %s, not available. "
+ "Attempting Failovers..\n",
+ tmp_device_uri);
+ printer_count++;
+ tmp_device_uri = (char *)cupsArrayNext(printer_array);
+ }
+ } while (tmp_device_uri != NULL);
+
+ if (selected_uri && !printer_count)
+ fprintf(stderr, "STATE: -primary-printer-failed\n");
+ else
+ fprintf(stderr, "STATE: +primary-printer-failed\n");
+
+ if (job_canceled)
+ {
+ fprintf(stderr, "DEBUG: Job Canceled\n");
+ goto cleanup;
+ }
+
+ if (!selected_uri && auth_failed_count == printer_count)
+ {
+ fprintf(stderr, "ERROR: All failover printers failed with "
+ "authorization issues.\n");
+ rc = CUPS_BACKEND_AUTH_REQUIRED;
+ fprintf(stderr, "ATTR: auth-info-required=%s\n", auth_info_required);
+ goto cleanup;
+ }
+ else if (!selected_uri && retry_count + 1 < retry_max)
+ {
+ fprintf(stderr, "INFO: No suitable printer found...retrying...\n");
+ sleep(2);
+ continue;
+ }
+ else if (selected_uri)
+ {
+ fprintf(stderr, "DEBUG: Using printer, %s.\n", selected_uri);
+ break;
+ }
+ }
+
+ if (!selected_uri)
+ {
+ fprintf(stderr, "ERROR: No suitable printer found. Aborting print\n");
+ rc = CUPS_BACKEND_FAILED;
+ goto cleanup;
+ }
+
+ rc = move_job(atoi(argv[1]), selected_uri);
+
+ if (job_canceled)
+ rc = CUPS_BACKEND_OK;
+
+cleanup :
+ if (job_canceled)
+ rc = CUPS_BACKEND_OK;
+
+ tmp_device_uri = (char *)cupsArrayFirst(printer_array);
+ do
+ {
+ free((void *)tmp_device_uri);
+ } while ((tmp_device_uri = (char *)cupsArrayNext(printer_array)) != NULL);
+
+ cupsArrayDelete(printer_array);
+ sleep(2);
+ return (rc);
+}
+
+/*
+ * 'check_printer()' - Checks the status of a remote printer and returns
+ * back a good/bad/busy status.
+ */
+int
+check_printer(const char *device_uri)
+{
+ ipp_t *attributes = NULL; /* attributes for device_uri */
+ ipp_attribute_t *tmp_attribute; /* for examining attribs */
+ int rc = FO_PRINTER_GOOD; /* return code */
+ char *reason; /* printer state reason */
+ int i;
+
+ fprintf(stderr, "DEBUG: Checking printer %s\n",device_uri);
+
+ rc = get_printer_attributes(device_uri, &attributes);
+ if ( rc != CUPS_BACKEND_OK )
+ {
+ fprintf(stderr, "DEBUG: Failed to get attributes from printer: %s\n",
+ device_uri);
+ if ( rc == CUPS_BACKEND_AUTH_REQUIRED )
+ return (FO_AUTH_REQUIRED);
+ else
+ return (FO_PRINTER_BAD);
+ }
+
+ /*
+ * Check if printer is accepting jobs
+ */
+ if ((tmp_attribute = ippFindAttribute(attributes,
+ "printer-is-accepting-jobs",
+ IPP_TAG_BOOLEAN)) != NULL &&
+ !tmp_attribute->values[0].boolean)
+ {
+ fprintf(stderr,
+ "DEBUG: Printer, %s, is not accepting jobs.\n",
+ device_uri);
+
+ rc = FO_PRINTER_BAD;
+ }
+
+ /*
+ * Check if printer is stopped or busy processing
+ */
+ if ((tmp_attribute = ippFindAttribute(attributes,
+ "printer-state",
+ IPP_TAG_ENUM)) != NULL)
+ {
+ // Printer Stopped
+ if ( tmp_attribute->values[0].integer == IPP_PRINTER_STOPPED )
+ {
+ fprintf(stderr, "DEBUG: Printer, %s, stopped.\n", device_uri);
+ rc = FO_PRINTER_BAD;
+ }
+ // Printer Busy
+ else if ( tmp_attribute->values[0].integer == IPP_PRINTER_PROCESSING )
+ {
+ fprintf(stderr, "DEBUG: Printer %s is busy.\n", device_uri);
+ rc = FO_PRINTER_BUSY;
+ }
+ }
+
+ /*
+ * Parse through the printer-state-reasons
+ */
+ if ((tmp_attribute = ippFindAttribute(attributes, "printer-state-reasons",
+ IPP_TAG_KEYWORD)) != NULL)
+ {
+ for (i = 0; i < tmp_attribute->num_values; i++)
+ {
+ reason = tmp_attribute->values[i].string.text;
+ int len = strlen(reason);
+
+ if (len > 8 && !strcmp(reason + len - 8, "-warning"))
+ {
+ fprintf(stderr, "DEBUG: Printer Supply Warning, %s\n", reason);
+ rc = FO_PRINTER_BAD;
+ }
+ else if (len > 6 && !strcmp(reason + len - 6, "-error"))
+ {
+ fprintf(stderr, "DEBUG: Printer Supply Error, %s\n", reason);
+ rc = FO_PRINTER_BAD;
+ }
+ }
+ }
+
+ return (rc);
+}
+
+/*
+ * 'read_config()' - Parses the failover and failover-retries options
+ *
+ */
+static int
+read_config(cups_array_t *printer_array, int *retries, const char *options)
+{
+
+ const char *tmp; /* temporary ptr */
+ char *tok_tmp; /* temporary ptr for option parsing */
+ int jobopts_count = 0; /* number of options */
+ cups_option_t *jobopts = NULL; /* job options */
+
+
+ fprintf(stderr, "DEBUG: Reading Configuration.\n");
+ jobopts_count = cupsParseOptions(options, 0, &jobopts);
+
+ if (!jobopts_count)
+ {
+ fprintf(stderr,
+ "ERROR: No job options! Cannot find failover options!\n");
+ return (CUPS_BACKEND_STOP);
+ }
+
+ /*
+ * Get attributes from the primary printer
+ */
+ fprintf(stderr, "DEBUG: Searching for failover option.\n");
+
+ if ((tmp = cupsGetOption("failover", jobopts_count, jobopts)) != NULL)
+ {
+ fprintf(stderr, "DEBUG: Failover option contents: %s.\n", tmp);
+
+ tok_tmp = strdup(tmp);
+
+ tmp = strtok(tok_tmp, ",");
+ do
+ {
+ cupsArrayAdd(printer_array, strdup(tmp));
+ } while ((tmp = strtok(NULL,",")) != NULL);
+
+ free(tok_tmp);
+ }
+ else
+ {
+ /*
+ * The queue is misconfigured, so return back CUPS_BACKEND_STOP
+ */
+ fprintf(stderr, "ERROR: failover option not specified!\n");
+ return (CUPS_BACKEND_STOP);
+ }
+
+ /*
+ * Get the failover-retries value, if it exists.
+ */
+ fprintf(stderr, "DEBUG: Searching for failover-retries option.\n");
+
+ if ((tmp = cupsGetOption("failover-retries",
+ jobopts_count, jobopts)) != NULL)
+ {
+ fprintf(stderr, "DEBUG: failover-retries option contents: %s.\n", tmp);
+ *retries = atoi(tmp);
+ }
+ else
+ {
+ *retries = FAILOVER_DEFAULT_RETRIES;
+ fprintf(stderr, "DEBUG: Failed to get failover-retries option\n");
+ fprintf(stderr, "DEBUG: Defaulted to %d retries\n", *retries);
+ }
+
+ return (CUPS_BACKEND_OK);
+}
+
+/*
+ * 'get_printer_attributes()' - Sends an IPP Get-Attributes request to
+ * a URI
+ */
+int
+get_printer_attributes(const char *device_uri, ipp_t **attributes)
+{
+ char uri[HTTP_MAX_URI]; /* Updated URI without login */
+ int version; /* IPP version */
+ char scheme[256]; /* Scheme in URI */
+ ipp_status_t ipp_status; /* Status of IPP request */
+ char hostname[1024]; /* Hostname */
+ char resource[1024]; /* Resource infoo */
+ char addrname[256]; /* Address name */
+ int port; /* IPP Port number */
+ char portname[255]; /* Port as string */
+ http_t *http; /* HTTP connection */
+ ipp_t *request; /* IPP request */
+ int rc = CUPS_BACKEND_OK; /* Return Code */
+ char username[256]; /* Username for device URI */
+ char *option_ptr; /* for parsing resource opts */
+ const char * const pattrs[] = /* Printer attributes wanted */
+ {
+ "printer-is-accepting-jobs",
+ "printer-state",
+ "printer-state-reasons"
+ };
+
+ if (job_canceled)
+ return (CUPS_BACKEND_OK);
+
+ fprintf(stderr, "DEBUG: Getting Printer Attributes.\n");
+ fprintf(stderr, "DEBUG: Device URL %s.\n", device_uri);
+
+ /*
+ * Parse device_uri
+ */
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme),
+ username, sizeof(username), hostname, sizeof(hostname),
+ &port, resource, sizeof(resource)) != HTTP_URI_OK)
+ {
+ fprintf(stderr, "ERROR: Problem parsing device_uri, %s\n", device_uri);
+ return (CUPS_BACKEND_STOP);
+ }
+
+ if (!port)
+ port = IPP_PORT;
+
+ sprintf(portname, "%d", port);
+
+ fprintf(stderr, "DEBUG: Getting Printer Attributes.\n");
+
+ /*
+ * Configure password
+ */
+ cupsSetPasswordCB(password_cb);
+
+ /*
+ * reset, in case a previous attempt for
+ * another printer left residue
+ */
+ cupsSetUser(NULL);
+ password = NULL;
+ password_retries = 0;
+
+ if (*username)
+ {
+ if ((password = strchr(username, ':')) != NULL)
+ {
+ *password = '\0';
+ password++;
+ }
+
+ cupsSetUser(username);
+ }
+ else if (!getuid())
+ {
+ const char *username_env;
+
+ if ((username_env = getenv("AUTH_USERNAME")) != NULL)
+ {
+ cupsSetUser(username_env);
+ password = getenv("AUTH_PASSWORD");
+ }
+ }
+
+ /*
+ * Try connecting to the remote server...
+ */
+ fprintf(stderr, "DEBUG: Connecting to %s:%d\n", hostname, port);
+ _cupsLangPuts(stderr, _("INFO: Connecting to printer...\n"));
+
+ http = httpConnectEncrypt(hostname, port, cupsEncryption());
+
+ /*
+ * Deal the socket not being open.
+ */
+ if (!http)
+ {
+ int error = errno; /* Connection error */
+
+ switch (error)
+ {
+ case EHOSTDOWN :
+ _cupsLangPuts(stderr, _("WARNING: "
+ "The printer may not exist or "
+ "is unavailable at this time.\n"));
+ break;
+ case EHOSTUNREACH :
+ _cupsLangPuts(stderr, _("WARNING: "
+ "The printer is unreachable at this "
+ "time.\n"));
+ break;
+ case ECONNREFUSED :
+ _cupsLangPuts(stderr, _("WARNING: "
+ "Connection Refused.\n"));
+ break;
+ default :
+ fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(errno));
+ break;
+ }
+
+ rc = CUPS_BACKEND_FAILED;
+ sleep(5);
+ goto prt_available_cleanup;
+ }
+
+
+#ifdef AF_INET6
+ if (http->hostaddr->addr.sa_family == AF_INET6)
+ fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6)...\n",
+ httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
+ ntohs(http->hostaddr->ipv6.sin6_port));
+ else
+#endif /* AF_INET6 */
+ if (http->hostaddr->addr.sa_family == AF_INET)
+ fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4)...\n",
+ httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
+ ntohs(http->hostaddr->ipv4.sin_port));
+
+ /*
+ * Search the resource string for options.
+ * We only care about version, for the moment.
+ */
+ version = 11;
+
+ if ((option_ptr = strchr(resource, '?')) != NULL)
+ {
+ *option_ptr++ = '\0';
+
+ if ((option_ptr = strstr(option_ptr, "version="))!=NULL)
+ {
+ int minor; /* minor version from URI */
+ int major; /* major version from URI */
+ char *version_str; /* ipp version */
+
+ option_ptr += 8;
+ version_str = option_ptr;
+
+ while (*option_ptr && *option_ptr != '&' && *option_ptr != '+')
+ option_ptr++;
+
+ if (*option_ptr)
+ *option_ptr = '\0';
+
+ sscanf(version_str, "%d.%d", &major, &minor);
+
+ version = (major * 10) + minor;
+
+ switch(version)
+ {
+ case 10 :
+ case 11 :
+ case 20 :
+ case 21 :
+ fprintf(stderr,
+ "DEBUG: Set version to %d from URI\n",
+ version);
+ break;
+ default :
+ _cupsLangPrintf(stderr,
+ _("DEBUG: Invalid version, %d, from URI. "
+ "Using default of 1.1 \n"),
+ version);
+ version = 11;
+ }
+ }
+ }
+
+
+ /*
+ * Build a URI for the printer. We can't use the URI in argv[0]
+ * because it might contain username:password information...
+ */
+ if (httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), scheme, NULL,
+ hostname, port, resource) != HTTP_URI_OK)
+ {
+ fprintf(stderr, "ERROR: Problem assembling printer URI from host %s, "
+ "port %d, resource %s\n", hostname, port, resource);
+ return (CUPS_BACKEND_STOP);
+ }
+
+ /*
+ * Build the IPP request...
+ */
+ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
+ request->request.op.version[0] = version / 10;
+ request->request.op.version[1] = version % 10;
+
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
+ NULL, uri);
+
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
+ NULL, pattrs);
+
+ /*
+ * Do the request...
+ */
+ fputs("DEBUG: Getting supported attributes...\n", stderr);
+
+ fprintf(stderr, "DEBUG: IPP Request Structure Built.\n");
+
+ *attributes = cupsDoRequest(http, request, resource);
+ ipp_status = cupsLastError();
+
+ fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n",
+ ippErrorString(ipp_status), cupsLastErrorString());
+
+ if (ipp_status > IPP_OK_CONFLICT)
+ {
+ fprintf(stderr, "DEBUG: Get-Printer-Attributes returned %s.\n",
+ ippErrorString(ipp_status));
+ switch(ipp_status)
+ {
+ case IPP_FORBIDDEN :
+ case IPP_NOT_AUTHORIZED :
+ _cupsLangPuts(stderr, _("ERROR: Not Authorized.\n"));
+ rc = CUPS_BACKEND_AUTH_REQUIRED;
+ break;
+ case IPP_PRINTER_BUSY :
+ case IPP_SERVICE_UNAVAILABLE :
+ _cupsLangPuts(stderr, _("ERROR: "
+ "The printer is not responding.\n"));
+ rc = CUPS_BACKEND_FAILED;
+ break;
+ case IPP_BAD_REQUEST :
+ case IPP_VERSION_NOT_SUPPORTED :
+ fprintf(stderr, "ERROR: Destination does not support IPP version %d\n",
+ version);
+ case IPP_NOT_FOUND :
+ _cupsLangPuts(stderr, _("ERROR: "
+ "The printer configuration is incorrect or the "
+ "printer no longer exists.\n"));
+ rc = CUPS_BACKEND_STOP;
+ break;
+ default :
+ rc = CUPS_BACKEND_FAILED;
+ }
+ goto prt_available_cleanup;
+ }
+
+prt_available_cleanup :
+ httpClose(http);
+ return (rc);
+}
+
+static int
+move_job(int jobid, /* Job ID */
+ const char *dest) /* Destination ipp address */
+{
+ ipp_t *request; /* IPP Request */
+ char job_uri[HTTP_MAX_URI]; /* job-uri */
+
+ http_t* http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+
+ if (!http)
+ {
+ _cupsLangPrintf(stderr,
+ _("failover: Unable to connect to server: %s\n"),
+ strerror(errno));
+ return (CUPS_BACKEND_FAILED);
+ }
+
+ /*
+ * Build a CUPS_MOVE_JOB request, which requires the following
+ * attributes:
+ *
+ * job-uri/printer-uri
+ * job-printer-uri
+ * requesting-user-name
+ */
+
+ request = ippNewRequest(CUPS_MOVE_JOB);
+
+ snprintf(job_uri, sizeof(job_uri), "ipp://localhost/jobs/%d", jobid);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL,
+ job_uri);
+
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+ "requesting-user-name",
+ NULL, cupsUser());
+
+ ippAddString(request, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri",
+ NULL, dest);
+
+ /*
+ * Do the request and get back a response...
+ */
+
+ ippDelete(cupsDoRequest(http, request, "/jobs"));
+
+ httpClose(http);
+
+ if (cupsLastError() > IPP_OK_CONFLICT)
+ {
+ _cupsLangPrintf(stderr, "failover: %s\n", cupsLastErrorString());
+ return (CUPS_BACKEND_FAILED);
+ }
+ else
+ return (CUPS_BACKEND_OK);
+}
+
+/*
+ * 'sigterm_handler()' - handles a sigterm, i.e. job canceled
+ */
+static void
+sigterm_handler(int sig)
+{
+ if (!job_canceled)
+ {
+ write(2, "DEBUG: Got SIGTERM.\n", 20);
+ job_canceled = 1;
+ }
+ else
+ {
+ /*
+ * Job has already been canceled, so just exit
+ */
+ exit(1);
+ }
+}
+
+/*
+ * 'password_cb()' - Disable the password prompt for cupsDoFileRequest().
+ */
+static const char * /* O - Password */
+password_cb(const char *prompt) /* I - Prompt (not used) */
+{
+ auth_info_required = "username,password";
+ password_retries++;
+
+ if(password_retries < FAILOVER_PASSWORD_RETRIES_MAX)
+ return (password);
+ else
+ return (NULL);
+}
diff -up cups-2.3.3/backend/Makefile.failover cups-2.3.3/backend/Makefile
--- cups-2.3.3/backend/Makefile.failover 2020-04-27 20:04:29.000000000 +0200
+++ cups-2.3.3/backend/Makefile 2020-06-11 08:52:31.212642019 +0200
@@ -22,6 +22,7 @@ include ../Makedefs
RBACKENDS = \
ipp \
lpd \
+ failover \
$(DNSSD_BACKEND)
UBACKENDS = \
snmp \
@@ -45,6 +46,7 @@ LIBOBJS = \
OBJS = \
ipp.o \
lpd.o \
+ failover.o \
dnssd.o \
snmp.o \
socket.o \
@@ -276,6 +278,15 @@ lpd: lpd.o ../cups/$(LIBCUPS) libbackend
#
+# failover
+#
+
+failover: failover.o ../cups/$(LIBCUPS) libbackend.a
+ echo Linking $@...
+ $(LD_CC) $(ALL_LDFLAGS) -o failover failover.o libbackend.a $(LINKCUPS)
+
+
+#
# snmp
#

View File

@ -1,32 +0,0 @@
diff -up cups-1.6b1/scheduler/job.c.filter-debug cups-1.6b1/scheduler/job.c
--- cups-1.6b1/scheduler/job.c.filter-debug 2012-05-25 16:06:01.000000000 +0200
+++ cups-1.6b1/scheduler/job.c 2012-05-25 16:07:46.309259511 +0200
@@ -625,10 +625,28 @@ cupsdContinueJob(cupsd_job_t *job) /* I
if (!filters)
{
+ mime_filter_t *current;
+
cupsdLogJob(job, CUPSD_LOG_ERROR,
"Unable to convert file %d to printable format.",
job->current_file);
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
+ "Required: %s/%s -> %s/%s",
+ job->filetypes[job->current_file]->super,
+ job->filetypes[job->current_file]->type,
+ job->printer->filetype->super,
+ job->printer->filetype->type);
+
+ for (current = (mime_filter_t *)cupsArrayFirst(MimeDatabase->srcs);
+ current;
+ current = (mime_filter_t *)cupsArrayNext(MimeDatabase->srcs))
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
+ "Available: %s/%s -> %s/%s (%s)",
+ current->src->super, current->src->type,
+ current->dst->super, current->dst->type,
+ current->filter);
+
abort_message = "Aborting job because it cannot be printed.";
abort_state = IPP_JOB_ABORTED;

View File

@ -1,21 +0,0 @@
diff -up cups-1.5b1/backend/snmp.c.hp-deviceid-oid cups-1.5b1/backend/snmp.c
--- cups-1.5b1/backend/snmp.c.hp-deviceid-oid 2011-05-20 05:49:49.000000000 +0200
+++ cups-1.5b1/backend/snmp.c 2011-05-24 17:24:48.000000000 +0200
@@ -187,6 +187,7 @@ static const int UriOID[] = { CUPS_OID_p
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 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;
@@ -1006,6 +1007,9 @@ read_snmp_response(int fd) /* I - SNMP
_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 :

View File

@ -1,43 +0,0 @@
diff --git a/cups/ipp-vars.c b/cups/ipp-vars.c
index 395b0eb..60aa991 100644
--- a/cups/ipp-vars.c
+++ b/cups/ipp-vars.c
@@ -13,6 +13,7 @@
*/
#include <cups/cups.h>
+#include <cups/cups-private.h>
#include "ipp-private.h"
#include "string-private.h"
#include "debug-internal.h"
@@ -221,9 +222,29 @@ _ippVarsSet(_ipp_vars_t *v, /* I - IPP variables */
if (!strcmp(name, "uri"))
{
char uri[1024]; /* New printer URI */
+ char resolved[1024]; /* Resolved mDNS URI */
+ char value_uri[1024]; /* URI from value */
http_uri_status_t uri_status; /* URI status */
- if ((uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, value, v->scheme, sizeof(v->scheme), v->username, sizeof(v->username), v->host, sizeof(v->host), &(v->port), v->resource, sizeof(v->resource))) < HTTP_URI_STATUS_OK)
+ snprintf(value_uri, sizeof(value_uri), "%s", value);
+ value_uri[1023] = '\0';
+
+ if (strstr(value_uri, "._tcp"))
+ {
+ /*
+ * Resolve URI...
+ */
+
+ if (!_httpResolveURI(value_uri, resolved, sizeof(resolved), _HTTP_RESOLVE_DEFAULT, NULL, NULL))
+ {
+ return (0);
+ }
+
+ snprintf(value_uri, sizeof(value_uri), "%s", resolved);
+ value_uri[1023] = '\0';
+ }
+
+ if ((uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, value_uri, v->scheme, sizeof(v->scheme), v->username, sizeof(v->username), v->host, sizeof(v->host), &(v->port), v->resource, sizeof(v->resource))) < HTTP_URI_STATUS_OK)
return (0);
if (v->username[0])

View File

@ -1,63 +0,0 @@
diff -up cups-2.1b1/scheduler/log.c.logrotate cups-2.1b1/scheduler/log.c
--- cups-2.1b1/scheduler/log.c.logrotate 2015-06-04 20:00:31.000000000 +0200
+++ cups-2.1b1/scheduler/log.c 2015-06-29 13:25:09.623350218 +0200
@@ -26,6 +26,9 @@
# include <systemd/sd-journal.h>
#endif /* HAVE_ASL_H */
#include <syslog.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
/*
@@ -135,12 +138,10 @@ cupsdCheckLogFile(cups_file_t **lf, /* I
}
/*
- * Format the filename as needed...
+ * Format the filename...
*/
- if (!*lf ||
- (strncmp(logname, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
- MaxLogSize > 0))
+ if (strncmp(logname, "/dev/", 5))
{
/*
* Handle format strings...
@@ -254,6 +255,34 @@ cupsdCheckLogFile(cups_file_t **lf, /* I
/*
* Change ownership and permissions of non-device logs...
*/
+
+ fchown(cupsFileNumber(*lf), RunUser, Group);
+ fchmod(cupsFileNumber(*lf), LogFilePerm);
+ }
+ }
+
+ /*
+ * Has someone else (i.e. logrotate) already rotated the log for us?
+ */
+ else if (strncmp(filename, "/dev/", 5))
+ {
+ struct stat st;
+ if (stat(filename, &st) || st.st_size == 0)
+ {
+ /* File is either missing or has zero size. */
+
+ cupsFileClose(*lf);
+ if ((*lf = cupsFileOpen(filename, "a")) == NULL)
+ {
+ syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename,
+ strerror(errno));
+
+ return (0);
+ }
+
+ /*
+ * Change ownership and permissions of non-device logs...
+ */
fchown(cupsFileNumber(*lf), RunUser, Group);
fchmod(cupsFileNumber(*lf), LogFilePerm);

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c
index 94a125a..79aab32 100644
--- a/cups/ppd-cache.c
+++ b/cups/ppd-cache.c
@@ -3228,7 +3228,7 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-pdf application/pdf 10 -\"\n");
}
else
- cupsFilePuts(fp, "*cupsManualCopies: true\n");
+ cupsFilePuts(fp, "*cupsManualCopies: True\n");
if (is_apple)
cupsFilePuts(fp, "*cupsFilter2: \"image/urf image/urf 100 -\"\n");
if (is_pwg)

View File

@ -1,10 +0,0 @@
diff -up cups-2.2b2/config-scripts/cups-ssl.m4.no-export-ssllibs cups-2.2b2/config-scripts/cups-ssl.m4
--- cups-2.2b2/config-scripts/cups-ssl.m4.no-export-ssllibs 2016-06-27 15:06:22.299980753 +0200
+++ cups-2.2b2/config-scripts/cups-ssl.m4 2016-06-27 15:08:00.953154042 +0200
@@ -102,5 +102,5 @@ AC_SUBST(IPPALIASES)
AC_SUBST(SSLFLAGS)
AC_SUBST(SSLLIBS)
-EXPORT_SSLLIBS="$SSLLIBS"
+EXPORT_SSLLIBS=""
AC_SUBST(EXPORT_SSLLIBS)

View File

@ -1,22 +0,0 @@
diff --git a/ppdc/ppdc-import.cxx b/ppdc/ppdc-import.cxx
index 04b587d..60d8834 100644
--- a/ppdc/ppdc-import.cxx
+++ b/ppdc/ppdc-import.cxx
@@ -27,7 +27,7 @@ ppdcSource::import_ppd(const char *f) // I - Filename
char line[256], // Comment line
*ptr; // Pointer into line
int cost; // Cost for filter
- ppd_file_t *ppd; // PPD file data
+ ppd_file_t *ppd = NULL; // PPD file data
ppd_group_t *group; // PPD group
ppd_option_t *option; // PPD option
ppd_choice_t *choice; // PPD choice
@@ -323,5 +323,8 @@ ppdcSource::import_ppd(const char *f) // I - Filename
}
}
+ if (ppd)
+ ppdClose(ppd);
+
return (1);
}

View File

@ -1,15 +0,0 @@
diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c
index 5965e38..94a125a 100644
--- a/cups/ppd-cache.c
+++ b/cups/ppd-cache.c
@@ -3735,8 +3735,8 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
*/
if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) == NULL)
- if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) == NULL)
- if ((attr = ippFindAttribute(response, "print-color-mode-supported", IPP_TAG_KEYWORD)) == NULL)
+ if ((attr = ippFindAttribute(response, "print-color-mode-supported", IPP_TAG_KEYWORD)) == NULL)
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) == NULL)
attr = ippFindAttribute(response, "output-mode-supported", IPP_TAG_KEYWORD);
if (attr)

View File

@ -1,14 +0,0 @@
diff --git a/filter/rastertopwg.c b/filter/rastertopwg.c
index 1e63e4e..b3a2e87 100644
--- a/filter/rastertopwg.c
+++ b/filter/rastertopwg.c
@@ -260,7 +260,8 @@ main(int argc, /* I - Number of command-line args */
}
if (inheader.cupsPageSizeName[0] &&
- (pwg_size = _ppdCacheGetSize(cache, inheader.cupsPageSizeName)) != NULL)
+ (pwg_size = _ppdCacheGetSize(cache, inheader.cupsPageSizeName)) != NULL &&
+ pwg_size->map.pwg)
{
strlcpy(outheader.cupsPageSizeName, pwg_size->map.pwg,
sizeof(outheader.cupsPageSizeName));

View File

@ -1,21 +0,0 @@
diff -up cups-1.5b1/backend/snmp.c.ricoh-deviceid-oid cups-1.5b1/backend/snmp.c
--- cups-1.5b1/backend/snmp.c.ricoh-deviceid-oid 2011-05-24 17:29:48.000000000 +0200
+++ cups-1.5b1/backend/snmp.c 2011-05-24 17:29:48.000000000 +0200
@@ -188,6 +188,7 @@ static const int LexmarkProductOID[] = {
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;
@@ -1005,6 +1006,9 @@ read_snmp_response(int fd) /* I - SNMP
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,

View File

@ -1,48 +0,0 @@
diff -up cups-2.2.12/conf/cups-files.conf.in.synconclose cups-2.2.12/conf/cups-files.conf.in
--- cups-2.2.12/conf/cups-files.conf.in.synconclose 2019-08-16 00:35:30.000000000 +0200
+++ cups-2.2.12/conf/cups-files.conf.in 2019-08-19 09:58:14.646567949 +0200
@@ -7,7 +7,7 @@
#FatalErrors @CUPS_FATAL_ERRORS@
# Do we call fsync() after writing configuration or status files?
-#SyncOnClose No
+#SyncOnClose Yes
# Default user and group for filters/backends/helper programs; this cannot be
# any user or group that resolves to ID 0 for security reasons...
diff -up cups-2.2.12/doc/help/man-cups-files.conf.html.synconclose cups-2.2.12/doc/help/man-cups-files.conf.html
--- cups-2.2.12/doc/help/man-cups-files.conf.html.synconclose 2019-08-16 00:35:30.000000000 +0200
+++ cups-2.2.12/doc/help/man-cups-files.conf.html 2019-08-19 09:58:14.646567949 +0200
@@ -150,7 +150,7 @@ The default is "/var/run/cups" or "/etc/
<dd style="margin-left: 5.0em">Specifies whether the scheduler calls
<b>fsync</b>(2)
after writing configuration or state files.
-The default is "No".
+The default is "Yes".
<dt><a name="SystemGroup"></a><b>SystemGroup </b><i>group-name </i>[ ... <i>group-name</i> ]
<dd style="margin-left: 5.0em">Specifies the group(s) to use for <i>@SYSTEM</i> group authentication.
The default contains "admin", "lpadmin", "root", "sys", and/or "system".
diff -up cups-2.2.12/man/cups-files.conf.man.in.synconclose cups-2.2.12/man/cups-files.conf.man.in
--- cups-2.2.12/man/cups-files.conf.5.synconclose 2019-08-16 00:35:30.000000000 +0200
+++ cups-2.2.12/man/cups-files.conf.5 2019-08-19 09:58:14.646567949 +0200
@@ -214,7 +214,7 @@ The default is "/var/run/cups" or "/etc/
Specifies whether the scheduler calls
.BR fsync (2)
after writing configuration or state files.
-The default is "No".
+The default is "Yes".
.\"#SystemGroup
.TP 5
\fBSystemGroup \fIgroup-name \fR[ ... \fIgroup-name\fR ]
diff -up cups-2.2.12/scheduler/conf.c.synconclose cups-2.2.12/scheduler/conf.c
--- cups-2.2.12/scheduler/conf.c.synconclose 2019-08-19 09:58:14.647567941 +0200
+++ cups-2.2.12/scheduler/conf.c 2019-08-19 09:59:36.066927455 +0200
@@ -735,7 +735,7 @@ cupsdReadConfiguration(void)
RootCertDuration = 300;
Sandboxing = CUPSD_SANDBOXING_STRICT;
StrictConformance = FALSE;
- SyncOnClose = FALSE;
+ SyncOnClose = TRUE;
Timeout = 900;
WebInterface = CUPS_DEFAULT_WEBIF;

View File

@ -1,74 +0,0 @@
diff -up cups-2.2.12/scheduler/main.c.systemd-socket cups-2.2.12/scheduler/main.c
--- cups-2.2.12/scheduler/main.c.systemd-socket 2019-08-16 00:35:30.000000000 +0200
+++ cups-2.2.12/scheduler/main.c 2019-08-19 09:31:09.703370325 +0200
@@ -674,8 +674,16 @@ main(int argc, /* I - Number of comm
#ifdef HAVE_ONDEMAND
if (OnDemand)
+ {
cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started on demand.");
- else
+# ifdef HAVE_SYSTEMD
+ sd_notifyf(0, "READY=1\n"
+ "STATUS=Scheduler is running...\n"
+ "MAINPID=%lu",
+ (unsigned long) getpid());
+# endif /* HAVE_SYSTEMD */
+ } else
+
#endif /* HAVE_ONDEMAND */
if (fg)
cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started in foreground.");
diff -up cups-2.2.12/scheduler/org.cups.cupsd.path.in.systemd-socket cups-2.2.12/scheduler/org.cups.cupsd.path.in
--- cups-2.2.12/scheduler/org.cups.cupsd.path.in.systemd-socket 2019-08-16 00:35:30.000000000 +0200
+++ cups-2.2.12/scheduler/org.cups.cupsd.path.in 2019-08-19 09:31:09.703370325 +0200
@@ -1,6 +1,6 @@
[Unit]
Description=CUPS Scheduler
-PartOf=org.cups.cupsd.service
+PartOf=cups.service
[Path]
PathExists=@CUPS_CACHEDIR@/org.cups.cupsd
diff -up cups-2.2.12/scheduler/org.cups.cupsd.service.in.systemd-socket cups-2.2.12/scheduler/org.cups.cupsd.service.in
--- cups-2.2.12/scheduler/org.cups.cupsd.service.in.systemd-socket 2019-08-19 09:31:09.703370325 +0200
+++ cups-2.2.12/scheduler/org.cups.cupsd.service.in 2019-08-19 09:54:58.890036404 +0200
@@ -1,13 +1,13 @@
[Unit]
Description=CUPS Scheduler
Documentation=man:cupsd(8)
-After=sssd.service
+After=sssd.service network.target
[Service]
ExecStart=@sbindir@/cupsd -l
-Type=simple
+Type=notify
Restart=on-failure
[Install]
-Also=org.cups.cupsd.socket org.cups.cupsd.path
+Also=cups.socket cups.path
WantedBy=printer.target
diff -up cups-2.2.12/scheduler/org.cups.cupsd.socket.in.systemd-socket cups-2.2.12/scheduler/org.cups.cupsd.socket.in
--- cups-2.2.12/scheduler/org.cups.cupsd.socket.in.systemd-socket 2019-08-16 00:35:30.000000000 +0200
+++ cups-2.2.12/scheduler/org.cups.cupsd.socket.in 2019-08-19 09:31:09.703370325 +0200
@@ -1,6 +1,6 @@
[Unit]
Description=CUPS Scheduler
-PartOf=org.cups.cupsd.service
+PartOf=cups.service
[Socket]
ListenStream=@CUPS_DEFAULT_DOMAINSOCKET@
diff -up cups-2.2.12/scheduler/org.cups.cups-lpd.socket.systemd-socket cups-2.2.12/scheduler/org.cups.cups-lpd.socket
--- cups-2.2.12/scheduler/org.cups.cups-lpd.socket.systemd-socket 2019-08-16 00:35:30.000000000 +0200
+++ cups-2.2.12/scheduler/org.cups.cups-lpd.socket 2019-08-19 09:31:09.703370325 +0200
@@ -1,6 +1,6 @@
[Unit]
Description=CUPS LPD Server Socket
-PartOf=org.cups.cups-lpd.service
+PartOf=cups-lpd.service
[Socket]
ListenStream=515

View File

@ -1,13 +0,0 @@
diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c
index a87e6be..4600d33 100644
--- a/cgi-bin/admin.c
+++ b/cgi-bin/admin.c
@@ -974,6 +974,8 @@ do_am_printer(http_t *http, /* I - HTTP connection */
cgiSetVariable("TEMPLATE_NAME", template);
}
+
+ cgiSetVariable("DEVICE_URI", var);
}
}

View File

@ -1,12 +0,0 @@
diff -up cups-2.2.12/scheduler/org.cups.cupsd.service.in.ypbind cups-2.2.12/scheduler/org.cups.cupsd.service.in
--- cups-2.2.12/scheduler/org.cups.cupsd.service.in.ypbind 2019-08-19 10:00:47.586326493 +0200
+++ cups-2.2.12/scheduler/org.cups.cupsd.service.in 2019-08-19 10:01:39.295890076 +0200
@@ -1,7 +1,7 @@
[Unit]
Description=CUPS Scheduler
Documentation=man:cupsd(8)
-After=sssd.service network.target
+After=sssd.service network.target ypbind.service
[Service]
ExecStart=@sbindir@/cupsd -l

View File

@ -1,5 +0,0 @@
/var/log/cups/*_log {
missingok
notifempty
sharedscripts
}

418
cups.spec
View File

@ -1,72 +1,67 @@
%global cups_serverbin %{_exec_prefix}/lib/cups %global cups_serverbin %{_exec_prefix}/lib/cups
Name: cups Name: cups
Epoch: 1 Epoch: 1
Version: 2.3.3 Version: 2.4.0
Release: 8 Release: 1
Summary: CUPS is the standards-based, open source printing system for linux operating systems. Summary: CUPS is the standards-based, open source printing system for linux operating systems.
License: GPLv2+ and LGPLv2+ with exceptions and AML License: GPLv2+ and LGPLv2+ with exceptions and AML
Url: http://www.cups.org/ Url: http://www.cups.org/
Source0: https://github.com/apple/cups/archive/v%{version}.tar.gz # Apple stopped uploading the new versions into github, use OpenPrinting fork
Source0: https://github.com/OpenPrinting/cups/releases/download/v%{version}/cups-%{version}-source.tar.gz
Source2: cupsprinter.png Source1: cupsprinter.png
Source3: cups.logrotate Source2: macros.cups
Source5: macros.cups
Patch1: cups-system-auth.patch Patch1: cups-system-auth.patch
Patch2: cups-multilib.patch Patch2: cups-multilib.patch
Patch3: cups-banners.patch Patch3: cups-banners.patch
Patch4: cups-no-export-ssllibs.patch Patch4: cups-direct-usb.patch
Patch5: cups-direct-usb.patch Patch5: cups-driverd-timeout.patch
Patch6: cups-eggcups.patch Patch6: cups-usb-paperout.patch
Patch7: cups-driverd-timeout.patch Patch7: cups-uri-compat.patch
Patch8: cups-logrotate.patch Patch8: cups-freebind.patch
Patch9: cups-usb-paperout.patch Patch9: cups-ipp-multifile.patch
Patch10: cups-uri-compat.patch Patch10: cups-web-devices-timeout.patch
Patch11: cups-hp-deviceid-oid.patch
Patch12: cups-ricoh-deviceid-oid.patch
Patch13: cups-systemd-socket.patch
Patch14: cups-freebind.patch
Patch15: cups-ipp-multifile.patch
Patch16: cups-web-devices-timeout.patch
Patch17: cups-synconclose.patch
Patch18: cups-ypbind.patch
Patch19: cups-lspp.patch
Patch20: cups-failover-backend.patch
Patch21: cups-filter-debug.patch
Patch22: cups-dymo-deviceid.patch
Patch23: cups-autostart-when-enabled.patch
Patch24: cups-prioritize-print-color-mode.patch
Patch25: cups-ppdleak.patch
Patch26: cups-rastertopwg-crash.patch
Patch27: cups-etimedout.patch
Patch28: cups-webui-uri.patch
Patch29: cups-ipptool-mdns-uri.patch
Patch30: cups-manual-copies.patch
Patch6000: backport-CVE-2020-10001.patch
Provides: cupsddk cupsddk-drivers cups-filesystem cups-client cups-ipptool cups-lpd
Provides: lpd lpr /usr/bin/lpq /usr/bin/lpr /usr/bin/lp /usr/bin/cancel /usr/bin/lprm /usr/bin/lpstat
Obsoletes: cups-client cups-filesystem cups-lpd cups-ipptool
Provides: cups-printerapp = %{version}-%{release}
Obsoletes: cups-printerapp < %{version}-%{release}
BuildRequires: pam-devel pkgconf-pkg-config pkgconfig(gnutls) libacl-devel openldap-devel pkgconfig(libusb-1.0) BuildRequires: pam-devel pkgconf-pkg-config pkgconfig(gnutls) libacl-devel openldap-devel pkgconfig(libusb-1.0)
BuildRequires: krb5-devel pkgconfig(avahi-client) systemd pkgconfig(libsystemd) pkgconfig(dbus-1) python3-cups BuildRequires: krb5-devel pkgconfig(avahi-client) systemd pkgconfig(libsystemd) pkgconfig(dbus-1) python3-cups
BuildRequires: automake zlib-devel gcc gcc-c++ libselinux-devel audit-libs-devel BuildRequires: automake zlib-devel gcc gcc-c++ libselinux-devel audit-libs-devel make
Requires: dbus systemd acl cups-filters /usr/sbin/alternatives %{name}-libs = %{epoch}:%{version}-%{release} Requires: dbus systemd acl cups-filters /usr/sbin/alternatives
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Requires: %{name}-client%{?_isa} = %{epoch}:%{version}-%{release}
Requires: %{name}-filesystem = %{epoch}:%{version}-%{release}
# Requires working PrivateTmp (bug #807672)
Requires(pre): systemd
Requires(post): systemd
Requires(post): grep, sed
Requires(preun): systemd
Requires(postun): systemd
%description %description
CUPS is the standards-based, open source printing system developed by Apple Inc. CUPS is the standards-based, open source printing system developed by Apple Inc.
for UNIX®-like operating systems. CUPS uses the Internet Printing for UNIX®-like operating systems. CUPS uses the Internet Printing
Protocol (IPP) to support printing to local and network printers.. Protocol (IPP) to support printing to local and network printers.
%package client
Summary: CUPS printing system - client programs
License: GPLv2
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Provides: /usr/bin/lpq /usr/bin/lpr /usr/bin/lp /usr/bin/cancel /usr/bin/lprm /usr/bin/lpstat
Requires: /usr/sbin/alternatives
Provides: lpr
%description client
CUPS printing system provides a portable printing layer for
UNIX® operating systems. This package contains command-line client
programs.
%package devel %package devel
Summary: CUPS printing system - development environment Summary: CUPS printing system - development environment
License: LGPLv2 License: LGPLv2
Requires: %{name}-libs = %{epoch}:%{version}-%{release} Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Requires: gnutls-devel krb5-devel zlib-devel Requires: gnutls-devel krb5-devel zlib-devel
Provides: cupsddk-devel
%description devel %description devel
CUPS is the standards-based, open source printing system developed by Apple Inc. CUPS is the standards-based, open source printing system developed by Apple Inc.
@ -77,8 +72,53 @@ package to develop other printer drivers.
Summary: CUPS libs Summary: CUPS libs
License: LGPLv2 and zlib License: LGPLv2 and zlib
%description libs %description libs
The package provides cups libraries CUPS printing system provides a portable printing layer for
UNIX® operating systems. It has been developed by Apple Inc.
to promote a standard printing solution for all UNIX vendors and users.
CUPS provides the System V and Berkeley command-line interfaces.
The cups-libs package provides libraries used by applications to use CUPS
natively, without needing the lp/lpr commands.
%package filesystem
Summary: CUPS printing system - directory layout
BuildArch: noarch
%description filesystem
CUPS printing system provides a portable printing layer for
UNIX® operating systems. This package provides some directories which are
required by other packages that add CUPS drivers (i.e. filters, backends etc.).
%package lpd
Summary: CUPS printing system - lpd emulation
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Provides: lpd
%description lpd
CUPS printing system provides a portable printing layer for
UNIX® operating systems. This is the package that provides standard
lpd emulation.
%package ipptool
Summary: CUPS printing system - tool for performing IPP requests
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Requires: avahi
%description ipptool
Sends IPP requests to the specified URI and tests and/or displays the results.
%package printerapp
Summary: CUPS printing system - tools for printer application
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Requires: avahi
%description printerapp
Provides IPP everywhere printer application ippeveprinter and tools for printing
PostScript and HP PCL document formats - ippevepcl and ippeveps. The printer
application enables older printers for IPP everywhere standard - so if older printer
is installed with a printer application, its print queue acts as IPP everywhere printer
to CUPS daemon. This solution will substitute printer drivers and raw queues in the future.
%package help %package help
Summary: Documents for cups Summary: Documents for cups
@ -92,9 +132,10 @@ Man pages and other related documents.
sed -i -e '1iMaxLogSize 0' conf/cupsd.conf.in sed -i -e '1iMaxLogSize 0' conf/cupsd.conf.in
sed -i -e 's,^ErrorLog .*$,ErrorLog syslog,' -i -e 's,^AccessLog .*$,AccessLog syslog,' -i -e 's,^PageLog .*,PageLog syslog,' conf/cups-files.conf.in sed -i -e 's,^ErrorLog .*$,ErrorLog syslog,' -i -e 's,^AccessLog .*$,AccessLog syslog,' -i -e 's,^PageLog .*,PageLog syslog,' conf/cups-files.conf.in
perl -pi -e "s,^.SILENT:,," Makedefs.in
aclocal -I config-scripts aclocal -I config-scripts
autoconf -I config-scripts autoconf -f -I config-scripts
%build %build
export DSOFLAGS="$DSOFLAGS -L../cgi-bin -L../filter -L../ppdc -L../scheduler -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld -Wl,-z,relro,-z,now -fPIE -pie" export DSOFLAGS="$DSOFLAGS -L../cgi-bin -L../filter -L../ppdc -L../scheduler -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld -Wl,-z,relro,-z,now -fPIE -pie"
@ -107,7 +148,6 @@ export CFLAGS="$RPM_OPT_FLAGS -fstack-protector-all -DLDAP_DEPRECATED=1"
--with-log-file-perm=0600 \ --with-log-file-perm=0600 \
--enable-relro \ --enable-relro \
--with-dbusdir=%{_sysconfdir}/dbus-1 \ --with-dbusdir=%{_sysconfdir}/dbus-1 \
--with-php=/usr/bin/php-cgi \
--enable-avahi \ --enable-avahi \
--enable-threads \ --enable-threads \
--enable-gnutls \ --enable-gnutls \
@ -115,10 +155,15 @@ export CFLAGS="$RPM_OPT_FLAGS -fstack-protector-all -DLDAP_DEPRECATED=1"
--with-xinetd=no \ --with-xinetd=no \
--with-access-log-level=actions \ --with-access-log-level=actions \
--enable-page-logging \ --enable-page-logging \
--with-rundir=%{_rundir}/cups \
--enable-sync-on-close \
localedir=%{_datadir}/locale localedir=%{_datadir}/locale
%make_build %make_build
%check
make check
%install %install
make BUILDROOT=${RPM_BUILD_ROOT} install make BUILDROOT=${RPM_BUILD_ROOT} install
@ -141,26 +186,25 @@ done
mv ${RPM_BUILD_ROOT}%{_mandir}/man8/lpc.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/lpc-cups.8 mv ${RPM_BUILD_ROOT}%{_mandir}/man8/lpc.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/lpc-cups.8
popd popd
mv ${RPM_BUILD_ROOT}%{_unitdir}/org.cups.cupsd.path ${RPM_BUILD_ROOT}%{_unitdir}/cups.path
mv ${RPM_BUILD_ROOT}%{_unitdir}/org.cups.cupsd.service ${RPM_BUILD_ROOT}%{_unitdir}/cups.service
mv ${RPM_BUILD_ROOT}%{_unitdir}/org.cups.cupsd.socket ${RPM_BUILD_ROOT}%{_unitdir}/cups.socket
mv ${RPM_BUILD_ROOT}%{_unitdir}/org.cups.cups-lpd.socket ${RPM_BUILD_ROOT}%{_unitdir}/cups-lpd.socket
mv ${RPM_BUILD_ROOT}%{_unitdir}/org.cups.cups-lpd@.service ${RPM_BUILD_ROOT}%{_unitdir}/cups-lpd@.service
/bin/sed -i -e "s,org.cups.cupsd,cups,g" ${RPM_BUILD_ROOT}%{_unitdir}/cups.service
install -d ${RPM_BUILD_ROOT}%{_datadir}/pixmaps ${RPM_BUILD_ROOT}%{_sysconfdir}/X11/sysconfig \ install -d ${RPM_BUILD_ROOT}%{_datadir}/pixmaps ${RPM_BUILD_ROOT}%{_sysconfdir}/X11/sysconfig \
${RPM_BUILD_ROOT}%{_sysconfdir}/X11/applnk/System ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d \ ${RPM_BUILD_ROOT}%{_sysconfdir}/X11/applnk/System \
${RPM_BUILD_ROOT}%{_rpmconfigdir}/macros.d ${RPM_BUILD_ROOT}%{_rpmconfigdir}/macros.d
install -p -m 644 %{SOURCE2} ${RPM_BUILD_ROOT}%{_datadir}/pixmaps install -p -m 644 %{SOURCE1} ${RPM_BUILD_ROOT}%{_datadir}/pixmaps
install -p -m 644 %{SOURCE3} ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/cups install -m 0644 %{SOURCE2} ${RPM_BUILD_ROOT}%{_rpmconfigdir}/macros.d
install -m 0644 %{SOURCE5} ${RPM_BUILD_ROOT}%{_rpmconfigdir}/macros.d
touch ${RPM_BUILD_ROOT}%{_sysconfdir}/cups/{printers,classes,client,subscriptions}.conf touch ${RPM_BUILD_ROOT}%{_sysconfdir}/cups/{printers,classes,client,subscriptions}.conf
touch ${RPM_BUILD_ROOT}%{_sysconfdir}/cups/lpoptions touch ${RPM_BUILD_ROOT}%{_sysconfdir}/cups/lpoptions
install -d ${RPM_BUILD_ROOT}%{_datadir}/ppd install -d ${RPM_BUILD_ROOT}%{_datadir}/ppd
# Remove unshipped files.
rm -rf %{buildroot}%{_mandir}/cat? %{buildroot}%{_mandir}/*/cat?
rm -f %{buildroot}%{_datadir}/applications/cups.desktop
rm -rf %{buildroot}%{_datadir}/icons
# there are pdf-banners shipped with cups-filters (#919489)
rm -rf %{buildroot}%{_datadir}/cups/banners
rm -f %{buildroot}%{_datadir}/cups/data/testprint
install -d ${RPM_BUILD_ROOT}%{_tmpfilesdir} install -d ${RPM_BUILD_ROOT}%{_tmpfilesdir}
cat > ${RPM_BUILD_ROOT}%{_tmpfilesdir}/cups.conf <<EOF cat > ${RPM_BUILD_ROOT}%{_tmpfilesdir}/cups.conf <<EOF
d /run/cups 0755 root lp - d /run/cups 0755 root lp -
@ -181,32 +225,50 @@ s:.*\('%{_datadir}'/\)\([^/_]\+\)\(.*\.po$\):%lang(\2) \1\2\3:
/^\([^%].*\)/d /^\([^%].*\)/d
' > %{name}.lang ' > %{name}.lang
%pre
%preun
%systemd_preun %{name}.path %{name}.socket %{name}.service
%systemd_preun cups-lpd.socket
%post %post
%systemd_post %{name}.path %{name}.socket %{name}.service %systemd_post %{name}.path %{name}.socket %{name}.service
install -d ${RPM_BUILD_ROOT}%{_localstatedir}/run/cups/certs install -d ${RPM_BUILD_ROOT}%{_localstatedir}/run/cups/certs
/bin/sed -i -e "s,^PageLogFormat,#PageLogFormat,i" %{_sysconfdir}/cups/cups-files.conf /bin/sed -i -e "s,^PageLogFormat,#PageLogFormat,i" %{_sysconfdir}/cups/cups-files.conf
%post client
/usr/sbin/alternatives --install %{_bindir}/lpr print %{_bindir}/lpr.cups 40 \
--slave %{_bindir}/lp print-lp %{_bindir}/lp.cups \
--slave %{_bindir}/lpq print-lpq %{_bindir}/lpq.cups \
--slave %{_bindir}/lprm print-lprm %{_bindir}/lprm.cups \
--slave %{_bindir}/lpstat print-lpstat %{_bindir}/lpstat.cups \
--slave %{_bindir}/cancel print-cancel %{_bindir}/cancel.cups \
--slave %{_sbindir}/lpc print-lpc %{_sbindir}/lpc.cups \
--slave %{_mandir}/man1/cancel.1.gz print-cancelman %{_mandir}/man1/cancel-cups.1.gz \
--slave %{_mandir}/man1/lp.1.gz print-lpman %{_mandir}/man1/lp-cups.1.gz \
--slave %{_mandir}/man8/lpc.8.gz print-lpcman %{_mandir}/man8/lpc-cups.8.gz \
--slave %{_mandir}/man1/lpq.1.gz print-lpqman %{_mandir}/man1/lpq-cups.1.gz \
--slave %{_mandir}/man1/lpr.1.gz print-lprman %{_mandir}/man1/lpr-cups.1.gz \
--slave %{_mandir}/man1/lprm.1.gz print-lprmman %{_mandir}/man1/lprm-cups.1.gz \
--slave %{_mandir}/man1/lpstat.1.gz print-lpstatman %{_mandir}/man1/lpstat-cups.1.gz || :
%post lpd
%systemd_post cups-lpd.socket %systemd_post cups-lpd.socket
exit 0
%ldconfig_scriptlets libs
%post libs -p /sbin/ldconfig
%preun
%systemd_preun %{name}.path %{name}.socket %{name}.service
%preun client
if [ $1 -eq 0 ] ; then
/usr/sbin/alternatives --remove print %{_bindir}/lpr.cups || :
fi
%preun lpd
%systemd_preun cups-lpd.socket
%postun %postun
%systemd_postun_with_restart %{name}.path %{name}.socket %{name}.service %systemd_postun_with_restart %{name}.path %{name}.socket %{name}.service
%postun lpd
%systemd_postun_with_restart cups-lpd.socket %systemd_postun_with_restart cups-lpd.socket
exit 0
%postun libs -p /sbin/ldconfig
%triggerin -- samba-client %triggerin -- samba-client
ln -sf %{_libexecdir}/samba/cups_backend_smb %{_exec_prefix}/lib/cups/backend/smb || : ln -sf %{_libexecdir}/samba/cups_backend_smb %{_exec_prefix}/lib/cups/backend/smb || :
@ -217,13 +279,78 @@ exit 0
rm -f %{_exec_prefix}/lib/cups/backend/smb rm -f %{_exec_prefix}/lib/cups/backend/smb
%files -f %{name}.lang %files -f %{name}.lang
%{_bindir}/cupstestppd
%{_bindir}/ppd*
%{_sbindir}/*
# client subpackage
%exclude %{_sbindir}/lpc.cups
%dir %{cups_serverbin}/daemon
%{cups_serverbin}/daemon/cups-deviced
%{cups_serverbin}/daemon/cups-driverd
%{cups_serverbin}/daemon/cups-exec
%{cups_serverbin}/backend/*
%{cups_serverbin}/cgi-bin
%{cups_serverbin}/filter/*
%{cups_serverbin}/monitor
%{cups_serverbin}/notifier
%{_datadir}/cups/drv/sample.drv
%{_datadir}/cups/examples
%{_datadir}/cups/mime/mime.types
%{_datadir}/cups/mime/mime.convs
%{_datadir}/cups/ppdc/*.defs
%{_datadir}/cups/ppdc/*.h
%dir %{_datadir}/cups/templates
%{_datadir}/cups/templates/*.tmpl
%dir %{_datadir}/cups/templates/de
%{_datadir}/cups/templates/de/*.tmpl
%dir %{_datadir}/cups/templates/da
%{_datadir}/cups/templates/da/*.tmpl
%dir %{_datadir}/cups/templates/es
%{_datadir}/cups/templates/es/*.tmpl
%dir %{_datadir}/cups/templates/fr
%{_datadir}/cups/templates/fr/*.tmpl
%dir %{_datadir}/cups/templates/ja
%{_datadir}/cups/templates/ja/*.tmpl
%dir %{_datadir}/cups/templates/pt_BR
%{_datadir}/cups/templates/pt_BR/*.tmpl
%dir %{_datadir}/cups/templates/ru
%{_datadir}/cups/templates/ru/*.tmpl
%dir %{_datadir}/%{name}/usb
%{_datadir}/%{name}/usb/org.cups.usb-quirks
%dir %{_datadir}/%{name}/www
%{_datadir}/%{name}/www/images
%{_datadir}/%{name}/www/*.css
%dir %{_datadir}/%{name}/www/de
%dir %{_datadir}/%{name}/www/da
%dir %{_datadir}/%{name}/www/es
%dir %{_datadir}/%{name}/www/fr
%dir %{_datadir}/%{name}/www/ja
%dir %{_datadir}/%{name}/www/pt_BR
%dir %{_datadir}/%{name}/www/ru
%{_datadir}/pixmaps/cupsprinter.png
%dir %attr(1770,root,lp) %{_localstatedir}/spool/cups/tmp
%dir %attr(0710,root,lp) %{_localstatedir}/spool/cups
%dir %attr(0755,root,lp) %{_localstatedir}/log/cups
# client subpackage
%exclude %{_mandir}/man1/lp*.1.gz
%exclude %{_mandir}/man1/cancel-cups.1.gz
%exclude %{_mandir}/man8/lpc-cups.8.gz
# devel subpackage
%exclude %{_mandir}/man1/cups-config.1.gz
# ipptool subpackage
%exclude %{_mandir}/man1/ipptool.1.gz
%exclude %{_mandir}/man5/ipptoolfile.5.gz
# lpd subpackage
%exclude %{_mandir}/man8/cups-lpd.8.gz
# printerapp
%exclude %{_mandir}/man1/ippeveprinter.1.gz
%exclude %{_mandir}/man7/ippevepcl.7.gz
%exclude %{_mandir}/man7/ippeveps.7.gz
%dir %attr(0755,root,lp) %{_rundir}/cups
%dir %attr(0511,lp,sys) %{_rundir}/cups/certs
%dir %attr(0755,root,lp) %{_sysconfdir}/cups %dir %attr(0755,root,lp) %{_sysconfdir}/cups
%dir %attr(0755,root,lp) %{_localstatedir}/run/cups
%dir %attr(0511,lp,sys) %{_localstatedir}/run/cups/certs
%{_tmpfilesdir}/cups.conf
%{_tmpfilesdir}/cups-lp.conf
%verify(not md5 size mtime) %config(noreplace) %attr(0640,root,lp) %{_sysconfdir}/cups/cupsd.conf
%attr(0640,root,lp) %{_sysconfdir}/cups/cupsd.conf.default %attr(0640,root,lp) %{_sysconfdir}/cups/cupsd.conf.default
%verify(not md5 size mtime) %config(noreplace) %attr(0640,root,lp) %{_sysconfdir}/cups/cupsd.conf
%verify(not md5 size mtime) %config(noreplace) %attr(0640,root,lp) %{_sysconfdir}/cups/cups-files.conf %verify(not md5 size mtime) %config(noreplace) %attr(0640,root,lp) %{_sysconfdir}/cups/cups-files.conf
%attr(0640,root,lp) %{_sysconfdir}/cups/cups-files.conf.default %attr(0640,root,lp) %{_sysconfdir}/cups/cups-files.conf.default
%verify(not md5 size mtime) %config(noreplace) %attr(0644,root,lp) %{_sysconfdir}/cups/client.conf %verify(not md5 size mtime) %config(noreplace) %attr(0644,root,lp) %{_sysconfdir}/cups/client.conf
@ -235,104 +362,91 @@ rm -f %{_exec_prefix}/lib/cups/backend/smb
%verify(not md5 size mtime) %config(noreplace) %attr(0644,root,lp) %{_sysconfdir}/cups/lpoptions %verify(not md5 size mtime) %config(noreplace) %attr(0644,root,lp) %{_sysconfdir}/cups/lpoptions
%dir %attr(0755,root,lp) %{_sysconfdir}/cups/ppd %dir %attr(0755,root,lp) %{_sysconfdir}/cups/ppd
%dir %attr(0700,root,lp) %{_sysconfdir}/cups/ssl %dir %attr(0700,root,lp) %{_sysconfdir}/cups/ssl
%config(noreplace) %{_sysconfdir}/pam.d/cups
%config(noreplace) %{_sysconfdir}/logrotate.d/cups
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/cups.conf %config(noreplace) %{_sysconfdir}/dbus-1/system.d/cups.conf
%config(noreplace) %{_sysconfdir}/pam.d/cups
%{_tmpfilesdir}/cups.conf
%{_tmpfilesdir}/cups-lp.conf
%attr(0644, root, root)%{_unitdir}/%{name}.service
%attr(0644, root, root)%{_unitdir}/%{name}.socket
%attr(0644, root, root)%{_unitdir}/%{name}.path
%files client
%{_bindir}/cancel*
%{_bindir}/lp*
%{_sbindir}/lpc.cups
%{_mandir}/man1/cancel-cups.1.gz
%{_mandir}/man1/lp*.1.gz
%{_mandir}/man8/lpc-cups.8.gz
%files libs
%{license} LICENSE
%{license} NOTICE
%{_libdir}/libcups.so.2
%{_libdir}/libcupsimage.so.2
%files filesystem
%dir %{cups_serverbin}
%dir %{cups_serverbin}/backend
%dir %{cups_serverbin}/driver
%dir %{cups_serverbin}/filter
%dir %{_datadir}/cups
%dir %{_datadir}/cups/data %dir %{_datadir}/cups/data
%dir %{_datadir}/cups/drv %dir %{_datadir}/cups/drv
%dir %{_datadir}/cups/mime %dir %{_datadir}/cups/mime
%dir %{_datadir}/cups/model %dir %{_datadir}/cups/model
%dir %{_datadir}/cups/ppdc %dir %{_datadir}/cups/ppdc
%dir %{_datadir}/ppd %dir %{_datadir}/ppd
%exclude %{_mandir}/cat?
%exclude %{_mandir}/*/cat? %files devel
%exclude %{_datadir}/applications/cups.desktop %{_bindir}/cups-config
%exclude %{_datadir}/icons %{_includedir}/cups
%exclude %{_datadir}/cups/banners %{_libdir}/*.so
%exclude %{_datadir}/cups/data/testprint %{_mandir}/man1/cups-config.1.gz
%{_rpmconfigdir}/macros.d/macros.cups
%{_unitdir}/%{name}.service %{_prefix}/lib/pkgconfig/cups.pc
%{_unitdir}/%{name}.socket
%{_unitdir}/%{name}.path %files lpd
%{_unitdir}/cups-lpd.socket %{cups_serverbin}/daemon/cups-lpd
%{_unitdir}/cups-lpd@.service %{_mandir}/man8/cups-lpd.8.gz
%{_bindir}/cupstestppd %attr(0644, root, root)%{_unitdir}/cups-lpd.socket
#%%{_bindir}/cupstestdsc %attr(0644, root, root)%{_unitdir}/cups-lpd@.service
%{_bindir}/ppd*
%{_bindir}/cancel* %files ipptool
%{_bindir}/lp*
%{_bindir}/ipptool
%{_bindir}/ippfind %{_bindir}/ippfind
%{_bindir}/ipptool
%dir %{_datadir}/cups/ipptool
%{_datadir}/cups/ipptool/*
%{_mandir}/man1/ipptool.1.gz
%{_mandir}/man5/ipptoolfile.5.gz
%files printerapp
%{_bindir}/ippeveprinter %{_bindir}/ippeveprinter
%{_sbindir}/*
%dir %{cups_serverbin}/command %dir %{cups_serverbin}/command
%{cups_serverbin}/command/ippevepcl %{cups_serverbin}/command/ippevepcl
%{cups_serverbin}/command/ippeveps %{cups_serverbin}/command/ippeveps
%{_mandir}/man1/ippeveprinter.1.gz
%{_exec_prefix}/lib/cups/backend/* %{_mandir}/man7/ippevepcl.7.gz
%{_exec_prefix}/lib/cups/cgi-bin %{_mandir}/man7/ippeveps.7.gz
%dir %{_exec_prefix}/lib/cups/driver
%dir %{_exec_prefix}/lib/cups/daemon
%{_exec_prefix}/lib/cups/daemon/cups-deviced
%{_exec_prefix}/lib/cups/daemon/cups-driverd
%{_exec_prefix}/lib/cups/daemon/cups-exec
%{_exec_prefix}/lib/cups/notifier
%{_exec_prefix}/lib/cups/filter/*
%{_exec_prefix}/lib/cups/monitor
%{_exec_prefix}/lib/cups/daemon/cups-lpd
%{_datadir}/cups/templates/*.tmpl
%{_datadir}/cups/templates/de/*.tmpl
%{_datadir}/cups/templates/fr/*.tmpl
%{_datadir}/cups/templates/es/*.tmpl
%{_datadir}/cups/templates/ja/*.tmpl
%{_datadir}/cups/templates/ru/*.tmpl
%{_datadir}/cups/templates/pt_BR/*.tmpl
%dir %attr(1770,root,lp) %{_localstatedir}/spool/cups/tmp
%dir %attr(0710,root,lp) %{_localstatedir}/spool/cups
%dir %attr(0755,root,lp) %{_localstatedir}/log/cups
%{_datadir}/pixmaps/cupsprinter.png
%{_datadir}/cups/drv/sample.drv
%{_datadir}/cups/examples
%{_datadir}/cups/mime/mime.types
%{_datadir}/cups/mime/mime.convs
%{_datadir}/cups/ppdc/*.defs
%{_datadir}/cups/ppdc/*.h
%{_datadir}/%{name}/www/images
%{_datadir}/%{name}/www/*.css
%dir %{_datadir}/%{name}/usb
%{_datadir}/%{name}/usb/org.cups.usb-quirks
%dir %{_datadir}/cups/ipptool
%{_datadir}/cups/ipptool/*
%files libs
%{license} LICENSE NOTICE
%{_libdir}/lib*.so.*
%files devel
%{_bindir}/cups-config
%{_libdir}/*.so
%{_includedir}/cups
%{_rpmconfigdir}/macros.d/macros.cups
%files help %files help
%{_mandir}/man[1578]/* %{_mandir}/man[1578]/*
%doc README.md CREDITS.md CHANGES.md %doc README.md CREDITS.md CHANGES.md
%doc %{_datadir}/%{name}/www/index.html %doc %{_datadir}/%{name}/www/index.html
%doc %{_datadir}/%{name}/www/help %doc %{_datadir}/%{name}/www/help
%doc %{_datadir}/%{name}/www/robots.txt %doc %{_datadir}/%{name}/www/robots.txt
%doc %{_datadir}/%{name}/www/de/index.html %doc %{_datadir}/%{name}/www/de/index.html
%doc %{_datadir}/%{name}/www/da/index.html
%doc %{_datadir}/%{name}/www/es/index.html %doc %{_datadir}/%{name}/www/es/index.html
%doc %{_datadir}/%{name}/www/fr/index.html
%doc %{_datadir}/%{name}/www/ja/index.html %doc %{_datadir}/%{name}/www/ja/index.html
%doc %{_datadir}/%{name}/www/ru/index.html %doc %{_datadir}/%{name}/www/ru/index.html
%doc %{_datadir}/%{name}/www/pt_BR/index.html %doc %{_datadir}/%{name}/www/pt_BR/index.html
%doc %{_datadir}/%{name}/www/apple-touch-icon.png %doc %{_datadir}/%{name}/www/apple-touch-icon.png
%changelog %changelog
* Thu Dec 9 2021 hanhui <hanhui15@huawei.com> - 2.4.0-1
- DESC:update to cups-2.4.0
* Thu Nov 04 2021 wangkerong <wangkerong@huawei.com> - 2.3.3-8 * Thu Nov 04 2021 wangkerong <wangkerong@huawei.com> - 2.3.3-8
- Type:bugfix - Type:bugfix
- ID:NA - ID:NA

View File

@ -1,51 +0,0 @@
#!/bin/sh
# This is a modified version of 'ncpprint'. It can now be used as a CUPS
# backend.
# Modifications:
# Copyright (C) 2002 Red Hat, inc
# Copyright (C) 2002 Tim Waugh
# Before modification: shipped as /usr/share/printconf/util/ncpprint
if [ -z "$*" ]
then
# This is where we would enumerate all the URIs we support.
# Patches welcome.
exit 0
fi
FILE=$6
if [ -z "$FILE" ]
then
FILE=-
fi
# $DEVICE_URI is 'ncp://[user:password@]server/queue'
URI=${DEVICE_URI#*://}
queue=${URI#*/}
URI=${URI%/$queue}
server=${URI#*@}
URI=${URI%$server}
URI=${URI%@}
if [ -n "$URI" ]
then
user=${URI%:*}
URI=${URI#$user}
password=${URI#:}
fi
#echo user: ${user-(none)}
#echo password: ${password-(none)}
#echo server: $server
#echo queue: $queue
if [ -n "$user" ]
then
if [ -n "$password" ]
then
/usr/bin/nprint -S "$server" -q "$queue" -U "$user" -P "$password" -N "$FILE" 2>/dev/null
else
/usr/bin/nprint -S "$server" -q "$queue" -U "$user" -n -N "$FILE" 2>/dev/null
fi
else
/usr/bin/nprint -S "$server" -q "$queue" -N "$FILE" 2>/dev/null
fi