fix space errors in failover patch

This commit is contained in:
Zdenek Dohnal 2020-05-22 09:04:54 +02:00
parent dacb3dad16
commit c9349a3af9
2 changed files with 159 additions and 153 deletions

View File

@ -1,6 +1,42 @@
diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c diff --git a/backend/Makefile b/backend/Makefile
--- cups-2.3.0/backend/failover.c.failover 2019-10-07 12:22:17.158626746 +0200 index 3038682..6642016 100644
+++ cups-2.3.0/backend/failover.c 2019-10-07 12:22:17.158626746 +0200 --- a/backend/Makefile
+++ b/backend/Makefile
@@ -28,6 +28,7 @@ include ../Makedefs
RBACKENDS = \
ipp \
lpd \
+ failover \
$(DNSSD_BACKEND)
UBACKENDS = \
snmp \
@@ -51,6 +52,7 @@ LIBOBJS = \
OBJS = \
ipp.o \
lpd.o \
+ failover.o \
dnssd.o \
snmp.o \
socket.o \
@@ -275,6 +277,13 @@ lpd: lpd.o ../cups/$(LIBCUPS) libbackend.a
echo Linking $@...
$(LD_CC) $(LDFLAGS) -o lpd lpd.o libbackend.a $(LIBS)
+#
+# failover
+#
+
+failover: failover.o ../cups/$(LIBCUPS) libbackend.a
+ echo Linking $@...
+ $(LD_CC) $(LDFLAGS) -o failover failover.o libbackend.a $(LIBS)
#
# snmp
diff --git a/backend/failover.c b/backend/failover.c
new file mode 100644
index 0000000..9affd8f
--- /dev/null
+++ b/backend/failover.c
@@ -0,0 +1,837 @@ @@ -0,0 +1,837 @@
+/* +/*
+ * Failover Backend for the Common UNIX Printing System (CUPS). + * Failover Backend for the Common UNIX Printing System (CUPS).
@ -90,9 +126,9 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ */ + */
+static int check_printer(const char *device_uri); +static int check_printer(const char *device_uri);
+static int read_config(cups_array_t *printer_array, int *retries, +static int read_config(cups_array_t *printer_array, int *retries,
+ const char *options); + const char *options);
+static int get_printer_attributes(const char *device_uri, +static int get_printer_attributes(const char *device_uri,
+ ipp_t **attributes); + ipp_t **attributes);
+static int move_job(int jobid, const char *dest); +static int move_job(int jobid, const char *dest);
+static void sigterm_handler(int sig); +static void sigterm_handler(int sig);
+static const char *password_cb(const char *); +static const char *password_cb(const char *);
@ -117,13 +153,13 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+int +int
+main(int argc, char *argv[]) +main(int argc, char *argv[])
+{ +{
+ const char *selected_uri = NULL; /* URI of selected printer */ + const char *selected_uri = NULL; /* URI of selected printer */
+ const char *tmp_device_uri; /* Device URI to check */ + const char *tmp_device_uri; /* Device URI to check */
+ cups_array_t *printer_array; /* Array of available printers */ + cups_array_t *printer_array; /* Array of available printers */
+ int printer_count = 0; /* current printer array index */ + int printer_count = 0; /* current printer array index */
+ int retry_max = 1; /* maximum retries before exit */ + int retry_max = 1; /* maximum retries before exit */
+ int retry_count = 0; /* current retry number */ + int retry_count = 0; /* current retry number */
+ int auth_failed_count = 0; /* auth failures per loop */ + int auth_failed_count = 0; /* auth failures per loop */
+ int rc = CUPS_BACKEND_OK; + int rc = CUPS_BACKEND_OK;
+#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
+ struct sigaction action; /* Actions for POSIX signals */ + struct sigaction action; /* Actions for POSIX signals */
@ -145,9 +181,9 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ backendName = argv[0]; + backendName = argv[0];
+ +
+ _cupsLangPrintf(stderr,"network %s \"Unknown\" \"%s (%s)\"\n", + _cupsLangPrintf(stderr,"network %s \"Unknown\" \"%s (%s)\"\n",
+ backendName, + backendName,
+ _cupsLangString(cupsLangDefault(), _("Failover Printer")), + _cupsLangString(cupsLangDefault(), _("Failover Printer")),
+ backendName); + backendName);
+ +
+ return (CUPS_BACKEND_OK); + return (CUPS_BACKEND_OK);
+ } + }
@ -155,7 +191,7 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ { + {
+ _cupsLangPrintf(stderr, + _cupsLangPrintf(stderr,
+ _("Usage: %s job-id user title copies options [file]"), + _("Usage: %s job-id user title copies options [file]"),
+ argv[0]); + argv[0]);
+ return (CUPS_BACKEND_STOP); + return (CUPS_BACKEND_STOP);
+ } + }
+ +
@ -192,7 +228,7 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ * Read Configuration + * Read Configuration
+ */ + */
+ if ((rc = read_config(printer_array, &retry_max, + if ((rc = read_config(printer_array, &retry_max,
+ argv[5])) != CUPS_BACKEND_OK) + argv[5])) != CUPS_BACKEND_OK)
+ { + {
+ fprintf(stderr, "ERROR: Failed to read configuration options!\n"); + fprintf(stderr, "ERROR: Failed to read configuration options!\n");
+ goto cleanup; + goto cleanup;
@ -217,23 +253,23 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ { + {
+ if (job_canceled) + if (job_canceled)
+ { + {
+ fprintf(stderr, "DEBUG: Job Canceled\n"); + fprintf(stderr, "DEBUG: Job Canceled\n");
+ goto cleanup; + goto cleanup;
+ } + }
+ +
+ fprintf(stderr,"DEBUG: Checking printer #%d: %s\n", + fprintf(stderr,"DEBUG: Checking printer #%d: %s\n",
+ printer_count+1, tmp_device_uri); + printer_count+1, tmp_device_uri);
+ +
+ rc = check_printer(tmp_device_uri); + rc = check_printer(tmp_device_uri);
+ +
+ // Printer is available and not busy. + // Printer is available and not busy.
+ if ( rc == FO_PRINTER_GOOD ) + if ( rc == FO_PRINTER_GOOD )
+ { + {
+ selected_uri = tmp_device_uri; + selected_uri = tmp_device_uri;
+ break; + break;
+ } + }
+ // Printer is busy + // Printer is busy
+ else if ( rc == FO_PRINTER_BUSY ) + else if (rc == FO_PRINTER_BUSY)
+ { + {
+ fprintf(stderr, "DEBUG: Waiting for job to complete.\n"); + fprintf(stderr, "DEBUG: Waiting for job to complete.\n");
+ sleep(2); + sleep(2);
@ -242,8 +278,8 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ // Authorization is required to access the printer. + // Authorization is required to access the printer.
+ else if (rc == FO_AUTH_REQUIRED) + else if (rc == FO_AUTH_REQUIRED)
+ { + {
+ auth_failed_count++; + auth_failed_count++;
+ fprintf(stderr, "DEBUG: auth_failed_count = %d\n", auth_failed_count); + fprintf(stderr, "DEBUG: auth_failed_count = %d\n", auth_failed_count);
+ } + }
+ // Printer is stopped or not accepting jobs + // Printer is stopped or not accepting jobs
+ else + else
@ -275,7 +311,7 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ if (!selected_uri && auth_failed_count == printer_count) + if (!selected_uri && auth_failed_count == printer_count)
+ { + {
+ fprintf(stderr, "ERROR: All failover printers failed with " + fprintf(stderr, "ERROR: All failover printers failed with "
+ "authorization issues.\n"); + "authorization issues.\n");
+ rc = CUPS_BACKEND_AUTH_REQUIRED; + rc = CUPS_BACKEND_AUTH_REQUIRED;
+ fprintf(stderr, "ATTR: auth-info-required=%s\n", auth_info_required); + fprintf(stderr, "ATTR: auth-info-required=%s\n", auth_info_required);
+ goto cleanup; + goto cleanup;
@ -339,7 +375,7 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ if ( rc != CUPS_BACKEND_OK ) + if ( rc != CUPS_BACKEND_OK )
+ { + {
+ fprintf(stderr, "DEBUG: Failed to get attributes from printer: %s\n", + fprintf(stderr, "DEBUG: Failed to get attributes from printer: %s\n",
+ device_uri); + device_uri);
+ if ( rc == CUPS_BACKEND_AUTH_REQUIRED ) + if ( rc == CUPS_BACKEND_AUTH_REQUIRED )
+ return (FO_AUTH_REQUIRED); + return (FO_AUTH_REQUIRED);
+ else + else
@ -350,13 +386,13 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ * Check if printer is accepting jobs + * Check if printer is accepting jobs
+ */ + */
+ if ((tmp_attribute = ippFindAttribute(attributes, + if ((tmp_attribute = ippFindAttribute(attributes,
+ "printer-is-accepting-jobs", + "printer-is-accepting-jobs",
+ IPP_TAG_BOOLEAN)) != NULL && + IPP_TAG_BOOLEAN)) != NULL &&
+ !tmp_attribute->values[0].boolean) + !tmp_attribute->values[0].boolean)
+ { + {
+ fprintf(stderr, + fprintf(stderr,
+ "DEBUG: Printer, %s, is not accepting jobs.\n", + "DEBUG: Printer, %s, is not accepting jobs.\n",
+ device_uri); + device_uri);
+ +
+ rc = FO_PRINTER_BAD; + rc = FO_PRINTER_BAD;
+ } + }
@ -365,8 +401,8 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ * Check if printer is stopped or busy processing + * Check if printer is stopped or busy processing
+ */ + */
+ if ((tmp_attribute = ippFindAttribute(attributes, + if ((tmp_attribute = ippFindAttribute(attributes,
+ "printer-state", + "printer-state",
+ IPP_TAG_ENUM)) != NULL) + IPP_TAG_ENUM)) != NULL)
+ { + {
+ // Printer Stopped + // Printer Stopped
+ if ( tmp_attribute->values[0].integer == IPP_PRINTER_STOPPED ) + if ( tmp_attribute->values[0].integer == IPP_PRINTER_STOPPED )
@ -386,7 +422,7 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ * Parse through the printer-state-reasons + * Parse through the printer-state-reasons
+ */ + */
+ if ((tmp_attribute = ippFindAttribute(attributes, "printer-state-reasons", + if ((tmp_attribute = ippFindAttribute(attributes, "printer-state-reasons",
+ IPP_TAG_KEYWORD)) != NULL) + IPP_TAG_KEYWORD)) != NULL)
+ { + {
+ for (i = 0; i < tmp_attribute->num_values; i++) + for (i = 0; i < tmp_attribute->num_values; i++)
+ { + {
@ -395,13 +431,13 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ +
+ if (len > 8 && !strcmp(reason + len - 8, "-warning")) + if (len > 8 && !strcmp(reason + len - 8, "-warning"))
+ { + {
+ fprintf(stderr, "DEBUG: Printer Supply Warning, %s\n", reason); + fprintf(stderr, "DEBUG: Printer Supply Warning, %s\n", reason);
+ rc = FO_PRINTER_BAD; + rc = FO_PRINTER_BAD;
+ } + }
+ else if (len > 6 && !strcmp(reason + len - 6, "-error")) + else if (len > 6 && !strcmp(reason + len - 6, "-error"))
+ { + {
+ fprintf(stderr, "DEBUG: Printer Supply Error, %s\n", reason); + fprintf(stderr, "DEBUG: Printer Supply Error, %s\n", reason);
+ rc = FO_PRINTER_BAD; + rc = FO_PRINTER_BAD;
+ } + }
+ } + }
+ } + }
@ -420,7 +456,7 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ const char *tmp; /* temporary ptr */ + const char *tmp; /* temporary ptr */
+ char *tok_tmp; /* temporary ptr for option parsing */ + char *tok_tmp; /* temporary ptr for option parsing */
+ int jobopts_count = 0; /* number of options */ + int jobopts_count = 0; /* number of options */
+ cups_option_t *jobopts = NULL; /* job options */ + cups_option_t *jobopts = NULL; /* job options */
+ +
+ +
+ fprintf(stderr, "DEBUG: Reading Configuration.\n"); + fprintf(stderr, "DEBUG: Reading Configuration.\n");
@ -429,7 +465,7 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ if (!jobopts_count) + if (!jobopts_count)
+ { + {
+ fprintf(stderr, + fprintf(stderr,
+ "ERROR: No job options! Cannot find failover options!\n"); + "ERROR: No job options! Cannot find failover options!\n");
+ return (CUPS_BACKEND_STOP); + return (CUPS_BACKEND_STOP);
+ } + }
+ +
@ -467,7 +503,7 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ fprintf(stderr, "DEBUG: Searching for failover-retries option.\n"); + fprintf(stderr, "DEBUG: Searching for failover-retries option.\n");
+ +
+ if ((tmp = cupsGetOption("failover-retries", + if ((tmp = cupsGetOption("failover-retries",
+ jobopts_count, jobopts)) != NULL) + jobopts_count, jobopts)) != NULL)
+ { + {
+ fprintf(stderr, "DEBUG: failover-retries option contents: %s.\n", tmp); + fprintf(stderr, "DEBUG: failover-retries option contents: %s.\n", tmp);
+ *retries = atoi(tmp); + *retries = atoi(tmp);
@ -489,21 +525,21 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+int +int
+get_printer_attributes(const char *device_uri, ipp_t **attributes) +get_printer_attributes(const char *device_uri, ipp_t **attributes)
+{ +{
+ char uri[HTTP_MAX_URI]; /* Updated URI without login */ + char uri[HTTP_MAX_URI]; /* Updated URI without login */
+ int version; /* IPP version */ + int version; /* IPP version */
+ char scheme[256]; /* Scheme in URI */ + char scheme[256]; /* Scheme in URI */
+ ipp_status_t ipp_status; /* Status of IPP request */ + ipp_status_t ipp_status; /* Status of IPP request */
+ char hostname[1024]; /* Hostname */ + char hostname[1024]; /* Hostname */
+ char resource[1024]; /* Resource infoo */ + char resource[1024]; /* Resource infoo */
+ char addrname[256]; /* Address name */ + char addrname[256]; /* Address name */
+ int port; /* IPP Port number */ + int port; /* IPP Port number */
+ char portname[255]; /* Port as string */ + char portname[255]; /* Port as string */
+ http_t *http; /* HTTP connection */ + http_t *http; /* HTTP connection */
+ ipp_t *request; /* IPP request */ + ipp_t *request; /* IPP request */
+ int rc = CUPS_BACKEND_OK; /* Return Code */ + int rc = CUPS_BACKEND_OK; /* Return Code */
+ char username[256]; /* Username for device URI */ + char username[256]; /* Username for device URI */
+ char *option_ptr; /* for parsing resource opts */ + char *option_ptr; /* for parsing resource opts */
+ const char * const pattrs[] = /* Printer attributes wanted */ + const char * const pattrs[] = /* Printer attributes wanted */
+ { + {
+ "printer-is-accepting-jobs", + "printer-is-accepting-jobs",
+ "printer-state", + "printer-state",
@ -520,8 +556,8 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ * Parse device_uri + * Parse device_uri
+ */ + */
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme), + if (httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme),
+ username, sizeof(username), hostname, sizeof(hostname), + username, sizeof(username), hostname, sizeof(hostname),
+ &port, resource, sizeof(resource)) != HTTP_URI_OK) + &port, resource, sizeof(resource)) != HTTP_URI_OK)
+ { + {
+ fprintf(stderr, "ERROR: Problem parsing device_uri, %s\n", device_uri); + fprintf(stderr, "ERROR: Problem parsing device_uri, %s\n", device_uri);
+ return (CUPS_BACKEND_STOP); + return (CUPS_BACKEND_STOP);
@ -581,23 +617,23 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ */ + */
+ if (!http) + if (!http)
+ { + {
+ int error = errno; /* Connection error */ + int error = errno; /* Connection error */
+ +
+ switch (error) + switch (error)
+ { + {
+ case EHOSTDOWN : + case EHOSTDOWN :
+ _cupsLangPuts(stderr, _("WARNING: " + _cupsLangPuts(stderr, _("WARNING: "
+ "The printer may not exist or " + "The printer may not exist or "
+ "is unavailable at this time.\n")); + "is unavailable at this time.\n"));
+ break; + break;
+ case EHOSTUNREACH : + case EHOSTUNREACH :
+ _cupsLangPuts(stderr, _("WARNING: " + _cupsLangPuts(stderr, _("WARNING: "
+ "The printer is unreachable at this " + "The printer is unreachable at this "
+ "time.\n")); + "time.\n"));
+ break; + break;
+ case ECONNREFUSED : + case ECONNREFUSED :
+ _cupsLangPuts(stderr, _("WARNING: " + _cupsLangPuts(stderr, _("WARNING: "
+ "Connection Refused.\n")); + "Connection Refused.\n"));
+ break; + break;
+ default : + default :
+ fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(errno)); + fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(errno));
@ -613,14 +649,14 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+#ifdef AF_INET6 +#ifdef AF_INET6
+ if (http->hostaddr->addr.sa_family == AF_INET6) + if (http->hostaddr->addr.sa_family == AF_INET6)
+ fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6)...\n", + fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6)...\n",
+ httpAddrString(http->hostaddr, addrname, sizeof(addrname)), + httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
+ ntohs(http->hostaddr->ipv6.sin6_port)); + ntohs(http->hostaddr->ipv6.sin6_port));
+ else + else
+#endif /* AF_INET6 */ +#endif /* AF_INET6 */
+ if (http->hostaddr->addr.sa_family == AF_INET) + if (http->hostaddr->addr.sa_family == AF_INET)
+ fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4)...\n", + fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4)...\n",
+ httpAddrString(http->hostaddr, addrname, sizeof(addrname)), + httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
+ ntohs(http->hostaddr->ipv4.sin_port)); + ntohs(http->hostaddr->ipv4.sin_port));
+ +
+ /* + /*
+ * Search the resource string for options. + * Search the resource string for options.
@ -642,10 +678,10 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ version_str = option_ptr; + version_str = option_ptr;
+ +
+ while (*option_ptr && *option_ptr != '&' && *option_ptr != '+') + while (*option_ptr && *option_ptr != '&' && *option_ptr != '+')
+ option_ptr++; + option_ptr++;
+ +
+ if (*option_ptr) + if (*option_ptr)
+ *option_ptr = '\0'; + *option_ptr = '\0';
+ +
+ sscanf(version_str, "%d.%d", &major, &minor); + sscanf(version_str, "%d.%d", &major, &minor);
+ +
@ -657,16 +693,16 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ case 11 : + case 11 :
+ case 20 : + case 20 :
+ case 21 : + case 21 :
+ fprintf(stderr, + fprintf(stderr,
+ "DEBUG: Set version to %d from URI\n", + "DEBUG: Set version to %d from URI\n",
+ version); + version);
+ break; + break;
+ default : + default :
+ _cupsLangPrintf(stderr, + _cupsLangPrintf(stderr,
+ _("DEBUG: Invalid version, %d, from URI. " + _("DEBUG: Invalid version, %d, from URI. "
+ "Using default of 1.1 \n"), + "Using default of 1.1 \n"),
+ version); + version);
+ version = 11; + version = 11;
+ } + }
+ } + }
+ } + }
@ -677,10 +713,10 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ * because it might contain username:password information... + * because it might contain username:password information...
+ */ + */
+ if (httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), scheme, NULL, + if (httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), scheme, NULL,
+ hostname, port, resource) != HTTP_URI_OK) + hostname, port, resource) != HTTP_URI_OK)
+ { + {
+ fprintf(stderr, "ERROR: Problem assembling printer URI from host %s, " + fprintf(stderr, "ERROR: Problem assembling printer URI from host %s, "
+ "port %d, resource %s\n", hostname, port, resource); + "port %d, resource %s\n", hostname, port, resource);
+ return (CUPS_BACKEND_STOP); + return (CUPS_BACKEND_STOP);
+ } + }
+ +
@ -692,11 +728,11 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ request->request.op.version[1] = version % 10; + request->request.op.version[1] = version % 10;
+ +
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
+ NULL, uri); + NULL, uri);
+ +
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, + ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]), + "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
+ NULL, pattrs); + NULL, pattrs);
+ +
+ /* + /*
+ * Do the request... + * Do the request...
@ -709,12 +745,12 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ ipp_status = cupsLastError(); + ipp_status = cupsLastError();
+ +
+ fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n", + fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n",
+ ippErrorString(ipp_status), cupsLastErrorString()); + ippErrorString(ipp_status), cupsLastErrorString());
+ +
+ if (ipp_status > IPP_OK_CONFLICT) + if (ipp_status > IPP_OK_CONFLICT)
+ { + {
+ fprintf(stderr, "DEBUG: Get-Printer-Attributes returned %s.\n", + fprintf(stderr, "DEBUG: Get-Printer-Attributes returned %s.\n",
+ ippErrorString(ipp_status)); + ippErrorString(ipp_status));
+ switch(ipp_status) + switch(ipp_status)
+ { + {
+ case IPP_FORBIDDEN : + case IPP_FORBIDDEN :
@ -725,17 +761,17 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ case IPP_PRINTER_BUSY : + case IPP_PRINTER_BUSY :
+ case IPP_SERVICE_UNAVAILABLE : + case IPP_SERVICE_UNAVAILABLE :
+ _cupsLangPuts(stderr, _("ERROR: " + _cupsLangPuts(stderr, _("ERROR: "
+ "The printer is not responding.\n")); + "The printer is not responding.\n"));
+ rc = CUPS_BACKEND_FAILED; + rc = CUPS_BACKEND_FAILED;
+ break; + break;
+ case IPP_BAD_REQUEST : + case IPP_BAD_REQUEST :
+ case IPP_VERSION_NOT_SUPPORTED : + case IPP_VERSION_NOT_SUPPORTED :
+ fprintf(stderr, "ERROR: Destination does not support IPP version %d\n", + fprintf(stderr, "ERROR: Destination does not support IPP version %d\n",
+ version); + version);
+ case IPP_NOT_FOUND : + case IPP_NOT_FOUND :
+ _cupsLangPuts(stderr, _("ERROR: " + _cupsLangPuts(stderr, _("ERROR: "
+ "The printer configuration is incorrect or the " + "The printer configuration is incorrect or the "
+ "printer no longer exists.\n")); + "printer no longer exists.\n"));
+ rc = CUPS_BACKEND_STOP; + rc = CUPS_BACKEND_STOP;
+ break; + break;
+ default : + default :
@ -828,8 +864,8 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+/* +/*
+ * 'password_cb()' - Disable the password prompt for cupsDoFileRequest(). + * 'password_cb()' - Disable the password prompt for cupsDoFileRequest().
+ */ + */
+static const char * /* O - Password */ +static const char * /* O - Password */
+password_cb(const char *prompt) /* I - Prompt (not used) */ +password_cb(const char *prompt) /* I - Prompt (not used) */
+{ +{
+ auth_info_required = "username,password"; + auth_info_required = "username,password";
+ password_retries++; + password_retries++;
@ -839,36 +875,3 @@ diff -up cups-2.3.0/backend/failover.c.failover cups-2.3.0/backend/failover.c
+ else + else
+ return (NULL); + return (NULL);
+} +}
diff -up cups-2.3.0/backend/Makefile.failover cups-2.3.0/backend/Makefile
--- cups-2.3.0/backend/Makefile.failover 2019-10-07 12:22:17.067627388 +0200
+++ cups-2.3.0/backend/Makefile 2019-10-07 12:24:17.046780985 +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 \
@@ -274,6 +276,13 @@ lpd: lpd.o ../cups/$(LIBCUPS) libbackend
$(LD_CC) $(ALL_LDFLAGS) -o lpd lpd.o libbackend.a $(LINKCUPS)
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+#
+# failover
+#
+
+failover: failover.o ../cups/$(LIBCUPS) libbackend.a
+ echo Linking $@...
+ $(LD_CC) $(ALL_LDFLAGS) -o failover failover.o libbackend.a $(LINKCUPS)
#
# snmp

View File

@ -15,7 +15,7 @@ Summary: CUPS printing system
Name: cups Name: cups
Epoch: 1 Epoch: 1
Version: 2.3.3 Version: 2.3.3
Release: 3%{?dist} Release: 4%{?dist}
License: ASL 2.0 with exceptions for GPL2/LGPL2 License: ASL 2.0 with exceptions for GPL2/LGPL2
Url: http://www.cups.org/ Url: http://www.cups.org/
Source0: https://github.com/apple/cups/releases/download/v%{VERSION}/cups-%{VERSION}-source.tar.gz Source0: https://github.com/apple/cups/releases/download/v%{VERSION}/cups-%{VERSION}-source.tar.gz
@ -747,6 +747,9 @@ rm -f %{cups_serverbin}/backend/smb
%{_mandir}/man7/ippevepcl.7.gz %{_mandir}/man7/ippevepcl.7.gz
%changelog %changelog
* Fri May 22 2020 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.3.3-4
- fix space errors in failover patch
* Thu May 21 2020 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.3.3-3 * Thu May 21 2020 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.3.3-3
- use _rundir instead of hardcode /run - use _rundir instead of hardcode /run