From ba55dc12de9ef3103d220a332ad7d26c54e397fa Mon Sep 17 00:00:00 2001 From: msweet Date: Thu, 11 Mar 2010 06:44:46 +0000 Subject: [PATCH] Merge changes from CUPS 1.5svn-r9037. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1968 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.4.txt | 13 +++ CHANGES.txt | 6 +- cups/adminutil.c | 67 +++++---------- cups/adminutil.h | 8 +- cups/dest.c | 2 +- cups/getdevices.c | 56 ++----------- cups/ipp.c | 65 ++++++++------ cups/libcups_s.exp | 2 - cups/mark.c | 89 ++++++++++++++++---- cups/request.c | 38 +++++---- cups/util.c | 36 ++------ filter/pstops.c | 83 +++++++++++++----- man/cupsfilter.man | 13 ++- scheduler/conf.c | 7 -- scheduler/conf.h | 7 +- scheduler/cupsd.h | 12 +-- scheduler/cupsfilter.c | 10 +++ scheduler/ipp.c | 64 +------------- scheduler/job.c | 48 +++++------ scheduler/log.c | 7 +- scheduler/main.c | 136 +++++++++++++++--------------- scheduler/network.c | 4 + scheduler/policy.c | 14 ++++ scheduler/printers.c | 110 ++++++++++++++++++------ scheduler/quotas.c | 15 +--- systemv/cupstestppd.c | 186 +---------------------------------------- test/run-stp-tests.sh | 12 +++ 27 files changed, 479 insertions(+), 631 deletions(-) diff --git a/CHANGES-1.4.txt b/CHANGES-1.4.txt index c3cb9dbe8..3bd701b81 100644 --- a/CHANGES-1.4.txt +++ b/CHANGES-1.4.txt @@ -4,6 +4,19 @@ CHANGES-1.4.txt CHANGES IN CUPS V1.4.4 - Documentation updates (STR #3453) + - The PostScript filter did not support all media selection options for + the first page (STR #3525) + - The scheduler did not always remove job control files (STR #3425) + - The scheduler could crash on restart if classes were defined + (STR #3524) + - The scheduler no longer looks up network interface hostnames by + default on Mac OS X (STR #3523) + - ippWriteIO did not write collection (member) attributes properly in + all cases (STR #3521) + - The "cupsctl --remote-any" and corresponding web interface check box + (allow printing from the Internet) did not work reliably (STR #3520) + - The lpq and lpr commands would sometimes choose different default + printers (STR #3503) - cupsDo*Request did not flush error text, leading to multiple issues (STR #3325, STR #3519) - cupsDoAuthentication did not cancel password authentication after 3 diff --git a/CHANGES.txt b/CHANGES.txt index b24755b86..01ec3535f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,12 @@ -CHANGES.txt - 2010-03-02 +CHANGES.txt - 2010-03-09 ------------------------ CHANGES IN CUPS V1.5b1 + - The scheduler and CUPS API now support the print-quality job template + attribute. + - The scheduler no longer supports the old Mac OS X Server quota + plugin. - The scheduler now allows writing to /Users/Shared from print filters on Mac OS X. - CUPS no longer supports the old ~/.cupsrc or ~/.lpoptions files from diff --git a/cups/adminutil.c b/cups/adminutil.c index 29d3b6728..4db5247ec 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -4,7 +4,7 @@ * Administration utility API definitions for the Common UNIX Printing * System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 2001-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -862,25 +862,6 @@ cupsAdminGetServerSettings( http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ int *num_settings, /* O - Number of settings */ cups_option_t **settings) /* O - Settings */ -{ - return (_cupsAdminGetServerSettings(http, num_settings, settings)); -} - - -/* - * '_cupsAdminGetServerSettings()' - Get settings from the server. - * - * The returned settings should be freed with cupsFreeOptions() when - * you are done with them. - * - * @since CUPS 1.2@ - */ - -int /* O - 1 on success, 0 on failure */ -_cupsAdminGetServerSettings( - http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ - int *num_settings, /* O - Number of settings */ - cups_option_t **settings) /* O - Settings */ { int i; /* Looping var */ cups_file_t *cupsd; /* cupsd.conf file */ @@ -1213,22 +1194,6 @@ cupsAdminSetServerSettings( http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ int num_settings, /* I - Number of settings */ cups_option_t *settings) /* I - Settings */ -{ - return (_cupsAdminSetServerSettings(http, num_settings, settings)); -} - - -/* - * '_cupsAdminSetServerSettings()' - Set settings on the server. - * - * @since CUPS 1.2@ - */ - -int /* O - 1 on success, 0 on failure */ -_cupsAdminSetServerSettings( - http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ - int num_settings, /* I - Number of settings */ - cups_option_t *settings) /* I - Settings */ { int i; /* Looping var */ http_status_t status; /* GET/PUT status */ @@ -1309,8 +1274,8 @@ _cupsAdminSetServerSettings( * Get current settings... */ - if (!_cupsAdminGetServerSettings(http, &cupsd_num_settings, - &cupsd_settings)) + if (!cupsAdminGetServerSettings(http, &cupsd_num_settings, + &cupsd_settings)) return (0); if ((val = cupsGetOption(CUPS_SERVER_DEBUG_LOGGING, cupsd_num_settings, @@ -1331,6 +1296,9 @@ _cupsAdminSetServerSettings( else remote_any = 0; + DEBUG_printf(("1cupsAdminSetServerSettings: old remote_any=%d", + remote_any)); + if ((val = cupsGetOption(CUPS_SERVER_REMOTE_PRINTERS, cupsd_num_settings, cupsd_settings)) != NULL) old_remote_printers = atoi(val); @@ -1495,13 +1463,13 @@ _cupsAdminSetServerSettings( while (cupsFileGetConf(cupsd, line, sizeof(line), &value, &linenum)) { if ((!strcasecmp(line, "Port") || !strcasecmp(line, "Listen")) && - (share_printers >= 0 || remote_admin >= 0)) + (remote_admin >= 0 || remote_any > 0 || share_printers >= 0)) { if (!wrote_port_listen) { wrote_port_listen = 1; - if (share_printers > 0 || remote_admin > 0) + if (remote_admin > 0 || remote_any > 0 || share_printers > 0) { cupsFilePuts(temp, "# Allow remote access\n"); cupsFilePrintf(temp, "Port %d\n", server_port); @@ -1709,7 +1677,8 @@ _cupsAdminSetServerSettings( cupsFilePrintf(temp, " Allow %s\n", remote_any > 0 ? "all" : "@LOCAL"); } - else if (in_root_location && (remote_admin >= 0 || share_printers >= 0)) + else if (in_root_location && + (remote_admin >= 0 || remote_any >= 0 || share_printers >= 0)) { wrote_root_location = 1; @@ -1720,12 +1689,14 @@ _cupsAdminSetServerSettings( cupsFilePuts(temp, " # Allow remote administration...\n"); else if (share_printers > 0) cupsFilePuts(temp, " # Allow shared printing...\n"); + else if (remote_any > 0) + cupsFilePuts(temp, " # Allow remote access...\n"); else cupsFilePuts(temp, " # Restrict access to the server...\n"); cupsFilePuts(temp, " Order allow,deny\n"); - if (remote_admin > 0 || share_printers > 0) + if (remote_admin > 0 || remote_any > 0 || share_printers > 0) cupsFilePrintf(temp, " Allow %s\n", remote_any > 0 ? "all" : "@LOCAL"); } @@ -1910,9 +1881,10 @@ _cupsAdminSetServerSettings( } } - if (!wrote_port_listen && (share_printers >= 0 || remote_admin >= 0)) + if (!wrote_port_listen && + (remote_admin >= 0 || remote_any >= 0 || share_printers >= 0)) { - if (share_printers > 0 || remote_admin > 0) + if (remote_admin > 0 || remote_any > 0 || share_printers > 0) { cupsFilePuts(temp, "# Allow remote access\n"); cupsFilePrintf(temp, "Port %d\n", ippPort()); @@ -1930,7 +1902,8 @@ _cupsAdminSetServerSettings( #endif /* CUPS_DEFAULT_DOMAINSOCKET */ } - if (!wrote_root_location && (remote_admin >= 0 || share_printers >= 0)) + if (!wrote_root_location && + (remote_admin >= 0 || remote_any >= 0 || share_printers >= 0)) { if (remote_admin > 0 && share_printers > 0) cupsFilePuts(temp, @@ -1939,13 +1912,15 @@ _cupsAdminSetServerSettings( cupsFilePuts(temp, "# Allow remote administration...\n"); else if (share_printers > 0) cupsFilePuts(temp, "# Allow shared printing...\n"); + else if (remote_any > 0) + cupsFilePuts(temp, "# Allow remote access...\n"); else cupsFilePuts(temp, "# Restrict access to the server...\n"); cupsFilePuts(temp, "\n" " Order allow,deny\n"); - if (remote_admin > 0 || share_printers > 0) + if (remote_admin > 0 || remote_any > 0 || share_printers > 0) cupsFilePrintf(temp, " Allow %s\n", remote_any > 0 ? "all" : "@LOCAL"); cupsFilePuts(temp, "\n"); diff --git a/cups/adminutil.h b/cups/adminutil.h index 145dfa0f7..45b497049 100644 --- a/cups/adminutil.h +++ b/cups/adminutil.h @@ -1,13 +1,9 @@ /* * "$Id: adminutil.h 7026 2007-10-19 00:57:45Z mike $" * - * Administration utility API definitions for the Common UNIX Printing - * System (CUPS). + * Administration utility API definitions for CUPS. * - * MANY OF THE FUNCTIONS IN THIS HEADER ARE PRIVATE AND SUBJECT TO - * CHANGE AT ANY TIME. USE AT YOUR OWN RISK. - * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 2001-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the diff --git a/cups/dest.c b/cups/dest.c index be962a104..52f70765d 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -545,7 +545,7 @@ cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTT if (!cups_get_sdests(http, op, name, 0, &dest)) { - if (op == CUPS_GET_DEFAULT || name) + if (op == CUPS_GET_DEFAULT || (name && !set_as_default)) return (NULL); /* diff --git a/cups/getdevices.c b/cups/getdevices.c index 6c9dbc843..76122cead 100644 --- a/cups/getdevices.c +++ b/cups/getdevices.c @@ -3,7 +3,7 @@ * * cupsGetDevices implementation for the Common UNIX Printing System (CUPS). * - * Copyright 2008-2009 by Apple Inc. + * Copyright 2008-2010 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -107,55 +107,15 @@ cupsGetDevices( } /* - * Send the request and do any necessary authentication... + * Send the request... */ - do - { - DEBUG_puts("2cupsGetDevices: Sending request..."); - status = cupsSendRequest(http, request, "/", ippLength(request)); - - DEBUG_puts("2cupsGetDevices: Waiting for response status..."); - while (status == HTTP_CONTINUE) - status = httpUpdate(http); - - if (status != HTTP_OK) - { - httpFlush(http); - - if (status == HTTP_UNAUTHORIZED) - { - /* - * See if we can do authentication... - */ - - DEBUG_puts("2cupsGetDevices: Need authorization..."); - - if (!cupsDoAuthentication(http, "POST", "/")) - httpReconnect(http); - else - { - status = HTTP_AUTHORIZATION_CANCELED; - break; - } - } - -#ifdef HAVE_SSL - else if (status == HTTP_UPGRADE_REQUIRED) - { - /* - * Force a reconnect with encryption... - */ - - DEBUG_puts("2cupsGetDevices: Need encryption..."); + DEBUG_puts("2cupsGetDevices: Sending request..."); + status = cupsSendRequest(http, request, "/", ippLength(request)); - if (!httpReconnect(http)) - httpEncryption(http, HTTP_ENCRYPT_REQUIRED); - } -#endif /* HAVE_SSL */ - } - } - while (status == HTTP_UNAUTHORIZED || status == HTTP_UPGRADE_REQUIRED); + DEBUG_puts("2cupsGetDevices: Waiting for response status..."); + while (status == HTTP_CONTINUE) + status = httpUpdate(http); DEBUG_printf(("2cupsGetDevices: status=%d", status)); @@ -258,7 +218,7 @@ cupsGetDevices( httpBlocking(http, blocking); httpFlush(http); - if (status == IPP_ERROR) + if (status == HTTP_ERROR) _cupsSetError(IPP_ERROR, NULL, 0); else { diff --git a/cups/ipp.c b/cups/ipp.c index 2f12f85b4..2a516c190 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -1,10 +1,9 @@ /* * "$Id: ipp.c 7847 2008-08-19 04:22:14Z mike $" * - * Internet Printing Protocol support functions for the Common UNIX - * Printing System (CUPS). + * Internet Printing Protocol functions for CUPS. * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -1894,6 +1893,12 @@ ippWriteIO(void *dst, /* I - Destination */ *bufptr++ = ipp->request.any.request_id >> 8; *bufptr++ = ipp->request.any.request_id; + DEBUG_printf(("2ippWriteIO: version=%d.%d", buffer[0], buffer[1])); + DEBUG_printf(("2ippWriteIO: op_status=%04x", + ipp->request.any.op_status)); + DEBUG_printf(("2ippWriteIO: request_id=%d", + ipp->request.any.request_id)); + if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0) { DEBUG_puts("1ippWriteIO: Could not write IPP header..."); @@ -1911,11 +1916,7 @@ ippWriteIO(void *dst, /* I - Destination */ ipp->current = ipp->attrs; ipp->curtag = IPP_TAG_ZERO; - DEBUG_printf(("2ippWriteIO: version=%d.%d", buffer[0], buffer[1])); - DEBUG_printf(("2ippWriteIO: op_status=%04x", - ipp->request.any.op_status)); - DEBUG_printf(("2ippWriteIO: request_id=%d", - ipp->request.any.request_id)); + DEBUG_printf(("1ippWriteIO: ipp->current=%p", ipp->current)); /* * If blocking is disabled, stop here... @@ -1936,23 +1937,30 @@ ippWriteIO(void *dst, /* I - Destination */ ipp->current = ipp->current->next; - if (ipp->curtag != attr->group_tag && parent == NULL) + if (!parent) { - /* - * Send a group tag byte... - */ + if (ipp->curtag != attr->group_tag) + { + /* + * Send a group tag byte... + */ - ipp->curtag = attr->group_tag; + ipp->curtag = attr->group_tag; - if (attr->group_tag == IPP_TAG_ZERO) - continue; + if (attr->group_tag == IPP_TAG_ZERO) + continue; - DEBUG_printf(("2ippWriteIO: wrote group tag=%x(%s)", - attr->group_tag, ippTagString(attr->group_tag))); - *bufptr++ = attr->group_tag; + DEBUG_printf(("2ippWriteIO: wrote group tag=%x(%s)", + attr->group_tag, ippTagString(attr->group_tag))); + *bufptr++ = attr->group_tag; + } + else if (attr->group_tag == IPP_TAG_ZERO) + continue; } - else if (attr->group_tag == IPP_TAG_ZERO) - continue; + + DEBUG_printf(("1ippWriteIO: %s (%s%s)", attr->name, + attr->num_values > 1 ? "1setOf " : "", + ippTagString(attr->value_tag))); /* * Write the attribute tag and name. The current implementation @@ -2625,15 +2633,18 @@ ippWriteIO(void *dst, /* I - Destination */ * Write the data out... */ - if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0) + if (bufptr > buffer) { - DEBUG_puts("1ippWriteIO: Could not write IPP attribute..."); - ipp_buffer_release(buffer); - return (IPP_ERROR); - } + if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0) + { + DEBUG_puts("1ippWriteIO: Could not write IPP attribute..."); + ipp_buffer_release(buffer); + return (IPP_ERROR); + } - DEBUG_printf(("2ippWriteIO: wrote %d bytes", - (int)(bufptr - buffer))); + DEBUG_printf(("2ippWriteIO: wrote %d bytes", + (int)(bufptr - buffer))); + } /* * If blocking is disabled, stop here... diff --git a/cups/libcups_s.exp b/cups/libcups_s.exp index 1ad3017fe..30b8a9f01 100644 --- a/cups/libcups_s.exp +++ b/cups/libcups_s.exp @@ -1,6 +1,4 @@ _cups_debug_fd -_cupsAdminGetServerSettings -_cupsAdminSetServerSettings _cupsCharmapFlush _cupsCharmapFree _cupsCharmapGet diff --git a/cups/mark.c b/cups/mark.c index 573e8fc7c..14349a1f9 100644 --- a/cups/mark.c +++ b/cups/mark.c @@ -1,9 +1,9 @@ /* * "$Id: mark.c 8210 2009-01-09 02:30:26Z mike $" * - * Option marking routines for the Common UNIX Printing System (CUPS). + * Option marking routines for CUPS. * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -29,7 +29,7 @@ * ppdFirstOption() - Return the first option in the PPD file. * ppdNextOption() - Return the next option in the PPD file. * _ppdParseOptions() - Parse options from a PPD file. - * debug_marked() - Output the marked array to stdout... + * ppd_debug_marked() - Output the marked array to stdout... * ppd_defaults() - Set the defaults for this group and all sub-groups. * ppd_mark_choices() - Mark one or more option choices from a string. * ppd_mark_option() - Quickly mark an option without checking for @@ -53,9 +53,9 @@ */ #ifdef DEBUG -static void debug_marked(ppd_file_t *ppd, const char *title); +static void ppd_debug_marked(ppd_file_t *ppd, const char *title); #else -# define debug_marked(ppd,title) +# define ppd_debug_marked(ppd,title) #endif /* DEBUG */ static void ppd_defaults(ppd_file_t *ppd, ppd_group_t *g); static void ppd_mark_choices(ppd_file_t *ppd, const char *s); @@ -122,7 +122,7 @@ cupsMarkOptions( if (!ppd || num_options <= 0 || !options) return (0); - debug_marked(ppd, "Before..."); + ppd_debug_marked(ppd, "Before..."); /* * Do special handling for media, media-col, and PageSize... @@ -146,10 +146,8 @@ cupsMarkOptions( num_media_cols = cupsParseOptions(media_col, 0, &media_cols); - if ((val = cupsGetOption("media-key", num_media_cols, media_cols)) != NULL) - media = val; - else if ((val = cupsGetOption("media-size", num_media_cols, - media_cols)) != NULL) + if ((val = cupsGetOption("media-size", num_media_cols, + media_cols)) != NULL) { /* * Lookup by dimensions... @@ -164,15 +162,15 @@ cupsMarkOptions( num_media_sizes = cupsParseOptions(val, 0, &media_sizes); loc = localeconv(); - if ((val = cupsGetOption("x-dimension", num_media_sizes, + if ((val = cupsGetOption("media-x-dimension", num_media_sizes, media_sizes)) != NULL) - width = _cupsStrScand(val, NULL, loc) * 2540.0 / 72.0; + width = _cupsStrScand(val, NULL, loc) * 72.0 / 2540.0; else width = 0.0; - if ((val = cupsGetOption("y-dimension", num_media_sizes, + if ((val = cupsGetOption("media-y-dimension", num_media_sizes, media_sizes)) != NULL) - length = _cupsStrScand(val, NULL, loc) * 2540.0 / 72.0; + length = _cupsStrScand(val, NULL, loc) * 72.0 / 2540.0; else length = 0.0; @@ -220,6 +218,9 @@ cupsMarkOptions( if (cupsGetOption("InputSlot", num_options, options) == NULL) ppd_mark_option(ppd, "InputSlot", s); + if (cupsGetOption("MediaColor", num_options, options) == NULL) + ppd_mark_option(ppd, "MediaColor", s); + if (cupsGetOption("MediaType", num_options, options) == NULL) ppd_mark_option(ppd, "MediaType", s); @@ -401,6 +402,60 @@ cupsMarkOptions( ppd_mark_choices(ppd, attr->value); } } + else if (!strcasecmp(optptr->name, "print-quality")) + { + ppd_option_t *output_mode = ppdFindOption(ppd, "OutputMode"); + /* OutputMode option */ + + if (!strcmp(optptr->value, "3")) + { + /* + * Draft quality... + */ + + if (ppdFindChoice(output_mode, "Draft")) + ppd_mark_option(ppd, "OutputMode", "Draft"); + else if (ppdFindChoice(output_mode, "Fast")) + ppd_mark_option(ppd, "OutputMode", "Fast"); + + if ((attr = ppdFindAttr(ppd, "APPrinterPreset", + "DraftGray_with_Paper_Auto-Detect")) != NULL) + ppd_mark_choices(ppd, attr->value); + } + else if (!strcmp(optptr->value, "4")) + { + /* + * Normal quality... + */ + + if (ppdFindChoice(output_mode, "Normal")) + ppd_mark_option(ppd, "OutputMode", "Normal"); + else if (ppdFindChoice(output_mode, "Good")) + ppd_mark_option(ppd, "OutputMode", "Good"); + + if ((attr = ppdFindAttr(ppd, "APPrinterPreset", + "Color_with_Paper_Auto-Detect")) != NULL) + ppd_mark_choices(ppd, attr->value); + else if ((attr = ppdFindAttr(ppd, "APPrinterPreset", + "Gray_with_Paper_Auto-Detect")) != NULL) + ppd_mark_choices(ppd, attr->value); + } + else if (!strcmp(optptr->value, "5")) + { + /* + * High/best/photo quality... + */ + + if (ppdFindChoice(output_mode, "Best")) + ppd_mark_option(ppd, "OutputMode", "Best"); + else if (ppdFindChoice(output_mode, "High")) + ppd_mark_option(ppd, "OutputMode", "High"); + + if ((attr = ppdFindAttr(ppd, "APPrinterPreset", + "Photo_on_Photo_Paper")) != NULL) + ppd_mark_choices(ppd, attr->value); + } + } else if (!strcasecmp(optptr->name, "APPrinterPreset")) { /* @@ -421,7 +476,7 @@ cupsMarkOptions( else ppd_mark_option(ppd, optptr->name, optptr->value); - debug_marked(ppd, "After..."); + ppd_debug_marked(ppd, "After..."); return (ppdConflicts(ppd) > 0); } @@ -746,11 +801,11 @@ _ppdParseOptions( #ifdef DEBUG /* - * 'debug_marked()' - Output the marked array to stdout... + * 'ppd_debug_marked()' - Output the marked array to stdout... */ static void -debug_marked(ppd_file_t *ppd, /* I - PPD file data */ +ppd_debug_marked(ppd_file_t *ppd, /* I - PPD file data */ const char *title) /* I - Title for list */ { ppd_choice_t *c; /* Current choice */ diff --git a/cups/request.c b/cups/request.c index 46a6b1ca9..413191bb0 100644 --- a/cups/request.c +++ b/cups/request.c @@ -679,6 +679,9 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP * Process the current HTTP status... */ + if (status >= HTTP_BAD_REQUEST) + httpFlush(http); + switch (status) { case HTTP_ERROR : @@ -687,18 +690,15 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP return (status); case HTTP_UNAUTHORIZED : - if (!cupsDoAuthentication(http, "POST", resource)) + if (cupsDoAuthentication(http, "POST", resource)) + return (HTTP_AUTHORIZATION_CANCELED); + + if (httpReconnect(http)) { - if (httpReconnect(http)) - { - _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0); - return (HTTP_SERVICE_UNAVAILABLE); - } + _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0); + return (HTTP_SERVICE_UNAVAILABLE); } - else - status = HTTP_AUTHORIZATION_CANCELED; - - return (status); + break; #ifdef HAVE_SSL case HTTP_UPGRADE_REQUIRED : @@ -713,9 +713,12 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP return (HTTP_SERVICE_UNAVAILABLE); } - httpEncryption(http, HTTP_ENCRYPT_REQUIRED); - - return (status); + if (httpEncryption(http, HTTP_ENCRYPT_REQUIRED)) + { + _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0); + return (HTTP_SERVICE_UNAVAILABLE); + } + break; #endif /* HAVE_SSL */ case HTTP_EXPECTATION_FAILED : @@ -802,7 +805,14 @@ cupsWriteRequestData( */ if (_httpWait(http, 0, 1)) - return (httpUpdate(http)); + { + http_status_t status; /* Status from httpUpdate */ + + if ((status = httpUpdate(http)) >= HTTP_BAD_REQUEST) + httpFlush(http); + + return (status); + } } return (HTTP_CONTINUE); diff --git a/cups/util.c b/cups/util.c index 7bfbe29a2..f0670436e 100644 --- a/cups/util.c +++ b/cups/util.c @@ -3,7 +3,7 @@ * * Printing utilities for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -1514,36 +1514,12 @@ cupsPrintFiles2( goto cancel_job; } - do - { - cupsFileRewind(fp); - - status = cupsStartDocument(http, name, job_id, docname, format, - i == (num_files - 1)); + status = cupsStartDocument(http, name, job_id, docname, format, + i == (num_files - 1)); - while (status == HTTP_CONTINUE && - (bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0) - status = cupsWriteRequestData(http, buffer, bytes); - - if (status == HTTP_UNAUTHORIZED) - { - char resource[1024]; /* Printer resource */ - - snprintf(resource, sizeof(resource), "/printers/%s", name); - - if (!cupsDoAuthentication(http, "POST", resource)) - { - if (httpReconnect(http)) - { - _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0); - return (0); - } - } - else - status = HTTP_AUTHORIZATION_CANCELED; - } - } - while (status == HTTP_UNAUTHORIZED); + while (status == HTTP_CONTINUE && + (bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0) + status = cupsWriteRequestData(http, buffer, bytes); cupsFileClose(fp); diff --git a/filter/pstops.c b/filter/pstops.c index 355b8a060..2dbbabb95 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -3,7 +3,7 @@ * * PostScript filter for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1993-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -121,14 +121,22 @@ typedef struct /**** Document information ****/ *title; /* Job name */ int copies; /* Number of copies */ const char *ap_input_slot, /* AP_FIRSTPAGE_InputSlot value */ - *ap_manual_feed; /* AP_FIRSTPAGE_ManualFeed value */ + *ap_manual_feed, /* AP_FIRSTPAGE_ManualFeed value */ + *ap_media_color, /* AP_FIRSTPAGE_MediaColor value */ + *ap_media_type, /* AP_FIRSTPAGE_MediaType value */ + *ap_page_region, /* AP_FIRSTPAGE_PageRegion value */ + *ap_page_size; /* AP_FIRSTPAGE_PageSize value */ float brightness; /* brightness value */ int collate, /* Collate copies? */ emit_jcl, /* Emit JCL commands? */ fitplot; /* Fit pages to media */ float gamma; /* gamma value */ const char *input_slot, /* InputSlot value */ - *manual_feed; /* ManualFeed value */ + *manual_feed, /* ManualFeed value */ + *media_color, /* MediaColor value */ + *media_type, /* MediaType value */ + *page_region, /* PageRegion value */ + *page_size; /* PageSize value */ int mirror, /* doc->mirror/mirror pages */ number_up, /* Number of pages on each sheet */ number_up_layout, /* doc->number_up_layout of N-up pages */ @@ -1322,6 +1330,18 @@ copy_page(cups_file_t *fp, /* I - File to read from */ doc->ap_manual_feed, pageinfo->num_options, &(pageinfo->options)); + pageinfo->num_options = cupsAddOption("MediaColor", doc->ap_media_color, + pageinfo->num_options, + &(pageinfo->options)); + pageinfo->num_options = cupsAddOption("MediaType", doc->ap_media_type, + pageinfo->num_options, + &(pageinfo->options)); + pageinfo->num_options = cupsAddOption("PageRegion", doc->ap_page_region, + pageinfo->num_options, + &(pageinfo->options)); + pageinfo->num_options = cupsAddOption("PageSize", doc->ap_page_size, + pageinfo->num_options, + &(pageinfo->options)); } else if (doc->page == (Duplex + 2)) { @@ -1337,6 +1357,18 @@ copy_page(cups_file_t *fp, /* I - File to read from */ doc->manual_feed, pageinfo->num_options, &(pageinfo->options)); + pageinfo->num_options = cupsAddOption("MediaColor", doc->media_color, + pageinfo->num_options, + &(pageinfo->options)); + pageinfo->num_options = cupsAddOption("MediaType", doc->media_type, + pageinfo->num_options, + &(pageinfo->options)); + pageinfo->num_options = cupsAddOption("PageRegion", doc->page_region, + pageinfo->num_options, + &(pageinfo->options)); + pageinfo->num_options = cupsAddOption("PageSize", doc->page_size, + pageinfo->num_options, + &(pageinfo->options)); } } @@ -2388,18 +2420,35 @@ set_pstops_options( doc->new_bounding_box[3] = INT_MIN; /* - * AP_FIRSTPAGE_InputSlot - */ - - doc->ap_input_slot = cupsGetOption("AP_FIRSTPAGE_InputSlot", num_options, - options); - - /* - * AP_FIRSTPAGE_ManualFeed + * AP_FIRSTPAGE_* and the corresponding non-first-page options. */ + doc->ap_input_slot = cupsGetOption("AP_FIRSTPAGE_InputSlot", num_options, + options); doc->ap_manual_feed = cupsGetOption("AP_FIRSTPAGE_ManualFeed", num_options, options); + doc->ap_media_color = cupsGetOption("AP_FIRSTPAGE_MediaColor", num_options, + options); + doc->ap_media_type = cupsGetOption("AP_FIRSTPAGE_MediaType", num_options, + options); + doc->ap_page_region = cupsGetOption("AP_FIRSTPAGE_PageRegion", num_options, + options); + doc->ap_page_size = cupsGetOption("AP_FIRSTPAGE_PageSize", num_options, + options); + + if ((choice = ppdFindMarkedChoice(ppd, "InputSlot")) != NULL) + doc->input_slot = choice->choice; + if ((choice = ppdFindMarkedChoice(ppd, "ManualFeed")) != NULL) + doc->manual_feed = choice->choice; + if ((choice = ppdFindMarkedChoice(ppd, "MediaColor")) != NULL) + doc->media_color = choice->choice; + if ((choice = ppdFindMarkedChoice(ppd, "MediaType")) != NULL) + doc->media_type = choice->choice; + if ((choice = ppdFindMarkedChoice(ppd, "PageRegion")) != NULL) + doc->page_region = choice->choice; + if ((choice = ppdFindMarkedChoice(ppd, "PageSize")) != NULL) + doc->page_size = choice->choice; + /* * brightness @@ -2495,19 +2544,9 @@ set_pstops_options( doc->gamma = 1.0f; /* - * InputSlot - */ - - if ((choice = ppdFindMarkedChoice(ppd, "InputSlot")) != NULL) - doc->input_slot = choice->choice; - - /* - * ManualFeed + * mirror/MirrorPrint */ - if ((choice = ppdFindMarkedChoice(ppd, "ManualFeed")) != NULL) - doc->manual_feed = choice->choice; - if ((choice = ppdFindMarkedChoice(ppd, "MirrorPrint")) != NULL) { val = choice->choice; diff --git a/man/cupsfilter.man b/man/cupsfilter.man index b2e797276..e4f961d33 100644 --- a/man/cupsfilter.man +++ b/man/cupsfilter.man @@ -1,9 +1,9 @@ .\" .\" "$Id: cupsfilter.man 7936 2008-09-11 03:12:59Z mike $" .\" -.\" cupsfilter man page for the Common UNIX Printing System (CUPS). +.\" cupsfilter man page for CUPS. .\" -.\" Copyright 2007-2009 by Apple Inc. +.\" Copyright 2007-2010 by Apple Inc. .\" .\" These coded instructions, statements, and computer programs are the .\" property of Apple Inc. and are protected by Federal copyright @@ -11,13 +11,15 @@ .\" which should have been included with this file. If this file is .\" file is missing or damaged, see the license at "http://www.cups.org/". .\" -.TH cupsfilter 8 "CUPS" "26 February 2009" "Apple Inc." +.TH cupsfilter 8 "CUPS" "4 March 2010" "Apple Inc." .SH NAME cupsfilter \- convert a file to another format using cups filters .SH SYNOPSIS .B cupsfilter [ -c .I config-file +] [ -d +.I printer ] [ -e ] -j .I job-id[,N] [ -m @@ -42,6 +44,9 @@ through CUPS. By default, \fIcupsfilter\fR generates a PDF file. .br Uses the named cupsd.conf configuration file. .TP 5 +-d printer +Uses information from the named printer. +.TP 5 -e .br Use every filter from the PPD file. @@ -80,7 +85,7 @@ This will be addressed in a future CUPS release. .br http://localhost:631/help .SH COPYRIGHT -Copyright 2007-2009 by Apple Inc. +Copyright 2007-2010 by Apple Inc. .\" .\" End of "$Id: cupsfilter.man 7936 2008-09-11 03:12:59Z mike $". .\" diff --git a/scheduler/conf.c b/scheduler/conf.c index 5288f9846..acdc92fc1 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -82,9 +82,6 @@ typedef struct static const cupsd_var_t variables[] = { { "AccessLog", &AccessLog, CUPSD_VARTYPE_STRING }, -#ifdef __APPLE__ - { "AppleQuotas", &AppleQuotas, CUPSD_VARTYPE_BOOLEAN }, -#endif /* __APPLE__ */ { "AutoPurgeJobs", &JobAutoPurge, CUPSD_VARTYPE_BOOLEAN }, { "BrowseInterval", &BrowseInterval, CUPSD_VARTYPE_INTEGER }, #ifdef HAVE_LDAP @@ -690,10 +687,6 @@ cupsdReadConfiguration(void) LaunchdTimeout = DEFAULT_TIMEOUT + 10; #endif /* HAVE_LAUNCHD */ -#ifdef __APPLE__ - AppleQuotas = TRUE; -#endif /* __APPLE__ */ - /* * Read the configuration file... */ diff --git a/scheduler/conf.h b/scheduler/conf.h index 1084bc2af..d1cab69a1 100644 --- a/scheduler/conf.h +++ b/scheduler/conf.h @@ -3,7 +3,7 @@ * * Configuration file definitions for CUPS. * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -252,11 +252,6 @@ VAR int LaunchdTimeout VALUE(DEFAULT_KEEPALIVE); /* Time after which an idle cupsd will exit */ #endif /* HAVE_LAUNCHD */ -#ifdef __APPLE__ -VAR int AppleQuotas VALUE(TRUE); - /* Use Apple PrintService Quotas instead of CUPS quotas */ -#endif /* __APPLE__ */ - #ifdef HAVE_AUTHORIZATION_H VAR char *SystemGroupAuthKey VALUE(NULL); /* System group auth key */ diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h index 93763a216..3a1b3a832 100644 --- a/scheduler/cupsd.h +++ b/scheduler/cupsd.h @@ -3,7 +3,7 @@ * * Main header file for the Common UNIX Printing System (CUPS) scheduler. * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -178,16 +178,6 @@ VAR int Launchd VALUE(0); /* Running from launchd */ #endif /* HAVE_LAUNCH_H */ -#if defined(__APPLE__) && defined(HAVE_DLFCN_H) -typedef int (*PSQUpdateQuotaProcPtr)(const char *printer, const char *info, - const char *user, int nPages, int options); -VAR PSQUpdateQuotaProcPtr PSQUpdateQuotaProc - VALUE(0); - /* Apple PrintService quota function */ -#endif /* __APPLE__ && HAVE_DLFCN_H */ - - - /* * Prototypes... diff --git a/scheduler/cupsfilter.c b/scheduler/cupsfilter.c index 5470bf549..bcef6b951 100644 --- a/scheduler/cupsfilter.c +++ b/scheduler/cupsfilter.c @@ -212,6 +212,14 @@ main(int argc, /* I - Number of command-line args */ usage(command, opt); break; + case 'd' : /* Specify the real printer name */ + i ++; + if (i < argc) + printer = argv[i]; + else + usage(command, opt); + break; + case 'D' : /* Delete input file after conversion */ removeinfile = 1; break; @@ -1353,6 +1361,7 @@ usage(const char *command, /* I - Command name */ "Options:\n" "\n" " -c cupsd.conf Set cupsd.conf file to use\n" + " -d printer Use the named printer\n" " -e Use every filter from the PPD file\n" " -j job-id[,N] Filter file N from the specified job (default is file 1)\n" " -n copies Set number of copies\n" @@ -1365,6 +1374,7 @@ usage(const char *command, /* I - Command name */ "\n" "Options:\n" "\n" + " -d printer Use the named printer\n" " -e Use every filter from the PPD file\n" " -f filename Set file to be converted (otherwise stdin)\n" " -o filename Set file to be generated (otherwise stdout)\n" diff --git a/scheduler/ipp.c b/scheduler/ipp.c index ced835f29..58a1ab493 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -2879,7 +2879,7 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ char cache_name[1024]; /* Cache filename for printer attrs */ - snprintf(cache_name, sizeof(cache_name), "%s/%s.ipp", CacheDir, + snprintf(cache_name, sizeof(cache_name), "%s/%s.ipp2", CacheDir, printer->name); unlink(cache_name); @@ -4434,66 +4434,6 @@ check_quotas(cupsd_client_t *con, /* I - Client connection */ * Check quotas... */ -#ifdef __APPLE__ - if (AppleQuotas && (q = cupsdFindQuota(p, username)) != NULL) - { - /* - * TODO: Define these special page count values as constants! - */ - - if (q->page_count == -4) /* special case: unlimited user */ - { - cupsdLogMessage(CUPSD_LOG_INFO, - "User \"%s\" request approved for printer %s (%s): " - "unlimited quota.", - username, p->name, p->info); - q->page_count = 0; /* allow user to print */ - return (1); - } - else if (q->page_count == -3) /* quota exceeded */ - { - cupsdLogMessage(CUPSD_LOG_INFO, - "User \"%s\" request denied for printer %s (%s): " - "quota limit exceeded.", - username, p->name, p->info); - q->page_count = 2; /* force quota exceeded failure */ - return (-1); - } - else if (q->page_count == -2) /* quota disabled for user */ - { - cupsdLogMessage(CUPSD_LOG_INFO, - "User \"%s\" request denied for printer %s (%s): " - "printing disabled for user.", - username, p->name, p->info); - q->page_count = 2; /* force quota exceeded failure */ - return (-1); - } - else if (q->page_count == -1) /* quota access error */ - { - cupsdLogMessage(CUPSD_LOG_INFO, - "User \"%s\" request denied for printer %s (%s): " - "unable to determine quota limit.", - username, p->name, p->info); - q->page_count = 2; /* force quota exceeded failure */ - return (-1); - } - else if (q->page_count < 0) /* user not found or other error */ - { - cupsdLogMessage(CUPSD_LOG_INFO, - "User \"%s\" request denied for printer %s (%s): " - "user disabled / missing quota.", - username, p->name, p->info); - q->page_count = 2; /* force quota exceeded failure */ - return (-1); - } - else /* page within user limits */ - { - q->page_count = 0; /* allow user to print */ - return (1); - } - } - else -#endif /* __APPLE__ */ if (p->k_limit || p->page_limit) { if ((q = cupsdUpdateQuota(p, username, 0, 0)) == NULL) @@ -6430,7 +6370,7 @@ delete_printer(cupsd_client_t *con, /* I - Client connection */ printer->name); unlink(filename); - snprintf(filename, sizeof(filename), "%s/%s.ipp", CacheDir, printer->name); + snprintf(filename, sizeof(filename), "%s/%s.ipp2", CacheDir, printer->name); unlink(filename); #ifdef __APPLE__ diff --git a/scheduler/job.c b/scheduler/job.c index 91a017b75..cbdb0e29a 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -3,7 +3,7 @@ * * Job management routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -2222,12 +2222,14 @@ cupsdSetJobState( if (!cupsdLoadJob(job)) return; - /* - * Don't do anything if the state is unchanged... - */ + /* + * Don't do anything if the state is unchanged and we aren't purging the + * job... + */ - if (newstate == (oldstate = job->state_value)) - return; + oldstate = job->state_value; + if (newstate == oldstate && action != CUPSD_JOB_PURGE) + return; /* * Stop any processes that are working on the current job... @@ -2434,6 +2436,15 @@ cupsdSetJobState( job->dirty = 1; cupsdMarkDirty(CUPSD_DIRTY_JOBS); } + else if (!job->printer) + { + /* + * Delete the job immediately if not actively printing... + */ + + cupsdDeleteJob(job, CUPSD_JOB_PURGE); + job = NULL; + } break; } @@ -2441,7 +2452,7 @@ cupsdSetJobState( * Finalize the job immediately if we forced things... */ - if (action >= CUPSD_JOB_FORCE && job->printer) + if (action >= CUPSD_JOB_FORCE && job && job->printer) finalize_job(job, 0); /* @@ -4055,28 +4066,7 @@ update_job(cupsd_job_t *job) /* I - Job to check */ job->sheets->values[0].integer += copies; if (job->printer->page_limit) - { - cupsd_quota_t *q = cupsdUpdateQuota(job->printer, job->username, - copies, 0); - -#ifdef __APPLE__ - if (AppleQuotas && q->page_count == -3) - { - /* - * Quota limit exceeded, cancel job in progress immediately... - */ - - cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_DEFAULT, - "Canceled job because pages exceed user %s " - "quota limit on printer %s (%s).", - job->username, job->printer->name, - job->printer->info); - return; - } -#else - (void)q; -#endif /* __APPLE__ */ - } + cupsdUpdateQuota(job->printer, job->username, copies, 0); } cupsdLogPage(job, message); diff --git a/scheduler/log.c b/scheduler/log.c index 15fcf972f..09bb273e9 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -3,7 +3,7 @@ * * Log file routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -560,7 +560,7 @@ cupsdLogRequest(cupsd_client_t *con, /* I - Request to log */ if (AccessLogLevel < CUPSD_ACCESSLOG_ALL) { /* - * Eliminate simple GET requests... + * Eliminate simple GET, POST, and PUT requests... */ if ((con->operation == HTTP_GET && @@ -568,7 +568,8 @@ cupsdLogRequest(cupsd_client_t *con, /* I - Request to log */ strncmp(con->uri, "/admin/log", 10)) || (con->operation == HTTP_POST && !con->request && strncmp(con->uri, "/admin", 6)) || - (con->operation != HTTP_POST && con->operation != HTTP_PUT)) + (con->operation != HTTP_GET && con->operation != HTTP_POST && + con->operation != HTTP_PUT)) return (1); if (con->request && con->response && diff --git a/scheduler/main.c b/scheduler/main.c index c4378d0d8..cc05af694 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -3,7 +3,7 @@ * * Scheduler main loop for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -21,6 +21,7 @@ * cupsdReleaseSignals() - Release signals for delivery. * cupsdSetString() - Set a string value. * cupsdSetStringf() - Set a formatted string value. + * cupsd_clean_files() - Clean out old files. * launchd_checkin() - Check-in with launchd and collect the * listening fds. * launchd_checkout() - Check-out with launchd. @@ -45,11 +46,12 @@ #include #include #include +#include #ifdef HAVE_LAUNCH_H # include # include -# define CUPS_KEEPALIVE CUPS_CACHEDIR "/org.cups.cupsd" +# define CUPS_KEEPALIVE CUPS_CACHEDIR "/org.cups.cupsd" /* Name of the launchd KeepAlive file */ # ifndef LAUNCH_JOBKEY_KEEPALIVE # define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive" @@ -69,15 +71,13 @@ # include #endif /* HAVE_NOTIFY_H */ -#if defined(__APPLE__) && defined(HAVE_DLFCN_H) -# include -#endif /* __APPLE__ && HAVE_DLFCN_H */ - /* * Local functions... */ +static void cupsd_clean_files(const char *path, + const char *pattern); #ifdef HAVE_LAUNCHD static void launchd_checkin(void); static void launchd_checkout(void); @@ -106,12 +106,6 @@ static int dead_children = 0; static int stop_scheduler = 0; /* Should the scheduler stop? */ -#if defined(__APPLE__) && defined(HAVE_DLFCN_H) -static const char *PSQLibPath = "/usr/lib/libPrintServiceQuota.dylib"; -static const char *PSQLibFuncName = "PSQUpdateQuota"; -static void *PSQLibRef; /* libPrintServiceQuota.dylib */ -#endif /* HAVE_DLFCN_H */ - /* * 'main()' - Main entry for the CUPS scheduler. @@ -508,42 +502,14 @@ main(int argc, /* I - Number of command-line args */ return (0); } - if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot))) - { - /* - * Clean out the temporary directory... - */ - - cups_dir_t *dir; /* Temporary directory */ - cups_dentry_t *dent; /* Directory entry */ - char tempfile[1024]; /* Temporary filename */ - - - if ((dir = cupsDirOpen(TempDir)) != NULL) - { - cupsdLogMessage(CUPSD_LOG_INFO, - "Cleaning out old temporary files in \"%s\"...", TempDir); - - while ((dent = cupsDirRead(dir)) != NULL) - { - snprintf(tempfile, sizeof(tempfile), "%s/%s", TempDir, dent->filename); + /* + * Clean out old temp files and printer cache data. + */ - if (unlink(tempfile)) - cupsdLogMessage(CUPSD_LOG_ERROR, - "Unable to remove temporary file \"%s\" - %s", - tempfile, strerror(errno)); - else - cupsdLogMessage(CUPSD_LOG_DEBUG, "Removed temporary file \"%s\"...", - tempfile); - } + if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot))) + cupsd_clean_files(TempDir, NULL); - cupsDirClose(dir); - } - else - cupsdLogMessage(CUPSD_LOG_ERROR, - "Unable to open temporary directory \"%s\" - %s", - TempDir, strerror(errno)); - } + cupsd_clean_files(CacheDir, "*.ipp"); #if HAVE_LAUNCHD if (Launchd) @@ -557,17 +523,6 @@ main(int argc, /* I - Number of command-line args */ } #endif /* HAVE_LAUNCHD */ -#if defined(__APPLE__) && defined(HAVE_DLFCN_H) - /* - * Load Print Service quota enforcement library (X Server only) - */ - - PSQLibRef = dlopen(PSQLibPath, RTLD_LAZY); - - if (PSQLibRef) - PSQUpdateQuotaProc = dlsym(PSQLibRef, PSQLibFuncName); -#endif /* __APPLE__ && HAVE_DLFCN_H */ - /* * Startup the server... */ @@ -1198,19 +1153,6 @@ main(int argc, /* I - Number of command-line args */ krb5_free_context(KerberosContext); #endif /* HAVE_GSSAPI */ -#if defined(__APPLE__) && defined(HAVE_DLFCN_H) - /* - * Unload Print Service quota enforcement library (X Server only) - */ - - PSQUpdateQuotaProc = NULL; - if (PSQLibRef) - { - dlclose(PSQLibRef); - PSQLibRef = NULL; - } -#endif /* __APPLE__ && HAVE_DLFCN_H */ - #ifdef __sgi /* * Remove the fake IRIX lpsched lock file, but only if the existing @@ -1441,6 +1383,60 @@ cupsdSetStringf(char **s, /* O - New string */ } +/* + * 'cupsd_clean_files()' - Clean out old files. + */ + +static void +cupsd_clean_files(const char *path, /* I - Directory to clean */ + const char *pattern) /* I - Filename pattern or NULL */ +{ + cups_dir_t *dir; /* Directory */ + cups_dentry_t *dent; /* Directory entry */ + char filename[1024]; /* Filename */ + int status; /* Status from unlink/rmdir */ + + + cupsdLogMessage(CUPSD_LOG_DEBUG, + "cupsd_clean_files(path=\"%s\", pattern=\"%s\")", path, + pattern ? pattern : "(null)"); + + if ((dir = cupsDirOpen(path)) == NULL) + { + cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open directory \"%s\" - %s", + path, strerror(errno)); + return; + } + + cupsdLogMessage(CUPSD_LOG_INFO, "Cleaning out old files in \"%s\"...", path); + + while ((dent = cupsDirRead(dir)) != NULL) + { + if (pattern && fnmatch(pattern, dent->filename, 0)) + continue; + + snprintf(filename, sizeof(filename), "%s/%s", path, dent->filename); + + if (S_ISDIR(dent->fileinfo.st_mode)) + { + cupsd_clean_files(filename, pattern); + + status = rmdir(filename); + } + else + status = unlink(filename); + + if (status) + cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to remove \"%s\" - %s", filename, + strerror(errno)); + else + cupsdLogMessage(CUPSD_LOG_DEBUG, "Removed \"%s\"...", filename); + } + + cupsDirClose(dir); +} + + #ifdef HAVE_LAUNCHD /* * 'launchd_checkin()' - Check-in with launchd and collect the listening fds. diff --git a/scheduler/network.c b/scheduler/network.c index 95c6a9cab..e2f7d6ca8 100644 --- a/scheduler/network.c +++ b/scheduler/network.c @@ -155,7 +155,11 @@ cupsdNetIFUpdate(void) * Try looking up the hostname for the address as needed... */ +#ifdef __APPLE__ + if (HostNameLookups) +#else if (HostNameLookups || RemotePort) +#endif /* __APPLE__ */ httpAddrLookup((http_addr_t *)(addr->ifa_addr), hostname, sizeof(hostname)); else diff --git a/scheduler/policy.c b/scheduler/policy.c index 4fefbd16a..b7deab72a 100644 --- a/scheduler/policy.c +++ b/scheduler/policy.c @@ -213,11 +213,25 @@ cupsdDeleteAllPolicies(void) { cupsd_policy_t *p; /* Current policy */ cupsd_location_t *po; /* Current policy op */ + cupsd_printer_t *printer; /* Current printer */ if (!Policies) return; + /* + * First clear the policy pointers for all printers... + */ + + for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers); + printer; + printer = (cupsd_printer_t *)cupsArrayNext(Printers)) + printer->op_policy_ptr = NULL; + + /* + * Then free all of the policies... + */ + for (p = (cupsd_policy_t *)cupsArrayFirst(Policies); p; p = (cupsd_policy_t *)cupsArrayNext(Policies)) diff --git a/scheduler/printers.c b/scheduler/printers.c index 3a02ab629..b77885cf2 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -3489,10 +3489,6 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */ ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "number-up-default", 1); - if (!cupsGetOption("orientation-requested", p->num_options, p->options)) - ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NOVALUE, - "orientation-requested-default", NULL, NULL); - if (!cupsGetOption("notify-lease-duration", p->num_options, p->options)) ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "notify-lease-duration-default", DefaultLeaseDuration); @@ -3500,6 +3496,14 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */ if (!cupsGetOption("notify-events", p->num_options, p->options)) ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "notify-events-default", NULL, "job-completed"); + + if (!cupsGetOption("orientation-requested", p->num_options, p->options)) + ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NOVALUE, + "orientation-requested-default", NULL, NULL); + + if (!cupsGetOption("print-quality", p->num_options, p->options)) + ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, + "print-quality-default", IPP_QUALITY_NORMAL); } @@ -3738,19 +3742,9 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */ mime_filter_t *filter; /* MIME filter looping var */ - pdl[0] = '\0'; - - if (mimeType(MimeDatabase, "application", "pdf")) - strlcat(pdl, "application/pdf,", sizeof(pdl)); - - if (mimeType(MimeDatabase, "application", "postscript")) - strlcat(pdl, "application/postscript,", sizeof(pdl)); - - if (mimeType(MimeDatabase, "application", "vnd.cups-raster")) - strlcat(pdl, "application/vnd.cups-raster,", sizeof(pdl)); - /* - * Determine if this is a Tioga PrintJobMgr based queue... + * We only support raw printing if this is not a Tioga PrintJobMgr based + * queue and if application/octet-stream is a known type... */ for (filter = (mime_filter_t *)cupsArrayFirst(MimeDatabase->filters); @@ -3762,16 +3756,34 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */ break; } - /* - * We only support raw printing if this is not a Tioga PrintJobMgr based - * queue and if application/octet-stream is a known conversion... - */ + pdl[0] = '\0'; if (!filter && mimeType(MimeDatabase, "application", "octet-stream")) strlcat(pdl, "application/octet-stream,", sizeof(pdl)); - if (mimeType(MimeDatabase, "image", "png")) - strlcat(pdl, "image/png,", sizeof(pdl)); + /* + * Then list a bunch of formats that are supported by the printer... + */ + + for (type = (mime_type_t *)cupsArrayFirst(p->filetypes); + type; + type = (mime_type_t *)cupsArrayNext(p->filetypes)) + { + if (!strcasecmp(type->super, "application")) + { + if (!strcasecmp(type->type, "pdf")) + strlcat(pdl, "application/pdf,", sizeof(pdl)); + else if (!strcasecmp(type->type, "postscript")) + strlcat(pdl, "application/postscript,", sizeof(pdl)); + } + else if (!strcasecmp(type->super, "image")) + { + if (!strcasecmp(type->type, "jpeg")) + strlcat(pdl, "image/jpeg,", sizeof(pdl)); + else if (!strcasecmp(type->type, "png")) + strlcat(pdl, "image/png,", sizeof(pdl)); + } + } if (pdl[0]) pdl[strlen(pdl) - 1] = '\0'; /* Remove trailing comma */ @@ -3891,6 +3903,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ ppd_size_t *size; /* Current size */ ppd_option_t *duplex, /* Duplex option */ *output_bin, /* OutputBin option */ + *output_mode, /* OutputMode option */ *resolution; /* (Set|JCL|)Resolution option */ ppd_choice_t *choice; /* Current PPD choice */ ppd_attr_t *ppd_attr; /* PPD attribute */ @@ -3902,8 +3915,10 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ ipp_t *media_col_default, /* media-col-default collection value */ *media_size; /* media-size collection value */ ipp_value_t *val; /* Attribute value */ - int num_finishings; /* Number of finishings */ - int finishings[5]; /* finishings-supported values */ + int num_finishings, /* Number of finishings */ + finishings[5]; /* finishings-supported values */ + int num_qualities, /* Number of print-quality values */ + qualities[3]; /* print-quality values */ static const char * const sides[3] = /* sides-supported values */ { "one-sided", @@ -3922,7 +3937,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ * Check to see if the cache is up-to-date... */ - snprintf(cache_name, sizeof(cache_name), "%s/%s.ipp", CacheDir, p->name); + snprintf(cache_name, sizeof(cache_name), "%s/%s.ipp2", CacheDir, p->name); if (stat(cache_name, &cache_info)) cache_info.st_mtime = 0; @@ -3990,8 +4005,51 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported", ppd->color_device); if (ppd->throughput) + { ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "pages-per-minute", ppd->throughput); + if (ppd->color_device) + ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, + "pages-per-minute-color", ppd->throughput); + } + + num_qualities = 0; + + if ((output_mode = ppdFindOption(ppd, "OutputMode")) != NULL) + { + if (ppdFindChoice(output_mode, "draft") || + ppdFindChoice(output_mode, "fast")) + qualities[num_qualities ++] = IPP_QUALITY_DRAFT; + if (ppdFindChoice(output_mode, "normal") || + ppdFindChoice(output_mode, "good")) + qualities[num_qualities ++] = IPP_QUALITY_NORMAL; + if (ppdFindChoice(output_mode, "best") || + ppdFindChoice(output_mode, "high")) + qualities[num_qualities ++] = IPP_QUALITY_HIGH; + } + else if ((ppd_attr = ppdFindAttr(ppd, "APPrinterPreset", NULL)) != NULL) + { + do + { + if (strstr(ppd_attr->spec, "draft") || + strstr(ppd_attr->spec, "Draft")) + { + qualities[num_qualities ++] = IPP_QUALITY_DRAFT; + break; + } + } + while ((ppd_attr = ppdFindNextAttr(ppd, "APPrinterPreset", + NULL)) != NULL); + + qualities[num_qualities ++] = IPP_QUALITY_NORMAL; + qualities[num_qualities ++] = IPP_QUALITY_HIGH; + } + + if (num_qualities == 0) + qualities[num_qualities ++] = IPP_QUALITY_NORMAL; + + ippAddIntegers(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, + "print-quality-supported", num_qualities, qualities); if (ppd->nickname) { @@ -4195,7 +4253,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ } attr->values[i].resolution.xres = xdpi; - attr->values[i].resolution.yres = xdpi; + attr->values[i].resolution.yres = ydpi; attr->values[i].resolution.units = IPP_RES_PER_INCH; if (choice->marked) diff --git a/scheduler/quotas.c b/scheduler/quotas.c index 3288c4d11..eb6277102 100644 --- a/scheduler/quotas.c +++ b/scheduler/quotas.c @@ -3,7 +3,7 @@ * * Quota routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -119,19 +119,6 @@ cupsdUpdateQuota( "cupsdUpdateQuota: p=%s username=%s pages=%d k=%d", p->name, username, pages, k); -#if defined(__APPLE__) && defined(HAVE_DLFCN_H) - /* - * Use Apple PrintService quota enforcement if installed (X Server only) - */ - - if (AppleQuotas && PSQUpdateQuotaProc) - { - q->page_count = (*PSQUpdateQuotaProc)(p->name, p->info, username, pages, 0); - - return (q); - } -#endif /* __APPLE__ && HAVE_DLFCN_H */ - curtime = time(NULL); if (curtime < q->next_update) diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index 79b192d76..c9f64de95 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -3,7 +3,7 @@ * * PPD test program for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -112,168 +112,6 @@ enum #define MODE_PROGRAM 0555 /* Owner/group/other read+exec */ -/* - * Standard Adobe media keywords (must remain sorted)... - */ - -static const char adobe_size_names[][PPD_MAX_NAME] = -{ - "10x11", - "10x13", - "10x14", - "12x11", - "15x11", - "7x9", - "8x10", - "9x11", - "9x12", - "A0", - "A1", - "A10", - "A2", - "A3", - "A3Extra", - "A3Rotated", - "A4", - "A4Extra", - "A4Plus", - "A4Rotated", - "A4Small", - "A5", - "A5Extra", - "A5Rotated", - "A6", - "A6Rotated", - "A7", - "A8", - "A9", - "ARCHA", - "ARCHB", - "ARCHC", - "ARCHD", - "ARCHE", - "AnsiA", - "AnsiB", - "AnsiC", - "AnsiD", - "AnsiE", - "B0", - "B1", - "B1", - "B10", - "B2", - "B3", - "B4", - "B4Rotated", - "B5", - "B5Rotated", - "B6", - "B6Rotated", - "B7", - "B8", - "B9", - "C4", - "C5", - "C6", - "DL", - "DoublePostcard", - "DoublePostcardRotated", - "Env10", - "Env11", - "Env12", - "Env14", - "Env9", - "EnvC0", - "EnvC1", - "EnvC2", - "EnvC3", - "EnvC4", - "EnvC5", - "EnvC6", - "EnvC65", - "EnvC7", - "EnvChou3", - "EnvChou3Rotated", - "EnvChou4", - "EnvChou4Rotated", - "EnvDL", - "EnvISOB4", - "EnvISOB5", - "EnvISOB6", - "EnvInvite", - "EnvItalian", - "EnvKaku2", - "EnvKaku2Rotated", - "EnvKaku3", - "EnvKaku3Rotated", - "EnvMonarch", - "EnvPRC1", - "EnvPRC10", - "EnvPRC10Rotated", - "EnvPRC1Rotated", - "EnvPRC2", - "EnvPRC2Rotated", - "EnvPRC3", - "EnvPRC3Rotated", - "EnvPRC4", - "EnvPRC4Rotated", - "EnvPRC5", - "EnvPRC5Rotated", - "EnvPRC6", - "EnvPRC6Rotated", - "EnvPRC7", - "EnvPRC7Rotated", - "EnvPRC8", - "EnvPRC8Rotated", - "EnvPRC9", - "EnvPRC9Rotated", - "EnvPersonal", - "EnvYou4", - "EnvYou4Rotated", - "Executive", - "FanFoldGerman", - "FanFoldGermanLegal", - "FanFoldUS", - "Folio", - "ISOB0", - "ISOB1", - "ISOB10", - "ISOB2", - "ISOB3", - "ISOB4", - "ISOB5", - "ISOB5Extra", - "ISOB6", - "ISOB7", - "ISOB8", - "ISOB9", - "Ledger", - "Legal", - "LegalExtra", - "Letter", - "LetterExtra", - "LetterPlus", - "LetterRotated", - "LetterSmall", - "Monarch", - "Note", - "PRC16K", - "PRC16KRotated", - "PRC32K", - "PRC32KBig", - "PRC32KBigRotated", - "PRC32KRotated", - "Postcard", - "PostcardRotated", - "Quarto", - "Statement", - "SuperA", - "SuperB", - "Tabloid", - "TabloidExtra" -}; - - /* * Local functions... */ @@ -3150,28 +2988,6 @@ check_sizes(ppd_file_t *ppd, /* I - PPD file */ errors ++; } } - else if (warn && verbose >= 0) - { - /* - * Lookup the size name in the standard size table... - */ - - strlcpy(name, size->name, sizeof(name)); - if ((nameptr = strchr(name, '.')) != NULL) - *nameptr = '\0'; - - if (!bsearch(name, adobe_size_names, - sizeof(adobe_size_names) / - sizeof(adobe_size_names[0]), - sizeof(adobe_size_names[0]), - (int (*)(const void *, const void *))strcmp)) - { - _cupsLangPrintf(stdout, - _(" %s Non-standard size name \"%s\"\n" - " REF: Page 187, section B.2.\n"), - prefix, size->name); - } - } /* * Verify that the size is defined for both PageSize and PageRegion... diff --git a/test/run-stp-tests.sh b/test/run-stp-tests.sh index b78ea9c22..b789b074d 100755 --- a/test/run-stp-tests.sh +++ b/test/run-stp-tests.sh @@ -612,6 +612,18 @@ echo "Test Summary" echo "" echo "

Summary

" >>$strfile +# Job control files +count=`ls -1 /tmp/cups-$user/spool | wc -l` +count=`expr $count - 1` +if test $count != 0; then + echo "FAIL: $count job control files were not purged." + echo "

FAIL: $count job control files were not purged.

" >>$strfile + fail=`expr $fail + 1` +else + echo "PASS: All job control files purged." + echo "

PASS: All job control files purged.

" >>$strfile +fi + # Pages printed on Test1 (within 1 page for timing-dependent cancel issues) count=`grep '^Test1 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'` expected=`expr $pjobs \* 2 + 34` -- 2.39.2