- Documentation fixes (STR #3542, STR #3650)
- Localization fixes (STR #3635, STR #3636, STR #3647, STR #3666)
+ - The CUPS API incorrectly mapped the HTTP_UNAUTHORIZED status to the
+ IPP_NOT_AUTHORIZED status code, when IPP_NOT_AUTHENTICATED would be
+ the correct mapping (STR #3684)
- The scheduler would restart jobs while shutting down (STR #3679)
- Fixed a PPD loader bug that could cause a crash in cupsd (STR #3680)
- Improved the mapping of non-standard PPD and PWG names (STR #3671)
*
* Contents:
*
-* list_devices() - List all USB devices.
-* print_device() - Print a file to a USB device.
-* sidechannel_thread() - Thread to handle side-channel requests.
-* read_thread() - Thread to read the backchannel data on.
-* list_device_cb() - list_device iterator callback.
-* find_device_cb() - print_device iterator callback.
-* status_timer_cb() - Status timer callback.
-* iterate_printers() - Iterate over all the printers.
-* device_added() - Device added notifier.
-* copy_deviceinfo() - Copy strings from the 1284 device ID.
-* release_deviceinfo() - Release deviceinfo strings.
-* load_classdriver() - Load a classdriver.
-* unload_classdriver() - Unload a classdriver.
-* load_printerdriver() - Load vendor's classdriver.
-* registry_open() - Open a connection to the printer.
-* registry_close() - Close the connection to the printer.
-* copy_deviceid() - Copy the 1284 device id string.
-* copy_devicestring() - Copy the 1284 device id string.
-* copy_value_for_key() - Copy value string associated with a key.
-* cfstr_create_trim() - Create CFString and trim whitespace characters.
-* parse_options() - Parse uri options.
-* setup_cfLanguage() - Create AppleLanguages array from LANG environment var.
-* run_legacy_backend() - Re-exec backend as ppc or i386.
-* sigterm_handler() - SIGTERM handler.
-* next_line() - Find the next line in a buffer.
-* parse_pserror() - Scan the backchannel data for postscript errors.
-* get_device_id() - Return IEEE-1284 device ID.
+ * list_devices() - List all USB devices.
+ * print_device() - Print a file to a USB device.
+ * read_thread() - Thread to read the backchannel data on.
+ * sidechannel_thread() - Handle side-channel requests.
+ * iterate_printers() - Iterate over all the printers.
+ * device_added() - Device added notifier.
+ * list_device_cb() - list_device iterator callback.
+ * find_device_cb() - print_device iterator callback.
+ * status_timer_cb() - Status timer callback.
+ * copy_deviceinfo() - Copy strings from the 1284 device ID.
+ * release_deviceinfo() - Release deviceinfo strings.
+ * load_classdriver() - Load a classdriver.
+ * unload_classdriver() - Unload a classdriver.
+ * load_printerdriver() - Load vendor's classdriver.
+ * registry_open() - Open a connection to the printer.
+ * registry_close() - Close the connection to the printer.
+ * copy_deviceid() - Copy the 1284 device id string.
+ * copy_devicestring() - Copy the 1284 device id string.
+ * copy_value_for_key() - Copy value string associated with a key.
+ * cfstr_create_trim() - Create CFString and trim whitespace characters.
+ * parse_options() - Parse URI options.
+ * sigterm_handler() - SIGTERM handler.
+ * next_line() - Find the next line in a buffer.
+ * parse_pserror() - Scan the backchannel data for postscript errors.
+ * soft_reset() - Send a soft reset to the device.
+ * get_device_id() - Return IEEE-1284 device ID.
*/
/*
#if defined(__i386__) || defined(__x86_64__)
static pid_t child_pid; /* Child PID */
static void run_legacy_backend(int argc, char *argv[], int fd); /* Starts child backend process running as a ppc executable */
-static void sigterm_handler(int sig); /* SIGTERM handler */
#endif /* __i386__ || __x86_64__ */
+static void sigterm_handler(int sig); /* SIGTERM handler */
#ifdef PARSE_PS_ERRORS
static const char *next_line (const char *buffer);
memset(&action, 0, sizeof(action));
sigemptyset(&action.sa_mask);
- action.sa_handler = SIG_DFL;
+ sigaddset(&action.sa_mask, SIGTERM);
+ action.sa_handler = sigterm_handler;
sigaction(SIGTERM, &action, NULL);
}
* Force the side-channel thread to exit...
*/
+ fputs("DEBUG: Force the side-channel thread to exit...\n", stderr);
pthread_kill(sidechannel_thread_id, SIGTERM);
}
}
*/
g.wait_eof = 0;
+ fputs("DEBUG: Force the read thread to exit...\n", stderr);
pthread_kill(read_thread_id, SIGTERM);
}
}
exit(exitstatus);
}
+#endif /* __i386__ || __x86_64__ */
+
/*
* 'sigterm_handler()' - SIGTERM handler.
static void
sigterm_handler(int sig) /* I - Signal */
{
- /* If we started a child process pass the signal on to it...
- */
+#if defined(__i386__) || defined(__x86_64__)
+ /*
+ * If we started a child process pass the signal on to it...
+ */
+
if (child_pid)
{
/*
exit(CUPS_BACKEND_STOP);
}
}
-}
-
#endif /* __i386__ || __x86_64__ */
+}
#ifdef PARSE_PS_ERRORS
DNSServiceRef ref, /* DNS-SD master service reference */
domainref, /* DNS-SD service reference for domain */
localref; /* DNS-SD service reference for .local */
- int domainsent = 0; /* Send the domain resolve? */
+ int domainsent = 0, /* Send the domain resolve? */
+ offline = 0; /* offline-report state set? */
char *regtype, /* Pointer to type in hostname */
*domain; /* Pointer to domain in hostname */
_http_uribuf_t uribuf; /* URI buffer */
&uribuf) == kDNSServiceErr_NoError)
domainsent = 1;
}
+
+ /*
+ * If it hasn't resolved within 5 seconds set the offline-report
+ * printer-state-reason...
+ */
+
+ if (logit && offline == 0 && time(NULL) > (start_time + 5))
+ {
+ fputs("STATE: +offline-report\n", stderr);
+ offline = 1;
+ }
}
else
{
else
fputs("DEBUG: Unable to resolve URI\n", stderr);
- fputs("STATE: -connecting-to-device\n", stderr);
+ fputs("STATE: -connecting-to-device,offline-report\n", stderr);
}
#else
return (ipp_status_400s[error - IPP_BAD_REQUEST]);
else if (error >= IPP_INTERNAL_ERROR && error <= IPP_PRINTER_IS_DEACTIVATED)
return (ipp_status_500s[error - IPP_INTERNAL_ERROR]);
- else if (error >= IPP_AUTHORIZATION_CANCELED && error <= IPP_UPGRADE_REQUIRED)
- return (ipp_status_1000s[error - IPP_AUTHORIZATION_CANCELED]);
+ else if (error >= IPP_AUTHENTICATION_CANCELED && error <= IPP_UPGRADE_REQUIRED)
+ return (ipp_status_1000s[error - IPP_AUTHENTICATION_CANCELED]);
/*
* No, build an "unknown-xxxx" error string...
IPP_MULTIPLE_JOBS_NOT_SUPPORTED, /* server-error-multiple-document-jobs-not-supported */
IPP_PRINTER_IS_DEACTIVATED, /* server-error-printer-is-deactivated */
- IPP_AUTHORIZATION_CANCELED = 0x1000, /* Authorization canceled by user @since CUPS 1.4@ */
+ IPP_AUTHENTICATION_CANCELED = 0x1000, /* Authentication canceled by user @since CUPS 1.5@ */
IPP_PKI_ERROR, /* Error negotiating a secure connection @since CUPS 1.5@ */
IPP_UPGRADE_REQUIRED /* TLS upgrade required */
} ipp_status_t;
}
else
{
-
/*
* Not a standard name; convert it to a PWG vendor name of the form:
*
new_right = _PWG_FROMPTS(ppd_size->width - ppd_size->right);
new_top = _PWG_FROMPTS(ppd_size->length - ppd_size->top);
new_imageable = new_length - new_top - new_bottom;
- new_borderless = new_bottom == 0 && new_top == 0 &&
- new_left == 0 && new_right == 0;
+ new_borderless = (new_bottom == 0 && new_top == 0) ||
+ (new_left == 0 && new_right == 0);
for (k = pwg->num_sizes, similar = 0, old_size = pwg->sizes, new_size = NULL;
k > 0 && !similar;
const char *ppd_name; /* PPD media name */
+ DEBUG_printf(("_pwgGetPageSize(pwg=%p, job=%p, keyword=\"%s\", exact=%p)",
+ pwg, job, keyword, exact));
+
/*
* Range check input...
*/
if ((attr = ippFindAttribute(job, "PageRegion", IPP_TAG_ZERO)) == NULL)
attr = ippFindAttribute(job, "media", IPP_TAG_ZERO);
+#ifdef DEBUG
+ if (attr)
+ DEBUG_printf(("1_pwgGetPageSize: Found attribute %s (%s)", attr->name,
+ ippTagString(attr->value_tag)));
+ else
+ DEBUG_puts("1_pwgGetPageSize: Did not find media attribute.");
+#endif /* DEBUG */
+
if (attr && (attr->value_tag == IPP_TAG_NAME ||
attr->value_tag == IPP_TAG_KEYWORD))
ppd_name = attr->values[0].string.text;
}
+ DEBUG_printf(("1_pwgGetPageSize: ppd_name=\"%s\"", ppd_name));
+
if (ppd_name)
{
/*
*/
for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++)
+ {
+ DEBUG_printf(("2_pwgGetPageSize: size[%d]=[\"%s\" \"%s\"]",
+ (int)(size - pwg->sizes), size->map.pwg, size->map.ppd));
+
if (!strcasecmp(ppd_name, size->map.ppd))
+ {
+ if (exact)
+ *exact = 1;
+
+ DEBUG_printf(("1_pwgGetPageSize: Returning \"%s\"", ppd_name));
+
return (ppd_name);
+ }
+ }
}
if (job && !keyword)
if (exact)
*exact = 1;
+ DEBUG_printf(("1_pwgGetPageSize: Returning \"%s\"", size->map.ppd));
+
return (size->map.ppd);
}
if (closest)
+ {
+ DEBUG_printf(("1_pwgGetPageSize: Returning \"%s\" (closest)",
+ closest->map.ppd));
+
return (closest->map.ppd);
+ }
/*
* If we get here we need to check for custom page size support...
else if (exact)
*exact = 1;
+ DEBUG_printf(("1_pwgGetPageSize: Returning \"%s\" (custom)",
+ pwg->custom_ppd_size));
+
return (pwg->custom_ppd_size);
}
* No custom page size support or the size is out of range - return NULL.
*/
+ DEBUG_puts("1_pwgGetPageSize: Returning NULL");
+
return (NULL);
}
break;
case HTTP_UNAUTHORIZED :
- _cupsSetError(IPP_NOT_AUTHORIZED, httpStatus(status), 0);
+ _cupsSetError(IPP_NOT_AUTHENTICATED, httpStatus(status), 0);
break;
case HTTP_AUTHORIZATION_CANCELED :
- _cupsSetError(IPP_AUTHORIZATION_CANCELED, httpStatus(status), 0);
+ _cupsSetError(IPP_AUTHENTICATION_CANCELED, httpStatus(status), 0);
break;
case HTTP_FORBIDDEN :
*PageSize Letter/US Letter: "PageSize=Letter"
*fr.PageSize Letter/French US Letter: ""
*fr_CA.PageSize Letter/French Canadian US Letter: ""
+*PageSize Letter.Banner/US Letter Banner: "PageSize=Letter.Banner"
+*fr.PageSize Letter.Banner/French US Letter Banner: ""
+*fr_CA.PageSize Letter.Banner/French Canadian US Letter Banner: ""
*PageSize Letter.Fullbleed/US Letter Borderless: "PageSize=Letter.Fullbleed"
*fr.PageSize Letter.Fullbleed/French US Letter Borderless: ""
*fr_CA.PageSize Letter.Fullbleed/French Canadian US Letter Borderless: ""
*OrderDependency: 10 AnySetup *PageRegion
*DefaultPageRegion: Letter
*PageRegion Letter/US Letter: "PageRegion=Letter"
+*PageRegion Letter.Banner/US Letter Banner: "PageRegion=Letter.Fullbleed"
*PageRegion Letter.Fullbleed/US Letter Borderless: "PageRegion=Letter.Fullbleed"
*PageRegion A4/A4: "PageRegion=A4"
*PageRegion Env10/#10 Envelope: "PageRegion=Env10"
*fr.Translation PageRegion/French Page Region: ""
*fr.PageRegion Letter/French US Letter: ""
+*fr.PageRegion Letter.Banner/French US Letter Banner: ""
*fr.PageRegion Letter.Fullbleed/French US Letter Borderless: ""
*fr.PageRegion A4/French A4: ""
*fr.PageRegion Env10/French #10 Envelope: ""
*fr_CA.Translation PageRegion/French Canadian Page Region: ""
*fr_CA.PageRegion Letter/French Canadian US Letter: ""
+*fr_CA.PageRegion Letter.Banner/French Canadian US Letter Banner: ""
*fr_CA.PageRegion Letter.Fullbleed/French Canadian US Letter Borderless: ""
*fr_CA.PageRegion A4/French Canadian A4: ""
*fr_CA.PageRegion Env10/French Canadian #10 Envelope: ""
*DefaultImageableArea: Letter
*ImageableArea Letter: "18 36 594 756"
+*ImageableArea Letter.Banner: "18 0 594 792"
*ImageableArea Letter.Fullbleed: "0 0 612 792"
*ImageableArea A4: "18 36 577 806"
*ImageableArea Env10: "18 36 279 648"
*DefaultPaperDimension: Letter
*PaperDimension Letter: "612 792"
+*PaperDimension Letter.Banner: "612 792"
*PaperDimension Letter.Fullbleed: "612 792"
*PaperDimension A4: "595 842"
*PaperDimension Env10: "297 684"
*
* Contents:
*
- * main() - Main entry.
- * test_pwg() - Test the PWG mapping functions.
+ * main() - Main entry.
+ * test_pagesize() - Test the PWG mapping functions.
+ * test_pwg() - Test the PWG mapping functions.
*/
/*
*/
#include "ppd-private.h"
+#include "file-private.h"
/*
* Local functions...
*/
-static int test_pwg(_pwg_t *pwg);
+static int test_pwg(_pwg_t *pwg, ppd_file_t *ppd);
+static int test_pagesize(_pwg_t *pwg, ppd_file_t *ppd,
+ const char *ppdsize);
/*
status = 0;
- if (argc != 2)
+ if (argc < 2 || argc > 3)
{
- puts("Usage: ./testpwg filename.ppd");
+ puts("Usage: ./testpwg filename.ppd [jobfile]");
return (1);
}
- else
- ppdfile = argv[1];
+
+ ppdfile = argv[1];
printf("ppdOpenFile(%s): ", ppdfile);
if ((ppd = ppdOpenFile(ppdfile)) == NULL)
else
{
puts("PASS");
- status += test_pwg(pwg);
+ status += test_pwg(pwg, ppd);
+
+ if (argc == 3)
+ {
+ /*
+ * Test PageSize mapping code.
+ */
+
+ int fd; /* Job file descriptor */
+ const char *pagesize; /* PageSize value */
+ ipp_t *job; /* Job attributes */
+ ipp_attribute_t *media; /* Media attribute */
+
+ if ((fd = open(argv[2], O_RDONLY)) >= 0)
+ {
+ job = ippNew();
+ ippReadFile(fd, job);
+ close(fd);
+
+ if ((media = ippFindAttribute(job, "media", IPP_TAG_ZERO)) != NULL &&
+ media->value_tag != IPP_TAG_NAME &&
+ media->value_tag != IPP_TAG_KEYWORD)
+ media = NULL;
+
+ if (media)
+ printf("_pwgGetPageSize(media=%s): ", media->values[0].string.text);
+ else
+ fputs("_pwgGetPageSize(media-col): ", stdout);
+
+ fflush(stdout);
+
+ if ((pagesize = _pwgGetPageSize(pwg, job, NULL, NULL)) == NULL)
+ {
+ puts("FAIL (Not Found)");
+ status = 1;
+ }
+ else if (media && strcasecmp(pagesize, media->values[0].string.text))
+ {
+ printf("FAIL (Got \"%s\", Expected \"%s\")\n", pagesize,
+ media->values[0].string.text);
+ status = 1;
+ }
+ else
+ printf("PASS (%s)\n", pagesize);
+
+ ippDelete(job);
+ }
+ else
+ {
+ perror(argv[2]);
+ status = 1;
+ }
+ }
/*
* _pwgDestroy should never fail...
}
+/*
+ * 'test_pagesize()' - Test the PWG mapping functions.
+ */
+
+static int /* O - 1 on failure, 0 on success */
+test_pagesize(_pwg_t *pwg, /* I - PWG mapping data */
+ ppd_file_t *ppd, /* I - PPD file */
+ const char *ppdsize) /* I - PPD page size */
+{
+ int status = 0; /* Return status */
+ ipp_t *job; /* Job attributes */
+ const char *pagesize; /* PageSize value */
+
+
+ if (ppdPageSize(ppd, ppdsize))
+ {
+ printf("_pwgGetPageSize(keyword=%s): ", ppdsize);
+ fflush(stdout);
+
+ if ((pagesize = _pwgGetPageSize(pwg, NULL, ppdsize, NULL)) == NULL)
+ {
+ puts("FAIL (Not Found)");
+ status = 1;
+ }
+ else if (strcasecmp(pagesize, ppdsize))
+ {
+ printf("FAIL (Got \"%s\", Expected \"%s\")\n", pagesize, ppdsize);
+ status = 1;
+ }
+ else
+ puts("PASS");
+
+ job = ippNew();
+ ippAddString(job, IPP_TAG_JOB, IPP_TAG_KEYWORD, "media", NULL, ppdsize);
+
+ printf("_pwgGetPageSize(media=%s): ", ppdsize);
+ fflush(stdout);
+
+ if ((pagesize = _pwgGetPageSize(pwg, job, NULL, NULL)) == NULL)
+ {
+ puts("FAIL (Not Found)");
+ status = 1;
+ }
+ else if (strcasecmp(pagesize, ppdsize))
+ {
+ printf("FAIL (Got \"%s\", Expected \"%s\")\n", pagesize, ppdsize);
+ status = 1;
+ }
+ else
+ puts("PASS");
+
+ ippDelete(job);
+ }
+
+ return (status);
+}
+
+
/*
* 'test_pwg()' - Test the PWG mapping functions.
*/
static int /* O - 1 on failure, 0 on success */
-test_pwg(_pwg_t *pwg) /* I - PWG mapping data */
+test_pwg(_pwg_t *pwg, /* I - PWG mapping data */
+ ppd_file_t *ppd) /* I - PPD file */
{
int i, /* Looping var */
status = 0; /* Return status */
if (!status)
puts("PASS");
+
+ _pwgDestroy(pwg2);
}
+ /*
+ * Test PageSize mapping code...
+ */
+
+ status += test_pagesize(pwg, ppd, "Letter");
+ status += test_pagesize(pwg, ppd, "na-letter");
+ status += test_pagesize(pwg, ppd, "A4");
+ status += test_pagesize(pwg, ppd, "iso-a4");
+
return (status);
}
* 'check_quotas()' - Check quotas for a printer and user.
*/
-static int /* O - 1 if OK, 0 if not */
+static int /* O - 1 if OK, 0 if forbidden,
+ -1 if limit reached */
check_quotas(cupsd_client_t *con, /* I - Client connection */
cupsd_printer_t *p) /* I - Printer or class */
{
{
cupsdLogMessage(CUPSD_LOG_INFO, "Too many jobs for printer \"%s\"...",
p->name);
- return (0);
+ return (-1);
}
}
{
cupsdLogMessage(CUPSD_LOG_INFO, "Too many jobs for user \"%s\"...",
username);
- return (0);
+ return (-1);
}
}