From: msweet Date: Fri, 23 Jan 2009 22:36:42 +0000 (+0000) Subject: Merge changes from CUPS 1.4svn-r8290. X-Git-Tag: release-1.6.3~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1c13e168660dfc384ead2efe29eb20a7abc5950;p=thirdparty%2Fcups.git Merge changes from CUPS 1.4svn-r8290. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1144 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/CHANGES-1.3.txt b/CHANGES-1.3.txt index b57dbf20c..84ea4a62c 100644 --- a/CHANGES-1.3.txt +++ b/CHANGES-1.3.txt @@ -5,6 +5,18 @@ CHANGES IN CUPS V1.3.10 - Documentation fixes (STR #2994, STR #2995, STR #3008, STR #3056, STR #3057) + - Fixed a Valgrind-detected initialization error when creating a + missing directory on startup. + - The scheduler did not always read all of the HTTP headers from a + CGI script/program. + - The scheduler did not always set the "air" property in Bonjour/DNS-SD + registrations. + - The scheduler incorrectly compared Mac OS X UUIDs for access + control, preventing access in certain configurations. + - The IPP backend incorrectly reset the required authentication + to Kerberos when authentication failed. + - The scheduler no longer looks up the local hostname by default; + turn on hostname lookups to restore the previous behavior. - The scheduler did not always load MIME type rules correctly (STR #3059) - The test page did not format correctly on A4 paper (STR #3060) diff --git a/CHANGES.txt b/CHANGES.txt index 262c7e471..cdf0e7445 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,22 @@ -CHANGES.txt - 2009-01-14 +CHANGES.txt - 2009-01-23 ------------------------ CHANGES IN CUPS V1.4b3 - Documentation fixes (STR #3044, STR #3057) + - The configure script incorrectly allowed Avahi to be used for DNS-SD + printer discovery (STR #3065) + - The web interface and scheduler did not support URIs up to 1024 bytes + in length (STR #3072) + - Fixed pdftops issues with page sizes (STR #3063) + - Fixed pdftops issues with Ghostscript (STR #3062) + - The scheduler incorrectly registered default profiles for PostScript + printers with no specified colorspace. + - The scheduler incorrectly created an empty org.cups.printers.plist + file on Mac OS X. + - cupsGetPPD3() did not look for local PPDs in the right directory. + - SNMP lookups via side-channel did not work for NULL-VALUE and + and OCTET-STRING OIDs containing nul characters. - The libusb-based USB backend did not work. - The scheduler did not set the printer-commands attribute correctly for some PPDs. diff --git a/backend/ipp.c b/backend/ipp.c index d2f1d570e..182980913 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -1262,6 +1262,19 @@ main(int argc, /* I - Number of command-line args */ page_count > start_count) fprintf(stderr, "PAGE: total %d\n", page_count - start_count); + /* + * Update auth-info-required as needed... + */ + + if (ipp_status == IPP_NOT_AUTHORIZED) + { + if (!strncmp(httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE), + "Negotiate", 9)) + fputs("ATTR: auth-info-required=negotiate\n", stderr); + else + fputs("ATTR: auth-info-required=username,password\n", stderr); + } + /* * Free memory... */ @@ -1295,15 +1308,7 @@ main(int argc, /* I - Number of command-line args */ */ if (ipp_status == IPP_NOT_AUTHORIZED) - { - /* - * Authorization failures here mean that we need Kerberos. Username + - * password authentication is handled in the password_cb function. - */ - - fputs("ATTR: auth-info-required=negotiate\n", stderr); return (CUPS_BACKEND_AUTH_REQUIRED); - } else if (ipp_status > IPP_OK_CONFLICT) return (CUPS_BACKEND_FAILED); else diff --git a/backend/network.c b/backend/network.c index 58f9503d9..06ffc0467 100644 --- a/backend/network.c +++ b/backend/network.c @@ -3,7 +3,7 @@ * * Common network APIs for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 2006-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -162,58 +162,72 @@ backendNetworkSideCB( case CUPS_ASN1_BOOLEAN : snprintf(dataptr, sizeof(data) - (dataptr - data), "%d", packet.object_value.boolean); + datalen += (int)strlen(dataptr); break; case CUPS_ASN1_INTEGER : snprintf(dataptr, sizeof(data) - (dataptr - data), "%d", packet.object_value.integer); + datalen += (int)strlen(dataptr); break; case CUPS_ASN1_BIT_STRING : case CUPS_ASN1_OCTET_STRING : - strlcpy(dataptr, packet.object_value.string, - sizeof(data) - (dataptr - data)); + i = (int)(sizeof(data) - (dataptr - data)); + if (packet.object_value.string.num_bytes < i) + i = packet.object_value.string.num_bytes; + + memcpy(dataptr, packet.object_value.string.bytes, i); + + datalen += i; break; case CUPS_ASN1_OID : _cupsSNMPOIDToString(packet.object_value.oid, dataptr, sizeof(data) - (dataptr - data)); + datalen += (int)strlen(dataptr); break; case CUPS_ASN1_HEX_STRING : for (i = 0; - i < packet.object_value.hex_string.num_bytes && + i < packet.object_value.string.num_bytes && dataptr < (data + sizeof(data) - 3); i ++, dataptr += 2) sprintf(dataptr, "%02X", - packet.object_value.hex_string.bytes[i]); + packet.object_value.string.bytes[i]); + datalen += (int)strlen(dataptr); break; case CUPS_ASN1_COUNTER : snprintf(dataptr, sizeof(data) - (dataptr - data), "%d", packet.object_value.counter); + datalen += (int)strlen(dataptr); break; case CUPS_ASN1_GAUGE : snprintf(dataptr, sizeof(data) - (dataptr - data), "%u", packet.object_value.gauge); + datalen += (int)strlen(dataptr); break; case CUPS_ASN1_TIMETICKS : snprintf(dataptr, sizeof(data) - (dataptr - data), "%u", packet.object_value.timeticks); + datalen += (int)strlen(dataptr); break; default : fprintf(stderr, "DEBUG: Unknown OID value type %02X!\n", packet.object_type); + + case CUPS_ASN1_NULL_VALUE : + dataptr[0] = '\0'; break; } fprintf(stderr, "DEBUG: Returning %s %s\n", data, data + datalen); - status = CUPS_SC_STATUS_OK; - datalen += (int)strlen(data + datalen); + status = CUPS_SC_STATUS_OK; } else fputs("DEBUG: SNMP read error...\n", stderr); @@ -246,7 +260,8 @@ backendNetworkSideCB( if (_cupsSNMPRead(snmp_fd, &packet, 1.0) && packet.object_type == CUPS_ASN1_OCTET_STRING) { - strlcpy(data, packet.object_value.string, sizeof(data)); + strlcpy(data, (char *)packet.object_value.string.bytes, + sizeof(data)); datalen = (int)strlen(data); status = CUPS_SC_STATUS_OK; } @@ -259,6 +274,7 @@ backendNetworkSideCB( { strlcpy(data, device_id, sizeof(data)); datalen = (int)strlen(data); + status = CUPS_SC_STATUS_OK; break; } diff --git a/backend/snmp-supplies.c b/backend/snmp-supplies.c index b63ed85c3..009c00602 100644 --- a/backend/snmp-supplies.c +++ b/backend/snmp-supplies.c @@ -3,7 +3,7 @@ * * SNMP supplies functions for the Common UNIX Printing System (CUPS). * - * Copyright 2008 by Apple Inc. + * Copyright 2008-2009 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -190,8 +190,8 @@ backendSNMPSupplies( packet.object_type != CUPS_ASN1_OCTET_STRING) return (-1); - i = ((packet.object_value.string[0] & 255) << 8) | - (packet.object_value.string[1] & 255); + i = (packet.object_value.string.bytes[0] << 8) | + packet.object_value.string.bytes[1]; if (i & CUPS_TC_lowPaper) fputs("STATE: +media-low-report\n", stderr); @@ -403,7 +403,8 @@ backend_init_supplies( num_supplies = 0; } else - strlcpy(description, packet.object_value.string, sizeof(description)); + strlcpy(description, (char *)packet.object_value.string.bytes, + sizeof(description)); /* * See if we have already queried this device... @@ -590,13 +591,13 @@ backend_walk_cb(cups_snmp_t *packet, /* I - SNMP packet */ i = packet->object_name[prtMarkerColorantValueOffset]; fprintf(stderr, "DEBUG2: prtMarkerColorantValue.1.%d = \"%s\"\n", i, - packet->object_value.string); + (char *)packet->object_value.string.bytes); for (j = 0; j < num_supplies; j ++) if (supplies[j].colorant == i) { for (k = 0; k < (int)(sizeof(colors) / sizeof(colors[0])); k ++) - if (!strcmp(colors[k][0], packet->object_value.string)) + if (!strcmp(colors[k][0], (char *)packet->object_value.string.bytes)) { strcpy(supplies[j].color, colors[k][1]); break; @@ -634,12 +635,12 @@ backend_walk_cb(cups_snmp_t *packet, /* I - SNMP packet */ return; fprintf(stderr, "DEBUG2: prtMarkerSuppliesDescription.1.%d = \"%s\"\n", i, - packet->object_value.string); + (char *)packet->object_value.string.bytes); if (i > num_supplies) num_supplies = i; - strlcpy(supplies[i - 1].name, packet->object_value.string, + strlcpy(supplies[i - 1].name, (char *)packet->object_value.string.bytes, sizeof(supplies[0].name)); } else if (_cupsSNMPIsOIDPrefixed(packet, prtMarkerSuppliesLevel)) diff --git a/backend/snmp.c b/backend/snmp.c index 692272474..0b7513d5b 100644 --- a/backend/snmp.c +++ b/backend/snmp.c @@ -3,7 +3,7 @@ * * SNMP discovery backend for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 2006-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -1015,18 +1015,18 @@ read_snmp_response(int fd) /* I - SNMP socket file descriptor */ char make_model[256]; /* Make and model */ - if (strchr(packet.object_value.string, ':') && - strchr(packet.object_value.string, ';')) + if (strchr((char *)packet.object_value.string.bytes, ':') && + strchr((char *)packet.object_value.string.bytes, ';')) { /* * Description is the IEEE-1284 device ID... */ if (!device->id) - device->id = strdup(packet.object_value.string); + device->id = strdup((char *)packet.object_value.string.bytes); - backendGetMakeModel(packet.object_value.string, make_model, - sizeof(make_model)); + backendGetMakeModel((char *)packet.object_value.string.bytes, + make_model, sizeof(make_model)); if (device->info) free(device->info); @@ -1039,13 +1039,13 @@ read_snmp_response(int fd) /* I - SNMP socket file descriptor */ * Description is plain text... */ - fix_make_model(make_model, packet.object_value.string, + fix_make_model(make_model, (char *)packet.object_value.string.bytes, sizeof(make_model)); if (device->info) free(device->info); - device->info = strdup(packet.object_value.string); + device->info = strdup((char *)packet.object_value.string.bytes); } if (!device->make_and_model) @@ -1066,14 +1066,14 @@ read_snmp_response(int fd) /* I - SNMP socket file descriptor */ if (device->id) free(device->id); - device->id = strdup(packet.object_value.string); + device->id = strdup((char *)packet.object_value.string.bytes); /* * Convert the ID to a make and model string... */ - backendGetMakeModel(packet.object_value.string, make_model, - sizeof(make_model)); + backendGetMakeModel((char *)packet.object_value.string.bytes, + make_model, sizeof(make_model)); if (device->make_and_model) free(device->make_and_model); @@ -1084,7 +1084,7 @@ read_snmp_response(int fd) /* I - SNMP socket file descriptor */ case DEVICE_LOCATION : if (device && packet.object_type == CUPS_ASN1_OCTET_STRING && !device->location) - device->location = strdup(packet.object_value.string); + device->location = strdup((char *)packet.object_value.string.bytes); break; case DEVICE_PRODUCT : @@ -1096,12 +1096,12 @@ read_snmp_response(int fd) /* I - SNMP socket file descriptor */ */ if (!device->info) - device->info = strdup(packet.object_value.string); + device->info = strdup((char *)packet.object_value.string.bytes); if (device->make_and_model) free(device->make_and_model); - device->make_and_model = strdup(packet.object_value.string); + device->make_and_model = strdup((char *)packet.object_value.string.bytes); } break; @@ -1113,16 +1113,16 @@ read_snmp_response(int fd) /* I - SNMP socket file descriptor */ * Update an existing cache entry... */ - if (!strncmp(packet.object_value.string, "lpr:", 4)) + if (!strncmp((char *)packet.object_value.string.bytes, "lpr:", 4)) { /* * We want "lpd://..." for the URI... */ - packet.object_value.string[2] = 'd'; + packet.object_value.string.bytes[2] = 'd'; } - device->uri = strdup(packet.object_value.string); + device->uri = strdup((char *)packet.object_value.string.bytes); } break; } diff --git a/cgi-bin/html.c b/cgi-bin/html.c index 2db9bdd25..5d0a39fdd 100644 --- a/cgi-bin/html.c +++ b/cgi-bin/html.c @@ -68,7 +68,10 @@ void cgiEndMultipart(void) { if (cgi_multipart) + { printf("\n%s--\n", cgi_multipart); + fflush(stdout); + } } @@ -190,8 +193,10 @@ cgiStartHTML(const char *title) /* I - Title of page */ void cgiStartMultipart(void) { - puts("MIME-Version: 1.0"); - puts("Content-Type: multipart/x-mixed-replace; boundary=\"CUPS-MULTIPART\"\n"); + puts("MIME-Version: 1.0\n" + "Content-Type: multipart/x-mixed-replace; boundary=\"CUPS-MULTIPART\"\n"); + fflush(stdout); + cgi_multipart = "--CUPS-MULTIPART"; } diff --git a/config-scripts/cups-dnssd.m4 b/config-scripts/cups-dnssd.m4 index a13006015..d35eb316c 100644 --- a/config-scripts/cups-dnssd.m4 +++ b/config-scripts/cups-dnssd.m4 @@ -32,17 +32,29 @@ if test x$enable_dnssd != xno; then case "$uname" in Darwin*) # Darwin and MacOS X... - DNSSDLIBS="-framework CoreFoundation -framework SystemConfiguration" AC_DEFINE(HAVE_DNSSD) AC_DEFINE(HAVE_COREFOUNDATION) AC_DEFINE(HAVE_SYSTEMCONFIGURATION) + DNSSDLIBS="-framework CoreFoundation -framework SystemConfiguration" DNSSD_BACKEND="dnssd" ;; *) # All others... - AC_CHECK_LIB(dns_sd,TXTRecordGetValuePtr, + AC_MSG_CHECKING(for current version of dns_sd library) + SAVELIBS="$LIBS" + LIBS="$LIBS -ldns_sd" + AC_TRY_COMPILE([#include num_constraints, constptr = consts->constraints; @@ -324,7 +325,12 @@ cupsResolveConflicts( * Is this the option we are changing? */ - if (option && !strcasecmp(constptr->option->keyword, option)) + if (option && + (!strcasecmp(constptr->option->keyword, option) || + (!strcasecmp(option, "PageSize") && + !strcasecmp(constptr->option->keyword, "PageRegion")) || + (!strcasecmp(option, "PageRegion") && + !strcasecmp(constptr->option->keyword, "PageSize")))) continue; /* @@ -334,10 +340,31 @@ cupsResolveConflicts( if ((value = cupsGetOption(constptr->option->keyword, num_newopts, newopts)) == NULL) { - marked = ppdFindMarkedChoice(ppd, constptr->option->keyword); - value = marked ? marked->choice : ""; + if (!strcasecmp(constptr->option->keyword, "PageSize") || + !strcasecmp(constptr->option->keyword, "PageRegion")) + { + if ((value = cupsGetOption("PageSize", num_newopts, + newopts)) == NULL) + value = cupsGetOption("PageRegion", num_newopts, newopts); + + if (!value) + { + if ((size = ppdPageSize(ppd, NULL)) != NULL) + value = size->name; + else + value = ""; + } + } + else + { + marked = ppdFindMarkedChoice(ppd, constptr->option->keyword); + value = marked ? marked->choice : ""; + } } + if (!strncasecmp(value, "Custom.", 7)) + value = "Custom"; + /* * Try the default choice... */ @@ -375,6 +402,7 @@ cupsResolveConflicts( if (strcasecmp(value, cptr->choice) && strcasecmp(constptr->option->defchoice, cptr->choice) && + strcasecmp("Custom", cptr->choice) && (test = ppd_test_constraints(ppd, constptr->option->keyword, cptr->choice, num_newopts, newopts, @@ -438,6 +466,13 @@ cupsResolveConflicts( cupsArrayRestore(ppd->sorted_attrs); + DEBUG_printf(("cupsResolveConflicts: Returning %d options:", num_newopts)); +#ifdef DEBUG + for (i = 0; i < num_newopts; i ++) + DEBUG_printf(("cupsResolveConflicts: options[%d]: %s=%s", i, + newopts[i].name, newopts[i].value)); +#endif /* DEBUG */ + return (1); /* @@ -453,6 +488,8 @@ cupsResolveConflicts( cupsArrayRestore(ppd->sorted_attrs); + DEBUG_puts("cupsResolveConflicts: Unable to resolve conflicts!"); + return (0); } @@ -847,7 +884,6 @@ ppd_test_constraints( *marked; /* Marked choice */ cups_array_t *active = NULL; /* Active constraints */ const char *value; /* Current value */ - int option_conflict;/* Conflict with current option? */ DEBUG_printf(("ppd_test_constraints(ppd=%p, num_options=%d, options=%p, " @@ -881,8 +917,7 @@ ppd_test_constraints( DEBUG_puts("ppd_test_constraints: Testing..."); - for (i = consts->num_constraints, constptr = consts->constraints, - option_conflict = 0; + for (i = consts->num_constraints, constptr = consts->constraints; i > 0; i --, constptr ++) { @@ -904,9 +939,6 @@ ppd_test_constraints( !strcasecmp(option, "PageRegion"))) { value = choice; - - if (!strcasecmp(value, constptr->choice->choice)) - option_conflict = 1; } else if ((value = cupsGetOption("PageSize", num_options, options)) == NULL) @@ -920,6 +952,9 @@ ppd_test_constraints( value = size->name; } + if (value && !strncasecmp(value, "Custom.", 7)) + value = "Custom"; + if (!value || strcasecmp(value, constptr->choice->choice)) { DEBUG_puts("ppd_test_constraints: NO"); @@ -930,14 +965,23 @@ ppd_test_constraints( { if (option && choice && !strcasecmp(option, constptr->option->keyword)) { - if (strcasecmp(choice, constptr->choice->choice)) - break; + if (!strncasecmp(choice, "Custom.", 7)) + value = "Custom"; + else + value = choice; - option_conflict = 1; + if (strcasecmp(value, constptr->choice->choice)) + { + DEBUG_puts("ppd_test_constraints: NO"); + break; + } } else if ((value = cupsGetOption(constptr->option->keyword, num_options, options)) != NULL) { + if (!strncasecmp(value, "Custom.", 7)) + value = "Custom"; + if (strcasecmp(value, constptr->choice->choice)) { DEBUG_puts("ppd_test_constraints: NO"); @@ -955,9 +999,10 @@ ppd_test_constraints( { if (!strcasecmp(choice, "None") || !strcasecmp(choice, "Off") || !strcasecmp(choice, "False")) + { + DEBUG_puts("ppd_test_constraints: NO"); break; - - option_conflict = 1; + } } else if ((value = cupsGetOption(constptr->option->keyword, num_options, options)) != NULL) @@ -985,7 +1030,7 @@ ppd_test_constraints( } } - if (i <= 0 && (!option || option_conflict)) + if (i <= 0) { if (!active) active = cupsArrayNew(NULL, NULL); diff --git a/cups/dest.c b/cups/dest.c index eab2eb587..f2dde4dda 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -1703,7 +1703,6 @@ cups_get_sdests(http_t *http, /* I - Connection to server or CUPS_HTTP_DEFA int num_dests, /* I - Number of destinations */ cups_dest_t **dests) /* IO - Destinations */ { - int i; /* Looping var */ cups_dest_t *dest; /* Current destination */ ipp_t *request, /* IPP Request */ *response; /* IPP Response */ @@ -1721,6 +1720,7 @@ cups_get_sdests(http_t *http, /* I - Connection to server or CUPS_HTTP_DEFA static const char * const pattrs[] = /* Attributes we're interested in */ { "auth-info-required", + "device-uri", "job-sheets-default", "marker-change-time", "marker-colors", @@ -1734,6 +1734,7 @@ cups_get_sdests(http_t *http, /* I - Connection to server or CUPS_HTTP_DEFA "media-supported", #endif /* __APPLE__ */ "printer-commands", + "printer-defaults", "printer-info", "printer-is-accepting-jobs", "printer-is-shared", @@ -1744,7 +1745,7 @@ cups_get_sdests(http_t *http, /* I - Connection to server or CUPS_HTTP_DEFA "printer-state-change-time", "printer-state-reasons", "printer-type", - "printer-defaults" + "printer-uri-supported" }; @@ -1819,10 +1820,12 @@ cups_get_sdests(http_t *http, /* I - Connection to server or CUPS_HTTP_DEFA attr->value_tag != IPP_TAG_NAME && attr->value_tag != IPP_TAG_NAMELANG && attr->value_tag != IPP_TAG_KEYWORD && - attr->value_tag != IPP_TAG_RANGE) + attr->value_tag != IPP_TAG_RANGE && + attr->value_tag != IPP_TAG_URI) continue; if (!strcmp(attr->name, "auth-info-required") || + !strcmp(attr->name, "device-uri") || !strcmp(attr->name, "marker-change-time") || !strcmp(attr->name, "marker-colors") || !strcmp(attr->name, "marker-high-levels") || @@ -1840,7 +1843,8 @@ cups_get_sdests(http_t *http, /* I - Connection to server or CUPS_HTTP_DEFA !strcmp(attr->name, "printer-type") || !strcmp(attr->name, "printer-is-accepting-jobs") || !strcmp(attr->name, "printer-location") || - !strcmp(attr->name, "printer-state-reasons")) + !strcmp(attr->name, "printer-state-reasons") || + !strcmp(attr->name, "printer-uri-supported")) { /* * Add a printer description attribute... @@ -1858,6 +1862,8 @@ cups_get_sdests(http_t *http, /* I - Connection to server or CUPS_HTTP_DEFA * See if we can set a default media size... */ + int i; /* Looping var */ + for (i = 0; i < attr->num_values; i ++) if (!strcasecmp(media_default, attr->values[i].string.text)) { diff --git a/cups/encode.c b/cups/encode.c index 16762aa0c..f098844e6 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -54,6 +54,7 @@ static const _ipp_option_t ipp_options[] = { 0, "compression", IPP_TAG_KEYWORD, IPP_TAG_OPERATION }, { 0, "copies", IPP_TAG_INTEGER, IPP_TAG_JOB }, { 0, "copies-default", IPP_TAG_INTEGER, IPP_TAG_PRINTER }, + { 0, "device-uri", IPP_TAG_URI, IPP_TAG_PRINTER }, { 0, "document-format", IPP_TAG_MIMETYPE, IPP_TAG_OPERATION }, { 0, "document-format-default", IPP_TAG_MIMETYPE, IPP_TAG_PRINTER }, { 1, "exclude-schemes", IPP_TAG_NAME, IPP_TAG_OPERATION }, @@ -145,6 +146,7 @@ static const _ipp_option_t ipp_options[] = { 1, "printer-state-reasons", IPP_TAG_KEYWORD, IPP_TAG_PRINTER }, { 0, "printer-type", IPP_TAG_ENUM, IPP_TAG_PRINTER }, { 0, "printer-uri", IPP_TAG_URI, IPP_TAG_OPERATION }, + { 1, "printer-uri-supported", IPP_TAG_URI, IPP_TAG_PRINTER }, { 0, "queued-job-count", IPP_TAG_INTEGER, IPP_TAG_PRINTER }, { 0, "raw", IPP_TAG_MIMETYPE, IPP_TAG_OPERATION }, { 1, "requested-attributes", IPP_TAG_NAME, IPP_TAG_OPERATION }, diff --git a/cups/http.c b/cups/http.c index 439f180f3..459730ef9 100644 --- a/cups/http.c +++ b/cups/http.c @@ -1459,7 +1459,7 @@ httpRead2(http_t *http, /* I - Connection to server */ bytes = (ssize_t)recv(http->fd, buffer, (int)length, 0); #else while ((bytes = recv(http->fd, buffer, length, 0)) < 0) - if (errno != EINTR) + if (errno != EINTR && errno != EAGAIN) break; #endif /* WIN32 */ @@ -1481,7 +1481,7 @@ httpRead2(http_t *http, /* I - Connection to server */ #ifdef WIN32 http->error = WSAGetLastError(); #else - if (errno == EINTR) + if (errno == EINTR || errno == EAGAIN) bytes = 0; else http->error = errno; diff --git a/cups/ipp.c b/cups/ipp.c index f8e7dafa6..a6c640856 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -3063,7 +3063,18 @@ ipp_read_http(http_t *http, /* I - Client connection */ } } - if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) <= 0) + if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) < 0) + { +#ifdef WIN32 + break; +#else + if (errno != EAGAIN && errno != EINTR) + break; + + bytes = 0; +#endif /* WIN32 */ + } + else if (bytes == 0) break; } } diff --git a/cups/mark.c b/cups/mark.c index b2cef1f2d..84836390e 100644 --- a/cups/mark.c +++ b/cups/mark.c @@ -461,13 +461,24 @@ ppd_choice_t * /* O - Pointer to choice or @code NULL@ */ ppdFindMarkedChoice(ppd_file_t *ppd, /* I - PPD file */ const char *option) /* I - Keyword/option name */ { - ppd_choice_t key; /* Search key for choice */ + ppd_choice_t key, /* Search key for choice */ + *marked; /* Marked choice */ + DEBUG_printf(("ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option)); + if ((key.option = ppdFindOption(ppd, option)) == NULL) + { + DEBUG_puts("ppdFindMarkedChoice: Option not found, returning NULL"); return (NULL); + } + + marked = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key); + + DEBUG_printf(("ppdFindMarkedChoice: Returning %p(%s)...", marked, + marked ? marked->choice : "NULL")); - return ((ppd_choice_t *)cupsArrayFind(ppd->marked, &key)); + return (marked); } diff --git a/cups/page.c b/cups/page.c index 2b59c1e72..b99b54a1e 100644 --- a/cups/page.c +++ b/cups/page.c @@ -3,7 +3,7 @@ * * Page size functions for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -30,6 +30,7 @@ #include "ppd.h" #include "string.h" #include +#include "debug.h" /* @@ -49,8 +50,13 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */ ppd_cparam_t *cparam; /* Custom option parameter */ + DEBUG_printf(("ppdPageSize(ppd=%p, name=\"%s\")", ppd, name)); + if (!ppd) + { + DEBUG_puts("ppdPageSize: Bad PPD pointer, returning NULL..."); return (NULL); + } if (name) { @@ -65,7 +71,10 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */ break; if (!i) + { + DEBUG_puts("ppdPageSize: No custom sizes, returning NULL..."); return (NULL); + } /* * Variable size; size name can be one of the following: @@ -135,6 +144,9 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */ * Return the page size... */ + DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size, + size->name, size->width, size->length)); + return (size); } else @@ -144,8 +156,13 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */ */ for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++) - if (!strcmp(name, size->name)) + if (!strcasecmp(name, size->name)) + { + DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size, + size->name, size->width, size->length)); + return (size); + } } } else @@ -156,9 +173,16 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */ for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++) if (size->marked) + { + DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size, + size->name, size->width, size->length)); + return (size); + } } + DEBUG_puts("ppdPageSize: Size not found, returning NULL"); + return (NULL); } diff --git a/cups/sidechannel.c b/cups/sidechannel.c index ccf1d1904..585d6cbc7 100644 --- a/cups/sidechannel.c +++ b/cups/sidechannel.c @@ -3,7 +3,7 @@ * * Side-channel API code for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -427,6 +427,9 @@ cupsSideChannelSNMPWalk( return (CUPS_SC_STATUS_OK); } + if (real_datalen < sizeof(real_data)) + real_data[real_datalen] = '\0'; + real_oidlen = strlen(real_data) + 1; real_datalen -= real_oidlen; diff --git a/cups/snmp-private.h b/cups/snmp-private.h index de6d0f6f3..1745b9259 100644 --- a/cups/snmp-private.h +++ b/cups/snmp-private.h @@ -6,7 +6,7 @@ * This API is PRIVATE and subject to change. No third-party applications * should use the SNMP API defined in this file. * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 2006-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -64,12 +64,12 @@ enum cups_asn1_e /**** ASN1 request/object types ****/ }; typedef enum cups_asn1_e cups_asn1_t; /**** ASN1 request/object types ****/ -struct cups_snmp_hexstring_s /**** Hex-STRING value ****/ +typedef struct cups_snmp_string_s /**** String value ****/ { unsigned char bytes[CUPS_SNMP_MAX_STRING]; /* Bytes in string */ int num_bytes; /* Number of bytes */ -}; +} cups_snmp_string_t; union cups_snmp_value_u /**** Object value ****/ { @@ -79,10 +79,7 @@ union cups_snmp_value_u /**** Object value ****/ unsigned gauge; /* Gauge value */ unsigned timeticks; /* Timeticks value */ int oid[CUPS_SNMP_MAX_OID]; /* OID value */ - char string[CUPS_SNMP_MAX_STRING]; - /* String value */ - struct cups_snmp_hexstring_s hex_string; - /* Hex string value */ + cups_snmp_string_t string; /* String value */ }; typedef struct cups_snmp_s /**** SNMP data packet ****/ diff --git a/cups/snmp.c b/cups/snmp.c index 69a91ac51..847f7c0d8 100644 --- a/cups/snmp.c +++ b/cups/snmp.c @@ -3,7 +3,7 @@ * * SNMP functions for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 2006-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -1079,8 +1079,11 @@ asn1_decode_snmp(unsigned char *buffer, /* I - Buffer */ break; case CUPS_ASN1_OCTET_STRING : + case CUPS_ASN1_BIT_STRING : + case CUPS_ASN1_HEX_STRING : + packet->object_value.string.num_bytes = length; asn1_get_string(&bufptr, bufend, length, - packet->object_value.string, + (char *)packet->object_value.string.bytes, CUPS_SNMP_MAX_STRING); break; @@ -1089,14 +1092,6 @@ asn1_decode_snmp(unsigned char *buffer, /* I - Buffer */ packet->object_value.oid, CUPS_SNMP_MAX_OID); break; - case CUPS_ASN1_HEX_STRING : - packet->object_value.hex_string.num_bytes = length; - - asn1_get_string(&bufptr, bufend, length, - (char *)packet->object_value.hex_string.bytes, - CUPS_SNMP_MAX_STRING); - break; - case CUPS_ASN1_COUNTER : packet->object_value.counter = asn1_get_integer(&bufptr, bufend, length); @@ -1169,7 +1164,7 @@ asn1_encode_snmp(unsigned char *buffer, /* I - Buffer */ break; case CUPS_ASN1_OCTET_STRING : - valuelen = strlen(packet->object_value.string); + valuelen = packet->object_value.string.num_bytes; break; case CUPS_ASN1_OID : @@ -1254,7 +1249,7 @@ asn1_encode_snmp(unsigned char *buffer, /* I - Buffer */ case CUPS_ASN1_OCTET_STRING : *bufptr++ = CUPS_ASN1_OCTET_STRING; asn1_set_length(&bufptr, valuelen); - memcpy(bufptr, packet->object_value.string, valuelen); + memcpy(bufptr, packet->object_value.string.bytes, valuelen); bufptr += valuelen; break; diff --git a/cups/testconflicts.c b/cups/testconflicts.c index 291739a26..0d7531bdb 100644 --- a/cups/testconflicts.c +++ b/cups/testconflicts.c @@ -36,7 +36,10 @@ main(int argc, /* I - Number of command-line arguments */ { int i; /* Looping var */ ppd_file_t *ppd; /* PPD file loaded from disk */ - char line[256]; /* Input buffer */ + char line[256], /* Input buffer */ + *ptr, /* Pointer into buffer */ + *optr, /* Pointer to first option name */ + *cptr; /* Pointer to first choice */ int num_options; /* Number of options */ cups_option_t *options; /* Options */ char *option, /* Current option */ @@ -73,11 +76,12 @@ main(int argc, /* I - Number of command-line arguments */ if (!cupsResolveConflicts(ppd, option, choice, &num_options, &options)) puts("Unable to resolve conflicts!"); - else if (num_options > 0) + else if ((!option && num_options > 0) || (option && num_options > 1)) { fputs("Resolved conflicts with the following options:\n ", stdout); for (i = 0; i < num_options; i ++) - printf(" %s=%s", options[i].name, options[i].value); + if (!option || strcasecmp(option, options[i].name)) + printf(" %s=%s", options[i].name, options[i].value); putchar('\n'); cupsFreeOptions(num_options, options); @@ -94,13 +98,20 @@ main(int argc, /* I - Number of command-line arguments */ if (!fgets(line, sizeof(line), stdin) || line[0] == '\n') break; - num_options = cupsParseOptions(line, 0, &options); - if (num_options > 0) - { - option = strdup(options[0].name); - choice = strdup(options[0].value); - } + for (ptr = line; isspace(*ptr & 255); ptr ++); + for (optr = ptr; *ptr && *ptr != '='; ptr ++); + if (!*ptr) + break; + for (*ptr++ = '\0', cptr = ptr; *ptr && !isspace(*ptr & 255); ptr ++); + if (!*ptr) + break; + *ptr++ = '\0'; + + option = strdup(optr); + choice = strdup(cptr); + num_options = cupsParseOptions(ptr, 0, &options); + ppdMarkOption(ppd, option, choice); if (cupsMarkOptions(ppd, num_options, options)) puts("Options Conflict!"); cupsFreeOptions(num_options, options); diff --git a/cups/testppd.c b/cups/testppd.c index 44c43b55b..9af38ee0a 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -774,6 +774,7 @@ main(int argc, /* I - Number of command-line arguments */ else { const char *filename; /* PPD filename */ + struct stat fileinfo; /* File information */ if (!strncmp(argv[1], "-d", 2)) @@ -788,6 +789,33 @@ main(int argc, /* I - Number of command-line arguments */ else filename = argv[1]; + if (lstat(filename, &fileinfo)) + { + printf("%s: %s\n", filename, strerror(errno)); + return (1); + } + + if (S_ISLNK(fileinfo.st_mode)) + { + char realfile[1024]; /* Real file path */ + ssize_t realsize; /* Size of real file path */ + + + if ((realsize = readlink(filename, realfile, sizeof(realfile) - 1)) < 0) + strcpy(realfile, "Unknown"); + else + realfile[realsize] = '\0'; + + if (stat(realfile, &fileinfo)) + printf("%s: symlink to \"%s\", %s\n", filename, realfile, + strerror(errno)); + else + printf("%s: symlink to \"%s\", %ld bytes\n", filename, realfile, + (long)fileinfo.st_size); + } + else + printf("%s: regular file, %ld bytes\n", filename, (long)fileinfo.st_size); + if ((ppd = ppdOpenFile(filename)) == NULL) { ppd_status_t err; /* Last error in file */ diff --git a/cups/testsnmp.c b/cups/testsnmp.c index fbbc30929..52983a968 100644 --- a/cups/testsnmp.c +++ b/cups/testsnmp.c @@ -3,7 +3,7 @@ * * SNMP test program for the Common UNIX Printing System (CUPS). * - * Copyright 2008 by Apple Inc. + * Copyright 2008-2009 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -155,11 +155,13 @@ print_packet(cups_snmp_t *packet, /* I - SNMP response packet */ break; case CUPS_ASN1_BIT_STRING : - printf("BIT-STRING \"%s\"\n", packet->object_value.string); + printf("BIT-STRING \"%s\"\n", + (char *)packet->object_value.string.bytes); break; case CUPS_ASN1_OCTET_STRING : - printf("OCTET-STRING \"%s\"\n", packet->object_value.string); + printf("OCTET-STRING \"%s\"\n", + (char *)packet->object_value.string.bytes); break; case CUPS_ASN1_NULL_VALUE : @@ -173,8 +175,8 @@ print_packet(cups_snmp_t *packet, /* I - SNMP response packet */ case CUPS_ASN1_HEX_STRING : fputs("Hex-STRING", stdout); - for (i = 0; i < packet->object_value.hex_string.num_bytes; i ++) - printf(" %02X", packet->object_value.hex_string.bytes[i]); + for (i = 0; i < packet->object_value.string.num_bytes; i ++) + printf(" %02X", packet->object_value.string.bytes[i]); putchar('\n'); break; diff --git a/cups/util.c b/cups/util.c index 30c0f5490..57340e6a9 100644 --- a/cups/util.c +++ b/cups/util.c @@ -3,7 +3,7 @@ * * Printing utilities for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -951,7 +951,8 @@ cupsGetPPD3(http_t *http, /* I - HTTP connection or @code CUPS_HTTP_DEFAUL struct stat ppdinfo; /* PPD file information */ - snprintf(ppdname, sizeof(ppdname), "%s/%s.ppd", cg->cups_serverroot, name); + snprintf(ppdname, sizeof(ppdname), "%s/ppd/%s.ppd", cg->cups_serverroot, + name); if (!stat(ppdname, &ppdinfo)) { /* @@ -1030,7 +1031,7 @@ cupsGetPPD3(http_t *http, /* I - HTTP connection or @code CUPS_HTTP_DEFAUL } } - if (*modtime <= ppdinfo.st_mtime) + if (*modtime >= ppdinfo.st_mtime) return (HTTP_NOT_MODIFIED); else { diff --git a/filter/pdftops.c b/filter/pdftops.c index 69ed05ab6..7e67895ba 100644 --- a/filter/pdftops.c +++ b/filter/pdftops.c @@ -4,7 +4,7 @@ * PDF to PostScript filter front-end for the Common UNIX Printing * System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -69,12 +69,8 @@ main(int argc, /* I - Number of command-line args */ pdfstatus, /* Status from pdftops */ pdfargc; /* Number of args for pdftops */ char *pdfargv[100], /* Arguments for pdftops/gs */ -#ifdef HAVE_PDFTOPS pdfwidth[255], /* Paper width */ pdfheight[255]; /* Paper height */ -#else - pdfgeometry[255]; /* Paper width and height */ -#endif /* HAVE_PDFTOPS */ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Actions for POSIX signals */ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ @@ -215,7 +211,11 @@ main(int argc, /* I - Number of command-line args */ */ size = ppdPageSize(ppd, NULL); - if (size) + if (size && + (cupsGetOption("media", num_options, options) || + cupsGetOption("media-col", num_options, options) || + cupsGetOption("PageRegion", num_options, options) || + cupsGetOption("PageSize", num_options, options)) { /* * Got the size, now get the orientation... @@ -261,25 +261,35 @@ main(int argc, /* I - Number of command-line args */ pdfargv[pdfargc++] = pdfwidth; pdfargv[pdfargc++] = (char *)"-paperh"; pdfargv[pdfargc++] = pdfheight; + + if ((val = cupsGetOption("fitplot", num_options, options)) != NULL && + strcasecmp(val, "no") && strcasecmp(val, "off") && + strcasecmp(val, "false")) + pdfargv[pdfargc++] = (char *)"-expand"; + #else if (orientation & 1) - snprintf(pdfgeometry, sizeof(pdfgeometry), "-g%.0fx%.0f", size->length, + { + snprintf(pdfwidth, sizeof(pdfwidth), "-dDEVICEWIDTHPOINTS=%.0f", + size->length); + snprintf(pdfheight, sizeof(pdfheight), "-dDEVICEHEIGHTPOINTS=%.0f", size->width); + } else - snprintf(pdfgeometry, sizeof(pdfgeometry), "-g%.0fx%.0f", size->width, + { + snprintf(pdfwidth, sizeof(pdfwidth), "-dDEVICEWIDTHPOINTS=%.0f", + size->width); + snprintf(pdfheight, sizeof(pdfheight), "-dDEVICEHEIGHTPOINTS=%.0f", size->length); + } - pdfargv[pdfargc++] = pdfgeometry; + pdfargv[pdfargc++] = pdfwidth; + pdfargv[pdfargc++] = pdfheight; #endif /* HAVE_PDFTOPS */ } } #ifdef HAVE_PDFTOPS - if ((val = cupsGetOption("fitplot", num_options, options)) != NULL && - strcasecmp(val, "no") && strcasecmp(val, "off") && - strcasecmp(val, "false")) - pdfargv[pdfargc++] = (char *)"-expand"; - pdfargv[pdfargc++] = filename; pdfargv[pdfargc++] = (char *)"-"; #else diff --git a/ppdc/ppdc-driver.cxx b/ppdc/ppdc-driver.cxx index 31c857f06..2321000a2 100644 --- a/ppdc/ppdc-driver.cxx +++ b/ppdc/ppdc-driver.cxx @@ -945,7 +945,7 @@ ppdcDriver::write_ppd_file( continue; if (!o->text->value || !strcmp(o->name->value, o->text->value)) - cupsFilePrintf(fp, "*OpenUI *%s: ", o->name->value, + cupsFilePrintf(fp, "*OpenUI *%s/%s: ", o->name->value, catalog->find_message(o->name->value)); else cupsFilePrintf(fp, "*OpenUI *%s/%s: ", o->name->value, diff --git a/scheduler/classes.c b/scheduler/classes.c index 5e53c8577..87a55f157 100644 --- a/scheduler/classes.c +++ b/scheduler/classes.c @@ -287,7 +287,7 @@ cupsdLoadAllClasses(void) { cups_file_t *fp; /* classes.conf file */ int linenum; /* Current line number */ - char line[1024], /* Line from file */ + char line[4096], /* Line from file */ *value, /* Pointer to value */ *valueptr; /* Pointer into value */ cupsd_printer_t *p, /* Current printer class */ diff --git a/scheduler/client.c b/scheduler/client.c index f49ce4533..a00ee62f7 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -3,7 +3,7 @@ * * Client routines for the Common UNIX Printing System (CUPS) scheduler. * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * This file contains Kerberos support code, copyright 2006 by @@ -283,16 +283,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */ * Map accesses from the same host to the server name. */ - for (addr = ServerAddrs; addr; addr = addr->next) - if (httpAddrEqual(con->http.hostaddr, &(addr->addr))) - break; - - if (addr) - { - strlcpy(con->http.hostname, ServerName, sizeof(con->http.hostname)); - hostname = con->http.hostname; - } - else if (HostNameLookups) + if (HostNameLookups) hostname = httpAddrLookup(con->http.hostaddr, con->http.hostname, sizeof(con->http.hostname)); else @@ -2778,6 +2769,7 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ buf[bytes] = '\0'; for (bufptr = buf; !con->got_fields && *bufptr; bufptr ++) + { if (*bufptr == '\n') { /* @@ -2788,7 +2780,7 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ bufptr[-1] = '\0'; *bufptr++ = '\0'; - cupsdLogMessage(CUPSD_LOG_DEBUG2, "Script header: %s", buf); + cupsdLogMessage(CUPSD_LOG_DEBUG, "Script header: %s", buf); if (!con->sent_header) { @@ -2833,7 +2825,12 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ */ bytes -= (bufptr - buf); - memmove(buf, bufptr, bytes + 1); + + if (bytes > 0) + memmove(buf, bufptr, bytes + 1); + else + buf[0] = '\0'; + bufptr = buf - 1; /* @@ -2858,6 +2855,7 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ } else if (*bufptr != '\r') con->field_col ++; + } cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdWriteClient: %d bytes=%d, got_fields=%d", diff --git a/scheduler/client.h b/scheduler/client.h index 6ea720889..3e447aeb0 100644 --- a/scheduler/client.h +++ b/scheduler/client.h @@ -3,7 +3,7 @@ * * Client definitions for the Common UNIX Printing System (CUPS) scheduler. * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -98,8 +98,6 @@ VAR cups_array_t *Clients VALUE(NULL), /* HTTP clients */ *ActiveClients VALUE(NULL); /* Active HTTP clients */ -VAR http_addrlist_t *ServerAddrs VALUE(NULL); - /* Server address(es) */ VAR char *ServerHeader VALUE(NULL); /* Server header in requests */ VAR int CGIPipes[2] VALUE2(-1,-1); diff --git a/scheduler/conf.c b/scheduler/conf.c index 1f44e61af..3d8b14b07 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -3,7 +3,7 @@ * * Configuration routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -264,7 +264,8 @@ cupsdCheckPermissions( return (-1); } - dir_created = 1; + dir_created = 1; + fileinfo.st_mode = mode | S_IFDIR; } else return (create_dir ? -1 : 1); @@ -425,12 +426,14 @@ cupsdReadConfiguration(void) cupsdDeleteAllListeners(); + RemoteAccessEnabled = 0; + /* * String options... */ - cupsdSetString(&ServerName, httpGetHostname(NULL, temp, sizeof(temp))); - cupsdSetStringf(&ServerAdmin, "root@%s", temp); + cupsdClearString(&ServerName); + cupsdClearString(&ServerAdmin); cupsdSetString(&ServerBin, CUPS_SERVERBIN); cupsdSetString(&RequestRoot, CUPS_REQUESTS); cupsdSetString(&CacheDir, CUPS_CACHEDIR); @@ -656,14 +659,38 @@ cupsdReadConfiguration(void) RunUser = getuid(); + cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.", + RemoteAccessEnabled ? "enabled" : "disabled"); + /* * See if the ServerName is an IP address... */ + if (!ServerName) + { + if (HostNameLookups || RemoteAccessEnabled) + httpGetHostname(NULL, temp, sizeof(temp)); + else if (gethostname(temp, sizeof(temp))) + { + cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get hostname: %s", + strerror(errno)); + strlcpy(temp, "localhost", sizeof(temp)); + } + + cupsdSetString(&ServerName, temp); + } + for (slash = ServerName; isdigit(*slash & 255) || *slash == '.'; slash ++); ServerNameIsIP = !*slash; + /* + * Make sure ServerAdmin is initialized... + */ + + if (!ServerAdmin) + cupsdSetStringf(&ServerAdmin, "root@%s", ServerName); + /* * Use the default system group if none was supplied in cupsd.conf... */ @@ -2451,6 +2478,9 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ #endif /* AF_LOCAL */ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp, ntohs(lis->address.ipv4.sin_port)); + + if (!httpAddrLocalhost(&(lis->address))) + RemoteAccessEnabled = 1; } /* diff --git a/scheduler/conf.h b/scheduler/conf.h index 1d534fbca..025f6a915 100644 --- a/scheduler/conf.h +++ b/scheduler/conf.h @@ -95,7 +95,10 @@ VAR char *ConfigurationFile VALUE(NULL), /* Directory for request files */ *DocumentRoot VALUE(NULL); /* Root directory for documents */ -VAR int ServerNameIsIP VALUE(0); +VAR int RemoteAccessEnabled VALUE(0), + /* Are we listening on non-local addresses? */ + ServerNameIsIP VALUE(0); + /* Is the ServerName an IP address? */ VAR int NumSystemGroups VALUE(0); /* Number of system group names */ VAR char *SystemGroups[MAX_SYSTEM_GROUPS] @@ -160,7 +163,7 @@ VAR int AccessLogLevel VALUE(CUPSD_ACCESSLOG_ACTIONS), /* Permissions for log files */ LogLevel VALUE(CUPSD_LOG_WARN), /* Error log level */ - MaxClients VALUE(0), + MaxClients VALUE(100), /* Maximum number of clients */ MaxClientsPerHost VALUE(0), /* Maximum number of clients per host */ diff --git a/scheduler/cups-driverd.cxx b/scheduler/cups-driverd.cxx index 1b551c09e..4cc80c706 100644 --- a/scheduler/cups-driverd.cxx +++ b/scheduler/cups-driverd.cxx @@ -331,8 +331,8 @@ cat_drv(const char *name, /* I - PPD name */ for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next()) - if (!strcasecmp(pc_file_name, d->pc_file_name->value) || - (d->file_name && !strcasecmp(pc_file_name, d->file_name->value))) + if (!strcmp(pc_file_name, d->pc_file_name->value) || + (d->file_name && !strcmp(pc_file_name, d->file_name->value))) break; if (d) @@ -678,10 +678,10 @@ compare_names(const ppd_info_t *p0, /* I - First PPD file */ int diff; /* Difference between strings */ - if ((diff = strcasecmp(p0->record.filename, p1->record.filename)) != 0) + if ((diff = strcmp(p0->record.filename, p1->record.filename)) != 0) return (diff); else - return (strcasecmp(p0->record.name, p1->record.name)); + return (strcmp(p0->record.name, p1->record.name)); } @@ -706,8 +706,7 @@ compare_ppds(const ppd_info_t *p0, /* I - First PPD file */ p1->record.make_and_model)) != 0) return (diff); else - return (strcasecmp(p0->record.languages[0], - p1->record.languages[0])); + return (strcmp(p0->record.languages[0], p1->record.languages[0])); } @@ -1111,7 +1110,7 @@ list_ppds(int request_id, /* I - Request ID */ { for (i = 0; i < PPD_MAX_LANG; i ++) if (!ppd->record.languages[i][0] || - !strcasecmp(ppd->record.languages[i], language)) + !strcmp(ppd->record.languages[i], language)) { ppd->matches ++; break; @@ -1453,7 +1452,7 @@ load_ppds(const char *d, /* I - Actual directory */ ppd->found = 1; } while ((ppd = (ppd_info_t *)cupsArrayNext(PPDsByName)) != NULL && - !strcasecmp(ppd->record.filename, name)); + !strcmp(ppd->record.filename, name)); continue; } @@ -1725,7 +1724,7 @@ load_ppds(const char *d, /* I - Actual directory */ } for (i = 0; i < (int)(sizeof(languages) / sizeof(languages[0])); i ++) - if (!strcasecmp(languages[i].version, lang_version)) + if (!strcmp(languages[i].version, lang_version)) break; if (i < (int)(sizeof(languages) / sizeof(languages[0]))) diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index d51f54630..54749128a 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -3,7 +3,7 @@ * * Directory services routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -283,7 +283,7 @@ cupsdLoadRemoteCache(void) { cups_file_t *fp; /* remote.cache file */ int linenum; /* Current line number */ - char line[1024], /* Line from file */ + char line[4096], /* Line from file */ *value, /* Pointer to value */ *valueptr, /* Pointer into value */ scheme[32], /* Scheme portion of URI */ @@ -2217,6 +2217,7 @@ dnssdBuildTxtRecord( rp_str[1024], /* Queue name string buffer */ air_str[1024], /* auth-info-required string buffer */ *keyvalue[32][2]; /* Table of key/value pairs */ + ipp_attribute_t *air_attr; /* auth-info-required attribute */ /* @@ -2326,12 +2327,14 @@ dnssdBuildTxtRecord( keyvalue[i ][0] = "pdl"; keyvalue[i++][1] = p->pdl ? p->pdl : "application/postscript"; - if (p->num_auth_info_required) + if ((air_attr = ippFindAttribute(p->attrs, "auth-info-required", + IPP_TAG_KEYWORD)) != NULL && + strcmp(air_attr->values[0].string.text, "none")) { char *air = air_str; /* Pointer into string */ - for (j = 0; j < p->num_auth_info_required; j ++) + for (j = 0; j < air_attr->num_values; j ++) { if (air >= (air_str + sizeof(air_str) - 2)) break; @@ -2339,7 +2342,8 @@ dnssdBuildTxtRecord( if (j) *air++ = ','; - strlcpy(air, p->auth_info_required[j], sizeof(air_str) - (air - air_str)); + strlcpy(air, air_attr->values[j].string.text, + sizeof(air_str) - (air - air_str)); air += strlen(air); } diff --git a/scheduler/ipp.c b/scheduler/ipp.c index e9e3e73f4..a867cbbc8 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -711,6 +711,11 @@ cupsdProcessIPPRequest( uri ? uri->values[0].string.text : "no URI", con->http.hostname); + if (LogLevel == CUPSD_LOG_DEBUG2) + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdProcessIPPRequest: ippLength(response)=%ld", + (long)ippLength(con->response)); + if (cupsdSendHeader(con, HTTP_OK, "application/ipp", CUPSD_AUTH_NONE)) { #ifdef CUPSD_USE_CHUNKING @@ -3413,8 +3418,8 @@ apple_register_profiles( * Use the default colorspace... */ - num_profiles = 1 + ppd->colorspace != PPD_CS_GRAY; - + num_profiles = 2; + if ((profiles = calloc(num_profiles, sizeof(CMDeviceProfileArray))) == NULL) { cupsdLogMessage(CUPSD_LOG_ERROR, @@ -3443,13 +3448,11 @@ apple_register_profiles( break; case PPD_CS_N : + default : apple_init_profile(ppd, NULL, profiles->profiles + 1, _ppdHashName("DeviceN.."), "DeviceN", "DeviceN", NULL); break; - - default : - break; } } @@ -4378,16 +4381,7 @@ check_quotas(cupsd_client_t *con, /* I - Client connection */ "entry ignored", p->users[i]); } - if ((mbr_err = mbr_check_membership(usr_uuid, usr2_uuid, - &is_member)) != 0) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, - "check_quotas: User \"%s\" identity check failed " - "(err=%d)", p->users[i], mbr_err); - is_member = 0; - } - - if (is_member) + if (!uuid_compare(usr_uuid, usr2_uuid)) break; } #else @@ -6928,7 +6922,7 @@ get_jobs(cupsd_client_t *con, /* I - Client connection */ completed = 0; list = Jobs; } - else if (attr && !strcmp(attr->values[0].string.text, "printing")) + else if (attr && !strcmp(attr->values[0].string.text, "processing")) { completed = 0; list = PrintingJobs; @@ -6980,7 +6974,10 @@ get_jobs(cupsd_client_t *con, /* I - Client connection */ * Filter out jobs that don't match... */ - cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: job->id = %d", job->id); + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "get_jobs: job->id=%d, dest=\"%s\", username=\"%s\", " + "state_value=%d, attrs=%p", job->id, job->dest, + job->username, job->state_value, job->attrs); if (!job->dest || !job->username) cupsdLoadJob(job); @@ -7003,7 +7000,11 @@ get_jobs(cupsd_client_t *con, /* I - Client connection */ cupsdLoadJob(job); if (!job->attrs) + { + cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: No attributes for job %d!", + job->id); continue; + } if (username[0] && strcasecmp(username, job->username)) continue; @@ -7013,11 +7014,11 @@ get_jobs(cupsd_client_t *con, /* I - Client connection */ count ++; - cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count = %d", count); - copy_job_attrs(con, job, ra); } + cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count=%d", count); + cupsArrayDelete(ra); con->response->request.status.status_code = IPP_OK; diff --git a/scheduler/listen.c b/scheduler/listen.c index 2ab8798d8..2b4f9e0fd 100644 --- a/scheduler/listen.c +++ b/scheduler/listen.c @@ -4,7 +4,7 @@ * Server listening routines for the Common UNIX Printing System (CUPS) * scheduler. * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -142,23 +142,6 @@ cupsdStartListening(void) cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdStartListening: %d Listeners", cupsArrayCount(Listeners)); - /* - * Get the server's IP address... - */ - - if (ServerAddrs) - httpAddrFreeList(ServerAddrs); - - if ((ServerAddrs = httpAddrGetList(ServerName, AF_UNSPEC, NULL)) == NULL) - { - cupsdLogMessage(CUPSD_LOG_ERROR, - "Unable to find IP address for server name \"%s\"!", - ServerName); - - if (FatalErrors & CUPSD_FATAL_LISTEN) - cupsdEndProcess(getpid(), 0); - } - /* * Setup socket listeners... */ diff --git a/scheduler/network.c b/scheduler/network.c index 6e15655af..e35c2f0fc 100644 --- a/scheduler/network.c +++ b/scheduler/network.c @@ -4,7 +4,7 @@ * Network interface functions for the Common UNIX Printing System * (CUPS) scheduler. * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -100,7 +100,6 @@ cupsdNetIFUpdate(void) cupsd_netif_t *temp; /* New interface */ struct ifaddrs *addrs, /* Interface address list */ *addr; /* Current interface address */ - http_addrlist_t *saddr; /* Current server address */ char hostname[1024]; /* Hostname for address */ @@ -155,7 +154,7 @@ cupsdNetIFUpdate(void) * Try looking up the hostname for the address as needed... */ - if (HostNameLookups) + if (HostNameLookups || RemoteAccessEnabled) httpAddrLookup((http_addr_t *)(addr->ifa_addr), hostname, sizeof(hostname)); else @@ -169,17 +168,8 @@ cupsdNetIFUpdate(void) if (httpAddrLocalhost((http_addr_t *)(addr->ifa_addr))) strcpy(hostname, "localhost"); else - { - for (saddr = ServerAddrs; saddr; saddr = saddr->next) - if (httpAddrEqual((http_addr_t *)(addr->ifa_addr), &(saddr->addr))) - break; - - if (saddr) - strlcpy(hostname, ServerName, sizeof(hostname)); - else - httpAddrString((http_addr_t *)(addr->ifa_addr), hostname, - sizeof(hostname)); - } + httpAddrString((http_addr_t *)(addr->ifa_addr), hostname, + sizeof(hostname)); } /* diff --git a/scheduler/printers.c b/scheduler/printers.c index d32a09b8f..7c57f0761 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -929,7 +929,7 @@ cupsdLoadAllPrinters(void) { cups_file_t *fp; /* printers.conf file */ int linenum; /* Current line number */ - char line[1024], /* Line from file */ + char line[4096], /* Line from file */ *value, /* Pointer to value */ *valueptr; /* Pointer into value */ cupsd_printer_t *p; /* Current printer */ @@ -2625,6 +2625,25 @@ cupsdSetPrinterReasons( *rptr; /* Pointer into reason */ + if (!p || !s) + { + cupsdLogMessage(CUPSD_LOG_EMERG, + "cupsdSetPrinterReasons called with p=%p and s=%p!", p, s); + return; + } + + if (LogLevel == CUPSD_LOG_DEBUG2) + { + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdSetPrinterReasons(p=%p(%s),s=\"%s\"", p, p->name, s); + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSetPrinterReasons: num_reasons=%d", + p->num_reasons); + for (i = 0; i < p->num_reasons; i ++) + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdSetPrinterReasons: reasons[%d]=%p(\"%s\")", i, + p->reasons[i], p->reasons[i]); + } + if (s[0] == '-' || s[0] == '+') { /* @@ -2684,12 +2703,16 @@ cupsdSetPrinterReasons( */ for (i = 0; i < p->num_reasons; i ++) - if (!strcasecmp(reason, p->reasons[i])) + if (!strcmp(reason, p->reasons[i])) { /* * Found a match, so remove it... */ + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdSetPrinterReasons: Removing \"%s\" at index %d", + reason, i); + p->num_reasons --; _cupsStrFree(p->reasons[i]); @@ -2697,8 +2720,6 @@ cupsdSetPrinterReasons( memmove(p->reasons + i, p->reasons + i + 1, (p->num_reasons - i) * sizeof(char *)); - i --; - if (!strcmp(reason, "paused") && p->state == IPP_PRINTER_STOPPED) cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1); @@ -2707,6 +2728,8 @@ cupsdSetPrinterReasons( if (PrintcapFormat == PRINTCAP_PLIST) cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP); + + break; } } else if (p->num_reasons < (int)(sizeof(p->reasons) / sizeof(p->reasons[0]))) @@ -2716,11 +2739,23 @@ cupsdSetPrinterReasons( */ for (i = 0; i < p->num_reasons; i ++) - if (!strcasecmp(reason, p->reasons[i])) + if (!strcmp(reason, p->reasons[i])) break; if (i >= p->num_reasons) { + if (i >= (int)(sizeof(p->reasons) / sizeof(p->reasons[0]))) + { + cupsdLogMessage(CUPSD_LOG_ALERT, + "Too many printer-state-reasons values for %s (%d)", + p->name, i + 1); + return; + } + + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdSetPrinterReasons: Adding \"%s\" at index %d", + reason, i); + p->reasons[i] = _cupsStrAlloc(reason); p->num_reasons ++; @@ -2735,6 +2770,17 @@ cupsdSetPrinterReasons( } } } + + if (LogLevel == CUPSD_LOG_DEBUG2) + { + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdSetPrinterReasons: NEW num_reasons=%d", + p->num_reasons); + for (i = 0; i < p->num_reasons; i ++) + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdSetPrinterReasons: NEW reasons[%d]=%p(\"%s\")", i, + p->reasons[i], p->reasons[i]); + } } @@ -3236,140 +3282,137 @@ cupsdWritePrintcap(void) "# %s/printers.conf file. All changes to this file\n" "# will be lost.\n", ServerRoot); - if (Printers) + /* + * Write a new printcap with the current list of printers. + */ + + switch (PrintcapFormat) { - /* - * Write a new printcap with the current list of printers. - */ + case PRINTCAP_BSD : + /* + * Each printer is put in the file as: + * + * Printer1: + * Printer2: + * Printer3: + * ... + * PrinterN: + */ - switch (PrintcapFormat) - { - case PRINTCAP_BSD : - /* - * Each printer is put in the file as: - * - * Printer1: - * Printer2: - * Printer3: - * ... - * PrinterN: - */ + if (DefaultPrinter) + cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name, + DefaultPrinter->info, ServerName, + DefaultPrinter->name); + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + if (p != DefaultPrinter) + cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info, + ServerName, p->name); + break; - if (DefaultPrinter) - cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name, - DefaultPrinter->info, ServerName, - DefaultPrinter->name); - - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - if (p != DefaultPrinter) - cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info, - ServerName, p->name); - break; - - case PRINTCAP_PLIST : - /* - * Each printer is written as a dictionary in a plist file. - * Currently the printer-name, printer-info, printer-is-accepting-jobs, - * printer-location, printer-make-and-model, printer-state, - * printer-state-reasons, printer-type, and (sanitized) device-uri. - */ + case PRINTCAP_PLIST : + /* + * Each printer is written as a dictionary in a plist file. + * Currently the printer-name, printer-info, printer-is-accepting-jobs, + * printer-location, printer-make-and-model, printer-state, + * printer-state-reasons, printer-type, and (sanitized) device-uri. + */ - cupsFilePuts(fp, "\n" - "\n" - "\n" - "\n"); - - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - { - cupsFilePuts(fp, "\t\n" - "\t\tprinter-name\n" - "\t\t"); - write_xml_string(fp, p->name); - cupsFilePuts(fp, "\n" - "\t\tprinter-info\n" - "\t\t"); - write_xml_string(fp, p->info); - cupsFilePrintf(fp, "\n" - "\t\tprinter-is-accepting-jobs\n" - "\t\t<%s/>\n" - "\t\tprinter-location\n" - "\t\t", p->accepting ? "true" : "false"); - write_xml_string(fp, p->location); - cupsFilePuts(fp, "\n" - "\t\tprinter-make-and-model\n" - "\t\t"); - write_xml_string(fp, p->make_model); - cupsFilePrintf(fp, "\n" - "\t\tprinter-state\n" - "\t\t%d\n" - "\t\tprinter-state-reasons\n" - "\t\t\n", p->state); - for (i = 0; i < p->num_reasons; i ++) - { - cupsFilePuts(fp, "\t\t\t"); - write_xml_string(fp, p->reasons[i]); - cupsFilePuts(fp, "\n"); - } - cupsFilePrintf(fp, "\t\t\n" - "\t\tprinter-type\n" - "\t\t%d\n" - "\t\tdevice-uri\n" - "\t\t", p->type); - write_xml_string(fp, p->sanitized_device_uri); - cupsFilePuts(fp, "\n" - "\t\n"); - } - cupsFilePuts(fp, "\n" - "\n"); - break; + cupsFilePuts(fp, "\n" + "\n" + "\n" + "\n"); - case PRINTCAP_SOLARIS : - /* - * Each printer is put in the file as: - * - * _all:all=Printer1,Printer2,Printer3,...,PrinterN - * _default:use=DefaultPrinter - * Printer1:\ - * :bsdaddr=ServerName,Printer1:\ - * :description=Description: - * Printer2: - * :bsdaddr=ServerName,Printer2:\ - * :description=Description: - * Printer3: - * :bsdaddr=ServerName,Printer3:\ - * :description=Description: - * ... - * PrinterN: - * :bsdaddr=ServerName,PrinterN:\ - * :description=Description: - */ + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + { + cupsFilePuts(fp, "\t\n" + "\t\tprinter-name\n" + "\t\t"); + write_xml_string(fp, p->name); + cupsFilePuts(fp, "\n" + "\t\tprinter-info\n" + "\t\t"); + write_xml_string(fp, p->info); + cupsFilePrintf(fp, "\n" + "\t\tprinter-is-accepting-jobs\n" + "\t\t<%s/>\n" + "\t\tprinter-location\n" + "\t\t", p->accepting ? "true" : "false"); + write_xml_string(fp, p->location); + cupsFilePuts(fp, "\n" + "\t\tprinter-make-and-model\n" + "\t\t"); + write_xml_string(fp, p->make_model); + cupsFilePrintf(fp, "\n" + "\t\tprinter-state\n" + "\t\t%d\n" + "\t\tprinter-state-reasons\n" + "\t\t\n", p->state); + for (i = 0; i < p->num_reasons; i ++) + { + cupsFilePuts(fp, "\t\t\t"); + write_xml_string(fp, p->reasons[i]); + cupsFilePuts(fp, "\n"); + } + cupsFilePrintf(fp, "\t\t\n" + "\t\tprinter-type\n" + "\t\t%d\n" + "\t\tdevice-uri\n" + "\t\t", p->type); + write_xml_string(fp, p->sanitized_device_uri); + cupsFilePuts(fp, "\n" + "\t\n"); + } + cupsFilePuts(fp, "\n" + "\n"); + break; - cupsFilePuts(fp, "_all:all="); - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayCurrent(Printers)) - cupsFilePrintf(fp, "%s%c", p->name, - cupsArrayNext(Printers) ? ',' : '\n'); - - if (DefaultPrinter) - cupsFilePrintf(fp, "_default:use=%s\n", DefaultPrinter->name); - - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - cupsFilePrintf(fp, "%s:\\\n" - "\t:bsdaddr=%s,%s:\\\n" - "\t:description=%s:\n", - p->name, ServerName, p->name, - p->info ? p->info : ""); - break; - } + case PRINTCAP_SOLARIS : + /* + * Each printer is put in the file as: + * + * _all:all=Printer1,Printer2,Printer3,...,PrinterN + * _default:use=DefaultPrinter + * Printer1:\ + * :bsdaddr=ServerName,Printer1:\ + * :description=Description: + * Printer2: + * :bsdaddr=ServerName,Printer2:\ + * :description=Description: + * Printer3: + * :bsdaddr=ServerName,Printer3:\ + * :description=Description: + * ... + * PrinterN: + * :bsdaddr=ServerName,PrinterN:\ + * :description=Description: + */ + + cupsFilePuts(fp, "_all:all="); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayCurrent(Printers)) + cupsFilePrintf(fp, "%s%c", p->name, + cupsArrayNext(Printers) ? ',' : '\n'); + + if (DefaultPrinter) + cupsFilePrintf(fp, "_default:use=%s\n", DefaultPrinter->name); + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + cupsFilePrintf(fp, "%s:\\\n" + "\t:bsdaddr=%s,%s:\\\n" + "\t:description=%s:\n", + p->name, ServerName, p->name, + p->info ? p->info : ""); + break; } /* diff --git a/scheduler/printers.h b/scheduler/printers.h index fac12b245..c7b26ee8c 100644 --- a/scheduler/printers.h +++ b/scheduler/printers.h @@ -52,7 +52,7 @@ typedef struct cupsd_printer_s ipp_pstate_t state; /* Printer state */ char state_message[1024]; /* Printer state message */ int num_reasons; /* Number of printer-state-reasons */ - char *reasons[16]; /* printer-state-reasons strings */ + char *reasons[64]; /* printer-state-reasons strings */ time_t state_time; /* Time at this state */ char *job_sheets[2]; /* Banners/job sheets */ cups_ptype_t type; /* Printer type (color, small, etc.) */ diff --git a/templates/choose-uri.tmpl b/templates/choose-uri.tmpl index 8b4f4a851..907c02aca 100644 --- a/templates/choose-uri.tmpl +++ b/templates/choose-uri.tmpl @@ -10,7 +10,7 @@ - + diff --git a/templates/es/choose-uri.tmpl b/templates/es/choose-uri.tmpl index eddf28150..a7ff12d2c 100644 --- a/templates/es/choose-uri.tmpl +++ b/templates/es/choose-uri.tmpl @@ -10,7 +10,7 @@
Connection:
- + diff --git a/test/5.1-lpadmin.sh b/test/5.1-lpadmin.sh index 30bda2d46..a21980ea6 100644 --- a/test/5.1-lpadmin.sh +++ b/test/5.1-lpadmin.sh @@ -4,7 +4,7 @@ # # Test the lpadmin command. # -# Copyright 2007 by Apple Inc. +# Copyright 2007-2009 by Apple Inc. # Copyright 1997-2005 by Easy Software Products, all rights reserved. # # These coded instructions, statements, and computer programs are the @@ -16,8 +16,8 @@ echo "Add Printer Test" echo "" -echo " lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/DESKJET.PPD" -../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/DESKJET.PPD 2>&1 +echo " lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd" +../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd 2>&1 if test $? != 0; then echo " FAILED" exit 1 diff --git a/test/create-printer-subscription.test b/test/create-printer-subscription.test new file mode 100644 index 000000000..c6427ef76 --- /dev/null +++ b/test/create-printer-subscription.test @@ -0,0 +1,36 @@ +# +# "$Id: 4.4-subscription-ops.test 4840 2005-11-14 21:53:30Z mike $" +# +# Verify that the CUPS subscription operations work. +# +{ + # The name of the test... + NAME "Add Printer Subscription w/Lease" + + # The operation to use + OPERATION Create-Printer-Subscription + RESOURCE / + + # The attributes to send + GROUP operation + ATTR charset attributes-charset utf-8 + ATTR language attributes-natural-language en + ATTR uri printer-uri $uri + + GROUP subscription + ATTR uri notify-recipient testnotify://nowait + ATTR keyword notify-events printer-state-changed + + # What statuses are OK? + STATUS successful-ok + + # What attributes do we expect? + EXPECT attributes-charset + EXPECT attributes-natural-language + EXPECT notify-subscription-id + DISPLAY notify-subscription-id +} + +# +# End of "$Id: 4.4-subscription-ops.test 4840 2005-11-14 21:53:30Z mike $" +# diff --git a/test/get-subscriptions.test b/test/get-subscriptions.test new file mode 100644 index 000000000..686059dfa --- /dev/null +++ b/test/get-subscriptions.test @@ -0,0 +1,21 @@ +# Get subscriptions using Get-Subscriptions +{ + # The name of the test... + NAME "Get subscriptions using Get-Subscriptions" + + # The resource to use for the POST + # RESOURCE /admin + + # The operation to use + OPERATION Get-Subscriptions + + # Attributes, starting in the operation group... + GROUP operation + ATTR charset attributes-charset utf-8 + ATTR language attributes-natural-language en + ATTR uri printer-uri $uri + + # What statuses are OK? + STATUS ok + STATUS ok-subst +} diff --git a/test/run-stp-tests.sh b/test/run-stp-tests.sh index 7a6cdc6a6..c36c9bb2e 100755 --- a/test/run-stp-tests.sh +++ b/test/run-stp-tests.sh @@ -5,7 +5,7 @@ # Perform the complete set of IPP compliance tests specified in the # CUPS Software Test Plan. # -# Copyright 2007-2008 by Apple Inc. +# Copyright 2007-2009 by Apple Inc. # Copyright 1997-2007 by Easy Software Products, all rights reserved. # # These coded instructions, statements, and computer programs are the @@ -188,7 +188,7 @@ echo "" case "$usevalgrind" in Y* | y*) - valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind --error-limit=no --leak-check=yes --trace-children=yes" + valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind.%p --error-limit=no --leak-check=yes --trace-children=yes --read-var-info=yes" echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..." ;;
Conexión: