From: msweet Date: Tue, 15 Jul 2008 01:21:40 +0000 (+0000) Subject: Merge changes from CUPS 1.4svn-r7715. X-Git-Tag: release-1.6.3~158 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fcups.git;a=commitdiff_plain;h=1f0275e3cc0bc5fbe11e3bffd54581aa05c9c764 Merge changes from CUPS 1.4svn-r7715. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@859 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/CHANGES-1.3.txt b/CHANGES-1.3.txt index ba2785712..7324c268d 100644 --- a/CHANGES-1.3.txt +++ b/CHANGES-1.3.txt @@ -4,6 +4,22 @@ CHANGES-1.3.txt CHANGES IN CUPS V1.3.8 - Documentation updates (STR #2785, STR #2861, STR #2862) + - The IPP backend did not relay marker-* attributes. + - The CUPS GNOME/KDE menu item was not localized for + Japanese (STR #2876) + - The cupstestppd utility reported mixed line endings for + Mac OS and Windows PPD files (STR #2874) + - The pdftops filter did not print landscape orientation PDF + pages correctly on all printers (STR #2850) + - The scheduler did not handle expiring of implicit classes + or their members properly, leading to a configuration where + one of the members would have a short name (STR #2766) + - The scheduler and cupstestppd utilities did not support + cupsFilter and cupsPreFilter programs with spaces in their + names (STR #2866) + - Removed unused variables and assignments found by the + LLVM "clang" tool. + - Added NULL checks recommended by the LLVM "clang" tool. - The scheduler would crash if you started a printer that pointed to a backend that did not exist (STR #2865) - The ppdLocalize functions incorrectly mapped all generic diff --git a/CHANGES.txt b/CHANGES.txt index 7bc730132..e2478d39d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,12 @@ -CHANGES.txt - 2008-07-02 +CHANGES.txt - 2008-07-14 ------------------------ CHANGES IN CUPS V1.4b1 + - Added an AccessLogLevel directive to cupsd.conf to control + what is logged to the access_log file. + - The default LogLevel is now "warn" instead of "info" to reduce + the amount of logging that is done to disk by default. - The PPD compiler did not include OID query keywords in PPD files (STR #2871) - The cups-driverd helper program now directly supports driver diff --git a/Makefile b/Makefile index 67fd9d84f..fefe1336d 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,20 @@ depend: done +# +# Run the clang.llvm.org static code analysis tool on the C sources. +# + +.PHONY: clang +clang: + if test ! -d clang; then \ + mkdir clang; \ + else \ + rm -rf clang/*; \ + fi + $(MAKE) $(MFLAGS) CC="scan-build -o ../clang $(CC)" clean all + + # # Generate a ctags file... # diff --git a/backend/ipp.c b/backend/ipp.c index 9944220a2..5113ac727 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -22,6 +22,7 @@ * compress_files() - Compress print files... * password_cb() - Disable the password prompt for * cupsDoFileRequest(). + * report_attr() - Report an IPP attribute value. * report_printer_state() - Report the printer state. * run_pictwps_filter() - Convert PICT files to PostScript when printing * remotely. @@ -64,6 +65,7 @@ static void check_printer_state(http_t *http, const char *uri, static void compress_files(int num_files, char **files); #endif /* HAVE_LIBZ */ static const char *password_cb(const char *); +static void report_attr(ipp_attribute_t *attr); static int report_printer_state(ipp_t *ipp, int job_id); #ifdef __APPLE__ @@ -88,6 +90,7 @@ main(int argc, /* I - Number of command-line args */ int send_options; /* Send job options? */ int num_options; /* Number of printer options */ cups_option_t *options; /* Printer options */ + const char *device_uri; /* Device URI */ char method[255], /* Method in URI */ hostname[1024], /* Hostname */ username[255], /* Username info */ @@ -137,6 +140,11 @@ main(int argc, /* I - Number of command-line args */ { /* Printer attributes we want */ "copies-supported", "document-format-supported", + "marker-colors", + "marker-levels", + "marker-message", + "marker-names", + "marker-types", "printer-is-accepting-jobs", "printer-state", "printer-state-message", @@ -220,7 +228,10 @@ main(int argc, /* I - Number of command-line args */ * Extract the hostname and printer name from the URI... */ - if (httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + if ((device_uri = cupsBackendDeviceURI(argv)) == NULL) + return (CUPS_BACKEND_FAILED); + + if (httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, method, sizeof(method), username, sizeof(username), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_OK) @@ -398,6 +409,7 @@ main(int argc, /* I - Number of command-line args */ cups_file_t *fp; /* Temporary file */ char buffer[8192]; /* Buffer for copying */ int bytes; /* Number of bytes read */ + off_t tbytes; /* Total bytes copied */ if ((fd = cupsTempFd(tmpfilename, sizeof(tmpfilename))) < 0) @@ -414,6 +426,8 @@ main(int argc, /* I - Number of command-line args */ return (CUPS_BACKEND_FAILED); } + tbytes = 0; + while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) if (cupsFileWrite(fp, buffer, bytes) < bytes) { @@ -422,9 +436,22 @@ main(int argc, /* I - Number of command-line args */ unlink(tmpfilename); return (CUPS_BACKEND_FAILED); } + else + tbytes += bytes; cupsFileClose(fp); + /* + * Don't try printing files less than 2 bytes... + */ + + if (tbytes <= 1) + { + _cupsLangPuts(stderr, _("ERROR: Empty print file!\n")); + unlink(tmpfilename); + return (CUPS_BACKEND_FAILED); + } + /* * Point to the single file from stdin... */ @@ -600,6 +627,7 @@ main(int argc, /* I - Number of command-line args */ */ if ((snmp_fd = _cupsSNMPOpen(http->hostaddr->addr.sa_family)) >= 0) + { if (backendSNMPSupplies(snmp_fd, http->hostaddr, &start_count, NULL)) { /* @@ -609,6 +637,9 @@ main(int argc, /* I - Number of command-line args */ _cupsSNMPClose(snmp_fd); snmp_fd = -1; } + } + else + start_count = 0; /* * Build a URI for the printer and fill the standard IPP attributes for @@ -1335,6 +1366,11 @@ check_printer_state( *response; /* IPP response */ static const char * const attrs[] = /* Attributes we want */ { + "marker-colors", + "marker-levels", + "marker-message", + "marker-names", + "marker-types", "printer-state-message", "printer-state-reasons" }; @@ -1487,6 +1523,74 @@ password_cb(const char *prompt) /* I - Prompt (not used) */ } +/* + * 'report_attr()' - Report an IPP attribute value. + */ + +static void +report_attr(ipp_attribute_t *attr) /* I - Attribute */ +{ + int i; /* Looping var */ + char value[1024], /* Value string */ + *valptr, /* Pointer into value string */ + *attrptr; /* Pointer into attribute value */ + + + /* + * Convert the attribute values into quoted strings... + */ + + for (i = 0, valptr = value; + i < attr->num_values && valptr < (value + sizeof(value) - 10); + i ++) + { + if (i > 0) + *valptr++ = ','; + + switch (attr->value_tag) + { + case IPP_TAG_INTEGER : + case IPP_TAG_ENUM : + snprintf(valptr, sizeof(value) - (valptr - value), "%d", + attr->values[i].integer); + valptr += strlen(valptr); + break; + + case IPP_TAG_TEXT : + case IPP_TAG_NAME : + case IPP_TAG_KEYWORD : + *valptr++ = '\"'; + for (attrptr = attr->values[i].string.text; + *attrptr && valptr < (value + sizeof(value) - 10); + attrptr ++) + { + if (*attrptr == '\\' || *attrptr == '\"') + *valptr++ = '\\'; + + *valptr++ = *attrptr; + } + *valptr++ = '\"'; + break; + + default : + /* + * Unsupported value type... + */ + + return; + } + } + + *valptr = '\0'; + + /* + * Tell the scheduler about the new values... + */ + + fprintf(stderr, "ATTR: %s=%s\n", attr->name, value); +} + + /* * 'report_printer_state()' - Report the printer state. */ @@ -1497,8 +1601,9 @@ report_printer_state(ipp_t *ipp, /* I - IPP response */ { int i; /* Looping var */ int count; /* Count of reasons shown... */ - ipp_attribute_t *psm, /* pritner-state-message */ - *reasons; /* printer-state-reasons */ + ipp_attribute_t *psm, /* printer-state-message */ + *reasons, /* printer-state-reasons */ + *marker; /* marker-* attributes */ const char *reason; /* Current reason */ const char *message; /* Message to show */ char unknown[1024]; /* Unknown message string */ @@ -1605,6 +1710,22 @@ report_printer_state(ipp_t *ipp, /* I - IPP response */ fprintf(stderr, "%s\n", state); + /* + * Relay the current marker-* attribute values... + */ + + if ((marker = ippFindAttribute(ipp, "marker-colors", IPP_TAG_NAME)) != NULL) + report_attr(marker); + if ((marker = ippFindAttribute(ipp, "marker-levels", + IPP_TAG_INTEGER)) != NULL) + report_attr(marker); + if ((marker = ippFindAttribute(ipp, "marker-message", IPP_TAG_TEXT)) != NULL) + report_attr(marker); + if ((marker = ippFindAttribute(ipp, "marker-names", IPP_TAG_NAME)) != NULL) + report_attr(marker); + if ((marker = ippFindAttribute(ipp, "marker-types", IPP_TAG_KEYWORD)) != NULL) + report_attr(marker); + return (count); } diff --git a/backend/lpd.c b/backend/lpd.c index 76123b32d..5bd008348 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -112,6 +112,7 @@ int /* O - Exit status */ main(int argc, /* I - Number of command-line arguments (6 or 7) */ char *argv[]) /* I - Command-line arguments */ { + const char *device_uri; /* Device URI */ char method[255], /* Method in URI */ hostname[1024], /* Hostname */ username[255], /* Username info */ @@ -188,7 +189,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the hostname and printer name from the URI... */ - httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + if ((device_uri = cupsBackendDeviceURI(argv)) == NULL) + return (CUPS_BACKEND_FAILED); + + httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, method, sizeof(method), username, sizeof(username), hostname, sizeof(hostname), &port, resource, sizeof(resource)); @@ -437,8 +441,6 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ unlink(tmpfilename); return (CUPS_BACKEND_FAILED); } - - filename = tmpfilename; } else if (argc == 6) { @@ -883,6 +885,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ */ if ((snmp_fd = _cupsSNMPOpen(addr->addr.addr.sa_family)) >= 0) + { if (backendSNMPSupplies(snmp_fd, &(addr->addr), &start_count, NULL)) { /* @@ -892,6 +895,9 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ _cupsSNMPClose(snmp_fd); snmp_fd = -1; } + } + else + start_count = 0; /* * Check for side-channel requests... diff --git a/backend/mdns.c b/backend/mdns.c index dba97231c..4ae2c8121 100644 --- a/backend/mdns.c +++ b/backend/mdns.c @@ -55,7 +55,8 @@ typedef struct *fullName, /* Full name */ *make_and_model; /* Make and model from TXT record */ cups_devtype_t type; /* Device registration type */ - int cups_shared, /* CUPS shared printer? */ + int priority, /* Priority associated with type */ + cups_shared, /* CUPS shared printer? */ sent; /* Did we list the device? */ } cups_device_t; @@ -227,6 +228,7 @@ main(int argc, /* I - Number of command-line args */ * Announce any devices we've found... */ + cups_device_t *best; /* Best matching device */ char device_uri[1024]; /* Device URI */ int count; /* Number of queries */ static const char * const schemes[] = @@ -234,7 +236,8 @@ main(int argc, /* I - Number of command-line args */ /* URI schemes for devices */ - for (device = (cups_device_t *)cupsArrayFirst(devices), count = 0; + for (device = (cups_device_t *)cupsArrayFirst(devices), + best = NULL, count = 0; device; device = (cups_device_t *)cupsArrayNext(devices)) if (!device->ref && !device->sent) @@ -268,17 +271,47 @@ main(int argc, /* I - Number of command-line args */ DNSServiceRefDeallocate(device->ref); device->ref = 0; - httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri), - schemes[device->type], NULL, device->fullName, 0, - device->cups_shared ? "/cups" : "/"); + if (!best) + best = device; + else if (strcasecmp(best->name, device->name) || + strcasecmp(best->domain, device->domain)) + { + httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri), + schemes[best->type], NULL, best->fullName, 0, + best->cups_shared ? "/cups" : "/"); + + printf("network %s \"%s\" \"%s\"\n", device_uri, + best->make_and_model ? best->make_and_model : "Unknown", + best->name); + fflush(stdout); + + best->sent = 1; + best = device; + } + else if (best->priority > device->priority || + (best->priority == device->priority && + best->type < device->type)) + { + best->sent = 1; + best = device; + } + else + device->sent = 1; + } - printf("network %s \"%s\" \"%s\"\n", device_uri, - device->make_and_model ? device->make_and_model : "Unknown", - device->name); - fflush(stdout); + if (best) + { + httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri), + schemes[best->type], NULL, best->fullName, 0, + best->cups_shared ? "/cups" : "/"); - device->sent = 1; - } + printf("network %s \"%s\" \"%s\"\n", device_uri, + best->make_and_model ? best->make_and_model : "Unknown", + best->name); + fflush(stdout); + + best->sent = 1; + } } } } @@ -410,7 +443,8 @@ exec_backend(char **argv) /* I - Command-line arguments */ * Resolve the device URI... */ - resolved_uri = cupsBackendDeviceURI(argv); + if ((resolved_uri = cupsBackendDeviceURI(argv)) == NULL) + exit(CUPS_BACKEND_FAILED); /* * Extract the scheme from the URI... @@ -481,47 +515,36 @@ get_device(cups_array_t *devices, /* I - Device array */ else key.type = CUPS_DEVICE_RIOUSBPRINT; - if ((device = cupsArrayFind(devices, &key)) != NULL) - { - /* - * No, see if this registration is a higher priority protocol... - */ + for (device = cupsArrayFind(devices, &key); + device; + device = cupsArrayNext(devices)) + if (strcasecmp(device->name, key.name) || + strcasecmp(device->domain, key.domain)) + break; + else if (device->type == key.type) + return (device); - if (key.type > device->type) - { - fprintf(stderr, "DEBUG: Updating \"%s\" to \"%s.%s%s\"...\n", - device->fullName, serviceName, regtype, replyDomain); - - device->type = key.type; - } - } - else - { - /* - * Yes, add the device... - */ + /* + * Yes, add the device... + */ - fprintf(stderr, "DEBUG: Found \"%s.%s%s\"...\n", serviceName, regtype, - replyDomain); + fprintf(stderr, "DEBUG: Found \"%s.%s%s\"...\n", serviceName, regtype, + replyDomain); - device = calloc(sizeof(cups_device_t), 1); - device->name = strdup(serviceName); - device->domain = strdup(replyDomain); - device->type = key.type; + device = calloc(sizeof(cups_device_t), 1); + device->name = strdup(serviceName); + device->domain = strdup(replyDomain); + device->type = key.type; + device->priority = 50; - cupsArrayAdd(devices, device); - } + cupsArrayAdd(devices, device); /* - * Update the "full name" of this service, which is used for queries... + * Set the "full name" of this service, which is used for queries... */ snprintf(fullName, sizeof(fullName), "%s.%s%s", serviceName, regtype, replyDomain); - - if (device->fullName) - free(device->fullName); - device->fullName = strdup(fullName); return (device); @@ -585,105 +608,142 @@ query_callback( if ((ptr = strstr(name, "._")) != NULL) *ptr = '\0'; - if ((device = cupsArrayFind(devices, &key)) != NULL) + if (strstr(fullName, "_ipp._tcp.") || + strstr(fullName, "_ipp-tls._tcp.")) + key.type = CUPS_DEVICE_IPP; + else if (strstr(fullName, "_fax-ipp._tcp.")) + key.type = CUPS_DEVICE_FAX_IPP; + else if (strstr(fullName, "_printer._tcp.")) + key.type = CUPS_DEVICE_PRINTER; + else if (strstr(fullName, "_pdl-datastream._tcp.")) + key.type = CUPS_DEVICE_PDL_DATASTREAM; + else + key.type = CUPS_DEVICE_RIOUSBPRINT; + + for (device = cupsArrayFind(devices, &key); + device; + device = cupsArrayNext(devices)) { - /* - * Found it, pull out the make and model from the TXT record and save it... - */ + if (strcasecmp(device->name, key.name) || + strcasecmp(device->domain, key.domain)) + { + device = NULL; + break; + } + else if (device->type == key.type) + { + /* + * Found it, pull out the priority and make and model from the TXT + * record and save it... + */ - const void *value; /* Pointer to value */ - uint8_t valueLen; /* Length of value (max 255) */ - char make_and_model[512], /* Manufacturer and model */ - model[256]; /* Model */ + const void *value; /* Pointer to value */ + uint8_t valueLen; /* Length of value (max 255) */ + char make_and_model[512], /* Manufacturer and model */ + model[256], /* Model */ + priority[256]; /* Priority */ - if ((value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MFG", - &valueLen)) == NULL) - value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MANUFACTURER", &valueLen); + value = TXTRecordGetValuePtr(rdlen, rdata, "priority", &valueLen); - if (value && valueLen) - { - memcpy(make_and_model, value, valueLen); - make_and_model[valueLen] = '\0'; - } - else - make_and_model[0] = '\0'; + if (value && valueLen) + { + memcpy(priority, value, valueLen); + priority[valueLen] = '\0'; + device->priority = atoi(priority); + } - if ((value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MDL", - &valueLen)) == NULL) - value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MODEL", &valueLen); + if ((value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MFG", + &valueLen)) == NULL) + value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MANUFACTURER", + &valueLen); - if (value && valueLen) - { - memcpy(model, value, valueLen); - model[valueLen] = '\0'; - } - else if ((value = TXTRecordGetValuePtr(rdlen, rdata, "product", - &valueLen)) != NULL && valueLen > 2) - { - if (((char *)value)[0] == '(') + if (value && valueLen) { - /* - * Strip parenthesis... - */ - - memcpy(model, value + 1, valueLen - 2); - model[valueLen - 2] = '\0'; + memcpy(make_and_model, value, valueLen); + make_and_model[valueLen] = '\0'; } else + make_and_model[0] = '\0'; + + if ((value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MDL", + &valueLen)) == NULL) + value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MODEL", &valueLen); + + if (value && valueLen) { memcpy(model, value, valueLen); model[valueLen] = '\0'; } - - if (!strcasecmp(model, "GPL Ghostscript") || - !strcasecmp(model, "GNU Ghostscript") || - !strcasecmp(model, "ESP Ghostscript")) + else if ((value = TXTRecordGetValuePtr(rdlen, rdata, "product", + &valueLen)) != NULL && valueLen > 2) { - if ((value = TXTRecordGetValuePtr(rdlen, rdata, "ty", - &valueLen)) != NULL) - { + if (((char *)value)[0] == '(') + { + /* + * Strip parenthesis... + */ + + memcpy(model, value + 1, valueLen - 2); + model[valueLen - 2] = '\0'; + } + else + { memcpy(model, value, valueLen); model[valueLen] = '\0'; + } - if ((ptr = strchr(model, ',')) != NULL) - *ptr = '\0'; + if (!strcasecmp(model, "GPL Ghostscript") || + !strcasecmp(model, "GNU Ghostscript") || + !strcasecmp(model, "ESP Ghostscript")) + { + if ((value = TXTRecordGetValuePtr(rdlen, rdata, "ty", + &valueLen)) != NULL) + { + memcpy(model, value, valueLen); + model[valueLen] = '\0'; + + if ((ptr = strchr(model, ',')) != NULL) + *ptr = '\0'; + } + else + strcpy(model, "Unknown"); } - else - strcpy(model, "Unknown"); } - } - else - strcpy(model, "Unknown"); + else + strcpy(model, "Unknown"); - if (device->make_and_model) - free(device->make_and_model); + if (device->make_and_model) + free(device->make_and_model); - if (make_and_model[0]) - { - strlcat(make_and_model, " ", sizeof(make_and_model)); - strlcat(make_and_model, model, sizeof(make_and_model)); - device->make_and_model = strdup(make_and_model); - } - else - device->make_and_model = strdup(model); + if (make_and_model[0]) + { + strlcat(make_and_model, " ", sizeof(make_and_model)); + strlcat(make_and_model, model, sizeof(make_and_model)); + device->make_and_model = strdup(make_and_model); + } + else + device->make_and_model = strdup(model); - if ((device->type == CUPS_DEVICE_IPP || - device->type == CUPS_DEVICE_PRINTER) && - (value = TXTRecordGetValuePtr(rdlen, rdata, "printer-type", - &valueLen)) != NULL) - { - /* - * This is a CUPS printer! - */ + if ((device->type == CUPS_DEVICE_IPP || + device->type == CUPS_DEVICE_PRINTER) && + TXTRecordGetValuePtr(rdlen, rdata, "printer-type", &valueLen)) + { + /* + * This is a CUPS printer! + */ - device->cups_shared = 1; + device->cups_shared = 1; - if (device->type == CUPS_DEVICE_PRINTER) - device->sent = 1; + if (device->type == CUPS_DEVICE_PRINTER) + device->sent = 1; + } + + break; } } - else + + if (!device) fprintf(stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName); } diff --git a/backend/pap.c b/backend/pap.c index f0f194e73..03c825259 100644 --- a/backend/pap.c +++ b/backend/pap.c @@ -278,7 +278,6 @@ int main (int argc, const char * argv[]) */ static int listDevices(void) { - int err = noErr; int i; int numberFound; @@ -298,7 +297,7 @@ static int listDevices(void) return -1; /* Network is down */ } - if ((err = zip_getmyzone(ZIP_DEF_INTERFACE, &at_zone)) != 0) + if (zip_getmyzone(ZIP_DEF_INTERFACE, &at_zone)) { _cupsLangPrintError(_("ERROR: Unable to get default AppleTalk zone")); return -2; @@ -410,14 +409,13 @@ static int printFile(char* name, char* type, char* zone, int fdin, int fdout, in at_inet_t sendDataAddr; at_inet_t src; at_resp_t resp; - int userdata, xo, reqlen; + int userdata, xo = 0, reqlen; u_short tid; u_char bitmap; int maxfdp1, nbp_failures = 0; struct timeval timeout, *timeoutPtr; u_char flowQuantum = 1; - u_short recvSequence = 0; time_t now, start_time, elasped_time, @@ -731,7 +729,7 @@ static int printFile(char* name, char* type, char* zone, int fdin, int fdout, in case AT_PAP_TYPE_SEND_DATA: /* Send-Data packet */ sendDataAddr.socket = src.socket; gSendDataID = tid; - recvSequence = OSReadBigInt16(&SEQUENCE_NUM(userdata), 0); + OSReadBigInt16(&SEQUENCE_NUM(userdata), 0); if ((fileBufferNbytes > 0 || fileEOFRead) && fileEOFSent == false) { @@ -913,8 +911,7 @@ static int papOpen(at_nbptuple_t* tuple, u_char* connID, int* fd, { int result, open_result, - userdata, - atp_err; + userdata; time_t tm, waitTime; char data[10], @@ -963,8 +960,8 @@ static int papOpen(at_nbptuple_t* tuple, u_char* connID, int* fd, fprintf(stderr, "DEBUG: -> %s\n", packet_name(AT_PAP_TYPE_OPEN_CONN)); - if ((atp_err = atp_sendreq(*fd, &tuple->enu_addr, data, 4, userdata, 1, 0, - 0, &resp, &retry, 0)) < 0) + if (atp_sendreq(*fd, &tuple->enu_addr, data, 4, userdata, 1, 0, + 0, &resp, &retry, 0) < 0) { statusUpdate("Destination unreachable", 23); result = EHOSTUNREACH; @@ -1031,7 +1028,6 @@ static int papClose() { int fd; u_short tmpID; - int result; unsigned char rdata[ATP_DATA_SIZE]; int userdata; u_char *puserdata = (u_char *)&userdata; @@ -1084,9 +1080,9 @@ static int papClose() resp.resp[0].iov_base = rdata; resp.resp[0].iov_len = sizeof(rdata); - result = atp_sendreq(fd, &gSessionAddr, 0, 0, userdata, 1, 0, 0, &resp, &retry, 0); + atp_sendreq(fd, &gSessionAddr, 0, 0, userdata, 1, 0, 0, &resp, &retry, 0); - result = close(fd); + close(fd); } return noErr; } diff --git a/backend/socket.c b/backend/socket.c index 5992fc5f7..4e2dac146 100644 --- a/backend/socket.c +++ b/backend/socket.c @@ -61,6 +61,7 @@ int /* O - Exit status */ main(int argc, /* I - Number of command-line arguments (6 or 7) */ char *argv[]) /* I - Command-line arguments */ { + const char *device_uri; /* Device URI */ char method[255], /* Method in URI */ hostname[1024], /* Hostname */ username[255], /* Username info (not used) */ @@ -160,7 +161,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the hostname and port number from the URI... */ - httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + if ((device_uri = cupsBackendDeviceURI(argv)) == NULL) + return (CUPS_BACKEND_FAILED); + + httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, method, sizeof(method), username, sizeof(username), hostname, sizeof(hostname), &port, resource, sizeof(resource)); @@ -364,6 +368,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ */ if ((snmp_fd = _cupsSNMPOpen(addr->addr.addr.sa_family)) >= 0) + { if (backendSNMPSupplies(snmp_fd, &(addr->addr), &start_count, NULL)) { /* @@ -373,6 +378,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ _cupsSNMPClose(snmp_fd); snmp_fd = -1; } + } + else + start_count = 0; /* * Print everything... diff --git a/berkeley/lpr.c b/berkeley/lpr.c index a1388be7e..b529365d7 100644 --- a/berkeley/lpr.c +++ b/berkeley/lpr.c @@ -3,7 +3,7 @@ * * "lpr" command for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the diff --git a/cgi-bin/Dependencies b/cgi-bin/Dependencies index 1d4cb9791..3c913998b 100644 --- a/cgi-bin/Dependencies +++ b/cgi-bin/Dependencies @@ -56,6 +56,9 @@ testtemplate.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h testtemplate.o: ../cups/versioning.h ../cups/ppd.h ../cups/array.h testtemplate.o: ../cups/file.h ../cups/language.h ../cups/array.h testtemplate.o: help-index.h +websearch.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h +websearch.o: ../cups/versioning.h ../cups/ppd.h ../cups/array.h +websearch.o: ../cups/file.h ../cups/language.h ../cups/array.h help-index.h # DO NOT DELETE help-index.32.o: help-index.c cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h @@ -114,6 +117,9 @@ testtemplate.32.o: testtemplate.c cgi.h ../cups/cups.h ../cups/ipp.h ../cups/ht testtemplate.32.o: testtemplate.c ../cups/versioning.h ../cups/ppd.h ../cups/array.h testtemplate.32.o: testtemplate.c ../cups/file.h ../cups/language.h ../cups/array.h testtemplate.32.o: testtemplate.c help-index.h +websearch.32.o: websearch.c cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h +websearch.32.o: websearch.c ../cups/versioning.h ../cups/ppd.h ../cups/array.h +websearch.32.o: websearch.c ../cups/file.h ../cups/language.h ../cups/array.h help-index.h # DO NOT DELETE help-index.64.o: help-index.c cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h @@ -172,3 +178,6 @@ testtemplate.64.o: testtemplate.c cgi.h ../cups/cups.h ../cups/ipp.h ../cups/ht testtemplate.64.o: testtemplate.c ../cups/versioning.h ../cups/ppd.h ../cups/array.h testtemplate.64.o: testtemplate.c ../cups/file.h ../cups/language.h ../cups/array.h testtemplate.64.o: testtemplate.c help-index.h +websearch.64.o: websearch.c cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h +websearch.64.o: websearch.c ../cups/versioning.h ../cups/ppd.h ../cups/array.h +websearch.64.o: websearch.c ../cups/file.h ../cups/language.h ../cups/array.h help-index.h diff --git a/cgi-bin/Makefile b/cgi-bin/Makefile index 53911d845..3ddc6cd65 100644 --- a/cgi-bin/Makefile +++ b/cgi-bin/Makefile @@ -35,7 +35,8 @@ OBJS = \ printers.o \ testcgi.o \ testhi.o \ - testtemplate.o + testtemplate.o \ + websearch.o CGIS = \ admin.cgi \ classes.cgi \ @@ -48,7 +49,8 @@ LIBTARGETS = \ $(LIB32CUPSCGI) \ $(LIB32CUPSCGI) \ testcgi \ - testhi + testhi \ + websearch TARGETS = \ $(LIBTARGETS) \ @@ -390,6 +392,16 @@ testtemplate: testtemplate.o ../Makedefs libcupscgi.a ../cups/libcups.a $(COMMONLIBS) $(SSLLIBS) $(LIBZ) $(LIBGSSAPI) +# +# websearch +# + +websearch: websearch.o ../Makedefs libcupscgi.a ../cups/libcups.a + echo Linking $@... + $(CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ websearch.o libcupscgi.a \ + ../cups/libcups.a $(COMMONLIBS) $(SSLLIBS) $(LIBZ) $(LIBGSSAPI) + + # # Dependencies... # diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index 3f94b8826..e67582d02 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -969,7 +969,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */ return; } - else if (!file && (var = cgiGetVariable("PPD_NAME")) == NULL) + else if (!file && !cgiGetVariable("PPD_NAME")) { if (modify) { @@ -3016,15 +3016,15 @@ do_set_options(http_t *http, /* I - HTTP connection */ cgiSetVariable("KEYWORD", "job_sheets_start"); cgiSetVariable("KEYTEXT", cgiText(_("Starting Banner"))); - cgiSetVariable("DEFCHOICE", attr == NULL ? - "" : attr->values[0].string.text); + cgiSetVariable("DEFCHOICE", attr != NULL ? + attr->values[0].string.text : ""); cgiCopyTemplateLang("option-pickone.tmpl"); cgiSetVariable("KEYWORD", "job_sheets_end"); cgiSetVariable("KEYTEXT", cgiText(_("Ending Banner"))); - cgiSetVariable("DEFCHOICE", attr == NULL && attr->num_values > 1 ? - "" : attr->values[1].string.text); + cgiSetVariable("DEFCHOICE", attr != NULL && attr->num_values > 1 ? + attr->values[1].string.text : ""); cgiCopyTemplateLang("option-pickone.tmpl"); @@ -3211,7 +3211,7 @@ do_set_options(http_t *http, /* I - HTTP connection */ } if ((var = cgiGetVariable("protocol")) != NULL) - cupsFilePrintf(out, "*cupsProtocol: %s\n", cgiGetVariable("protocol")); + cupsFilePrintf(out, "*cupsProtocol: %s\n", var); cupsFileClose(in); cupsFileClose(out); @@ -3250,12 +3250,12 @@ do_set_options(http_t *http, /* I - HTTP connection */ attr->values[1].string.text = _cupsStrAlloc(cgiGetVariable("job_sheets_end")); if ((var = cgiGetVariable("printer_error_policy")) != NULL) - attr = ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, - "printer-error-policy", NULL, var); + ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, + "printer-error-policy", NULL, var); if ((var = cgiGetVariable("printer_op_policy")) != NULL) - attr = ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, - "printer-op-policy", NULL, var); + ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, + "printer-op-policy", NULL, var); /* * Do the request and get back a response... diff --git a/cgi-bin/help-index.c b/cgi-bin/help-index.c index cb88aee17..9b40252bf 100644 --- a/cgi-bin/help-index.c +++ b/cgi-bin/help-index.c @@ -1297,7 +1297,7 @@ help_sort_by_score(help_node_t *n1, /* I - First node */ n2, n2->score, n2->section ? n2->section : "", n2->text)); if (n1->score != n2->score) - return (n1->score - n2->score); + return (n2->score - n1->score); if (n1->section && !n2->section) return (1); diff --git a/cgi-bin/search.c b/cgi-bin/search.c index d8f023c28..7d15d639d 100644 --- a/cgi-bin/search.c +++ b/cgi-bin/search.c @@ -47,7 +47,14 @@ cgiCompileSearch(const char *query) /* I - Query string */ char *lword; /* Last word in query */ - DEBUG_printf(("help_compile_search(query=\"%s\")\n", query ? query : "(nil)")); + DEBUG_printf(("cgiCompileSearch(query=\"%s\")\n", query)); + + /* + * Range check input... + */ + + if (!query) + return (NULL); /* * Allocate a regular expression storage structure... diff --git a/cgi-bin/websearch.c b/cgi-bin/websearch.c new file mode 100644 index 000000000..742c3238e --- /dev/null +++ b/cgi-bin/websearch.c @@ -0,0 +1,109 @@ +/* + * "$Id$" + * + * Web search program for www.cups.org. + * + * Copyright 2007-2008 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products. + * + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * 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/". + * + * Usage: + * + * websearch directory "search string" + * + * Contents: + * + * main() - Search a directory of help files. + * list_nodes() - List matching nodes. + */ + +/* + * Include necessary headers... + */ + +#include "cgi.h" + + +/* + * Local functions... + */ + +static void list_nodes(const char *title, cups_array_t *nodes); + + +/* + * 'main()' - Test the help index code. + */ + +int /* O - Exit status */ +main(int argc, /* I - Number of command-line args */ + char *argv[]) /* I - Command-line arguments */ +{ + help_index_t *hi, /* Help index */ + *search; /* Search index */ + char indexname[1024]; /* Name of index file */ + + + if (argc != 3) + { + puts("Usage: websearch directory \"search terms\""); + return (1); + } + + /* + * Load the help index... + */ + + snprintf(indexname, sizeof(indexname), "%s/.index", argv[1]); + hi = helpLoadIndex(indexname, argv[1]); + + /* + * Do any searches... + */ + + search = helpSearchIndex(hi, argv[2], NULL, NULL); + + if (search) + list_nodes(argv[1], search->sorted); + + /* + * Return with no errors... + */ + + return (0); +} + + +/* + * 'list_nodes()' - List nodes in an array... + */ + +static void +list_nodes(const char *title, /* I - Title string */ + cups_array_t *nodes) /* I - Nodes */ +{ + help_node_t *node; /* Current node */ + + + printf("%d\n", cupsArrayCount(nodes)); + for (node = (help_node_t *)cupsArrayFirst(nodes); + node; + node = (help_node_t *)cupsArrayNext(nodes)) + { + if (node->anchor) + printf("%d|%s#%s|%s\n", node->score, node->filename, node->anchor, + node->text); + else + printf("%d|%s|%s\n", node->score, node->filename, node->text); + } +} + + +/* + * End of "$Id$". + */ diff --git a/conf/cupsd.conf.in b/conf/cupsd.conf.in index c48b70626..649b552ee 100644 --- a/conf/cupsd.conf.in +++ b/conf/cupsd.conf.in @@ -6,9 +6,9 @@ # file. # -# Log general information in error_log - change "info" to "debug" for -# troubleshooting... -LogLevel info +# Log general information in error_log - change "@CUPS_LOG_LEVEL@" to "debug" +# for troubleshooting... +LogLevel @CUPS_LOG_LEVEL@ # Administrator user group... SystemGroup @CUPS_SYSTEM_GROUPS@ diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index a88692f35..e48fc0fe4 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -277,14 +277,30 @@ case $uname in AC_CHECK_FUNCS(notify_post) dnl Check for Authorization Services support + AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value], + default_adminkey="$withval", + default_adminkey="default") + AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value], + default_operkey="$withval", + default_operkey="default") + AC_CHECK_HEADER(Security/Authorization.h, [ AC_DEFINE(HAVE_AUTHORIZATION_H) - if grep -q system.print.operator /etc/authorization; then - CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin" - CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences" + + if test "x$default_adminkey" != xdefault; then + CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey" + elif grep -q system.print.operator /etc/authorization; then + CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin" else + CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences" + fi + + if test "x$default_operkey" != xdefault; then + CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin" + elif grep -q system.print.operator /etc/authorization; then CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin" - CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin" + else + CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin" fi]) AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H)) diff --git a/config-scripts/cups-defaults.m4 b/config-scripts/cups-defaults.m4 index 80287e806..624b3d6f2 100644 --- a/config-scripts/cups-defaults.m4 +++ b/config-scripts/cups-defaults.m4 @@ -43,6 +43,20 @@ AC_ARG_WITH(log_file_perm, [ --with-log-file-perm set default LogFilePerm va AC_SUBST(CUPS_LOG_FILE_PERM) AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, 0$CUPS_LOG_FILE_PERM) +dnl Default LogLevel +AC_ARG_WITH(log_level, [ --with-log-level set default LogLevel value, default=warn], + CUPS_LOG_LEVEL="$withval", + CUPS_LOG_LEVEL="warn") +AC_SUBST(CUPS_LOG_LEVEL) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_LEVEL, "$CUPS_LOG_LEVEL") + +dnl Default AccessLogLevel +AC_ARG_WITH(log_level, [ --with-access-log-level set default AccessLogLevel value, default=actions], + CUPS_LOG_LEVEL="$withval", + CUPS_LOG_LEVEL="actions") +AC_SUBST(CUPS_ACCESS_LOG_LEVEL) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_ACCESS_LOG_LEVEL, "$CUPS_ACCESS_LOG_LEVEL") + dnl Default Browsing AC_ARG_ENABLE(browsing, [ --enable-browsing enable Browsing by default, default=yes]) if test "x$enable_browsing" = xno; then diff --git a/config.h.in b/config.h.in index 7c54621fc..cd801f72e 100644 --- a/config.h.in +++ b/config.h.in @@ -42,6 +42,14 @@ #define CUPS_DEFAULT_LOG_FILE_PERM 0644 +/* + * Default logging settings... + */ + +#define CUPS_DEFAULT_LOG_LEVEL "warn" +#define CUPS_DEFAULT_ACCESS_LOG_LEVEL "actions" + + /* * Default browsing settings... */ diff --git a/cups/adminutil.c b/cups/adminutil.c index 95393afd0..87ff36fd7 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -389,7 +389,7 @@ cupsAdminCreateWindowsPPD( { write_option(dstfp, jclorder ++, "cupsJobSheetsStart", "Start Banner", "job-sheets", suppattr, defattr, 0, 2); - write_option(dstfp, jclorder ++, "cupsJobSheetsEnd", "End Banner", + write_option(dstfp, jclorder, "cupsJobSheetsEnd", "End Banner", "job-sheets", suppattr, defattr, 1, 2); } @@ -967,7 +967,7 @@ _cupsAdminGetServerSettings( if (!value && strncmp(line, "gssctx != GSS_C_NO_CONTEXT) { - major_status = gss_delete_sec_context(&minor_status, &http->gssctx, - GSS_C_NO_BUFFER); + gss_delete_sec_context(&minor_status, &http->gssctx, GSS_C_NO_BUFFER); http->gssctx = GSS_C_NO_CONTEXT; } @@ -323,14 +322,14 @@ cupsDoAuthentication(http_t *http, /* I - Connection to server or @code CUPS httpEncode64_2(http->authstring + 10, authsize - 10, output_token.value, output_token.length); - major_status = gss_release_buffer(&minor_status, &output_token); + gss_release_buffer(&minor_status, &output_token); } else { DEBUG_printf(("cupsDoAuthentication: Kerberos credentials too large - " "%d bytes!\n", (int)output_token.length)); - major_status = gss_release_buffer(&minor_status, &output_token); + gss_release_buffer(&minor_status, &output_token); return (-1); } @@ -405,12 +404,8 @@ DEBUG_gss_printf(OM_uint32 major_status,/* I - Major status code */ &major_status_string); if (!GSS_ERROR(err_major_status)) - err_major_status = gss_display_status(&err_minor_status, - minor_status, - GSS_C_MECH_CODE, - GSS_C_NULL_OID, - &msg_ctx, - &minor_status_string); + gss_display_status(&err_minor_status, minor_status, GSS_C_MECH_CODE, + GSS_C_NULL_OID, &msg_ctx, &minor_status_string); printf("%s: %s, %s\n", message, (char *)major_status_string.value, (char *)minor_status_string.value); diff --git a/cups/backend.c b/cups/backend.c index 477d38ecd..021dad2e2 100644 --- a/cups/backend.c +++ b/cups/backend.c @@ -53,7 +53,7 @@ cupsBackendDeviceURI(char **argv) /* I - Command-line arguments */ } return (_httpResolveURI(device_uri, cg->resolved_uri, - sizeof(cg->resolved_uri))); + sizeof(cg->resolved_uri), 1)); } diff --git a/cups/debug.c b/cups/debug.c index cfb8bd6aa..76dec26ee 100644 --- a/cups/debug.c +++ b/cups/debug.c @@ -62,7 +62,6 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ { char *bufptr, /* Pointer to position in buffer */ *bufend, /* Pointer to end of buffer */ - sign, /* Sign of format width */ size, /* Size character (h, l, L) */ type; /* Format type character */ int width, /* Width of field */ @@ -74,6 +73,9 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ int bytes; /* Total number of bytes needed */ + if (!buffer || bufsize < 2 || !format) + return (-1); + /* * Loop through the format string, formatting as needed... */ @@ -91,18 +93,14 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ if (*format == '%') { - if (bufptr && bufptr < bufend) *bufptr++ = *format; + if (bufptr < bufend) + *bufptr++ = *format; bytes ++; format ++; continue; } else if (strchr(" -+#\'", *format)) - { - *tptr++ = *format; - sign = *format++; - } - else - sign = 0; + *tptr++ = *format++; if (*format == '*') { @@ -161,8 +159,6 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ } } } - else - prec = -1; if (*format == 'l' && format[1] == 'l') { @@ -183,6 +179,8 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ size = *format++; } + else + size = 0; if (!*format) break; @@ -365,7 +363,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */ { bytes ++; - if (bufptr && bufptr < bufend) + if (bufptr < bufend) *bufptr++ = *format; format ++; diff --git a/cups/dest.c b/cups/dest.c index 185bd1a50..66289b2c7 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -120,7 +120,7 @@ cupsAddDest(const char *name, /* I - Destination name */ if (!name || !dests) return (0); - if ((dest = cupsGetDest(name, instance, num_dests, *dests)) != NULL) + if (cupsGetDest(name, instance, num_dests, *dests)) return (num_dests); /* @@ -980,7 +980,6 @@ appleGetDefault(char *name, /* I - Name buffer */ DEBUG_puts("appleGetDefault: Missing or bad location history array..."); - CFRelease(network); return (NULL); } @@ -992,9 +991,6 @@ appleGetDefault(char *name, /* I - Name buffer */ else name[0] = '\0'; - CFRelease(locations); - CFRelease(network); - DEBUG_printf(("appleGetDefault: Returning \"%s\"...\n", name)); return (*name ? name : NULL); @@ -1206,9 +1202,6 @@ appleSetDefault(const char *name) /* I - Default printer/class name */ CFRelease(newlocation); } - if (locations) - CFRelease(locations); - CFRelease(network); CFRelease(newprinter); } diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index effe2e6a8..265107af0 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -529,8 +529,6 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p if (addr) addr->next = temp; - else - addr = temp; } } else if (!hostname) @@ -584,8 +582,6 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p if (addr) addr->next = temp; - else - addr = temp; } } } diff --git a/cups/http-private.h b/cups/http-private.h index 415f25a9e..f44266cce 100644 --- a/cups/http-private.h +++ b/cups/http-private.h @@ -264,7 +264,7 @@ extern void _cups_freeifaddrs(struct ifaddrs *addrs); extern char *_httpEncodeURI(char *dst, const char *src, size_t dstsize); extern const char *_httpResolveURI(const char *uri, char *resolved_uri, - size_t resolved_size); + size_t resolved_size, int log); #endif /* !_CUPS_HTTP_PRIVATE_H_ */ /* diff --git a/cups/http-support.c b/cups/http-support.c index 419383899..56e27515c 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -1255,23 +1255,37 @@ const char * /* O - Resolved URI */ _httpResolveURI( const char *uri, /* I - DNS-SD URI */ char *resolved_uri, /* I - Buffer for resolved URI */ - size_t resolved_size) /* I - Size of URI buffer */ + size_t resolved_size, /* I - Size of URI buffer */ + int log) /* I - Log progress to stderr? */ { char scheme[32], /* URI components... */ userpass[256], hostname[1024], resource[1024]; int port; + http_uri_status_t status; /* URI decode status */ + DEBUG_printf(("_httpResolveURI(uri=\"%s\", resolved_uri=%p, " + "resolved_size=" CUPS_LLFMT ")\n", uri, resolved_uri, + CUPS_LLCAST resolved_size)); + /* * Get the device URI... */ - if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), - userpass, sizeof(userpass), hostname, sizeof(hostname), - &port, resource, sizeof(resource)) < HTTP_URI_OK) + if ((status = httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, + sizeof(scheme), userpass, sizeof(userpass), + hostname, sizeof(hostname), &port, resource, + sizeof(resource))) < HTTP_URI_OK) + { + if (log) + _cupsLangPrintf(stderr, _("Bad device URI \"%s\"!\n"), uri); + + DEBUG_printf(("_httpResolveURI: httpSeparateURI returned %d!\n", status)); + DEBUG_puts("_httpResolveURI: Returning NULL"); return (NULL); + } /* * Resolve it as needed... @@ -1289,8 +1303,24 @@ _httpResolveURI( * Separate the hostname into service name, registration type, and domain... */ - regtype = strchr(hostname, '.'); - *regtype++ = '\0'; + for (regtype = strstr(hostname, "._tcp") - 2; + regtype > hostname; + regtype --) + if (regtype[0] == '.' && regtype[1] == '_') + { + /* + * Found ._servicetype in front of ._tcp... + */ + + *regtype++ = '\0'; + break; + } + + if (regtype <= hostname) + { + DEBUG_puts("_httpResolveURI: Bad hostname, returning NULL"); + return (NULL); + } domain = regtype + strlen(regtype) - 1; if (domain > regtype && *domain == '.') @@ -1310,6 +1340,14 @@ _httpResolveURI( resolved_uri[0] = '\0'; + DEBUG_printf(("_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", " + "domain=\"%s\"\n", hostname, regtype, domain)); + if (log) + { + fputs("STATE: +connecting-to-device\n", stderr); + _cupsLangPrintf(stderr, _("INFO: Looking for \"%s\"...\n"), hostname); + } + if (DNSServiceResolve(&ref, 0, 0, hostname, regtype, domain, resolve_callback, &uribuf) == kDNSServiceErr_NoError) @@ -1323,11 +1361,25 @@ _httpResolveURI( DNSServiceRefDeallocate(ref); } else -#endif /* HAVE_DNSSD */ + uri = NULL; + + if (log) + fputs("STATE: -connecting-to-device\n", stderr); + +#else + /* + * No DNS-SD support... + */ uri = NULL; +#endif /* HAVE_DNSSD */ + + if (log && !uri) + _cupsLangPuts(stderr, _("Unable to find printer!\n")); } + DEBUG_printf(("_httpResolveURI: Returning \"%s\"\n", uri)); + return (uri); } diff --git a/cups/http.c b/cups/http.c index 7a150a0b1..894f7641a 100644 --- a/cups/http.c +++ b/cups/http.c @@ -298,8 +298,7 @@ void httpClose(http_t *http) /* I - Connection to server */ { #ifdef HAVE_GSSAPI - OM_uint32 minor_status, /* Minor status code */ - major_status; /* Major status code */ + OM_uint32 minor_status; /* Minor status code */ #endif /* HAVE_GSSAPI */ @@ -326,11 +325,10 @@ httpClose(http_t *http) /* I - Connection to server */ #ifdef HAVE_GSSAPI if (http->gssctx != GSS_C_NO_CONTEXT) - major_status = gss_delete_sec_context(&minor_status, &http->gssctx, - GSS_C_NO_BUFFER); + gss_delete_sec_context(&minor_status, &http->gssctx, GSS_C_NO_BUFFER); if (http->gssname != GSS_C_NO_NAME) - major_status = gss_release_name(&minor_status, &http->gssname); + gss_release_name(&minor_status, &http->gssname); #endif /* HAVE_GSSAPI */ #ifdef HAVE_AUTHORIZATION_H diff --git a/cups/ipp.c b/cups/ipp.c index d528b6a54..88a42f01c 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -1050,9 +1050,9 @@ ippReadIO(void *src, /* I - Data source */ * Get the request header... */ - if ((n = (*cb)(src, buffer, 8)) < 8) + if ((*cb)(src, buffer, 8) < 8) { - DEBUG_printf(("ippReadIO: Unable to read header (%d bytes read)!\n", n)); + DEBUG_puts("ippReadIO: Unable to read header!"); return (IPP_ERROR); } @@ -1557,6 +1557,12 @@ ippReadIO(void *src, /* I - Data source */ return (IPP_ERROR); } + if (!value) + { + DEBUG_puts("ippReadIO: NULL value!"); + return (IPP_ERROR); + } + value->unknown.length = n; if (n > 0) { diff --git a/cups/langprintf.c b/cups/langprintf.c index 089eb4859..84956888c 100644 --- a/cups/langprintf.c +++ b/cups/langprintf.c @@ -71,9 +71,8 @@ _cupsLangPrintError(const char *message)/* I - Message */ * Format the message... */ - bytes = snprintf(buffer, sizeof(buffer), "%s: %s", - _cupsLangString(cg->lang_default, message), - strerror(last_errno)); + snprintf(buffer, sizeof(buffer), "%s: %s", + _cupsLangString(cg->lang_default, message), strerror(last_errno)); /* * Convert and write to stderr... @@ -120,8 +119,8 @@ _cupsLangPrintf(FILE *fp, /* I - File to write to */ */ va_start(ap, message); - bytes = vsnprintf(buffer, sizeof(buffer), - _cupsLangString(cg->lang_default, message), ap); + vsnprintf(buffer, sizeof(buffer), + _cupsLangString(cg->lang_default, message), ap); va_end(ap); /* diff --git a/cups/ppd.c b/cups/ppd.c index cbe20558f..c10cbc491 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -1088,7 +1088,7 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */ else if (!strcmp(string, "Plus90")) ppd->landscape = 90; } - else if (!strcmp(keyword, "Emulators")) + else if (!strcmp(keyword, "Emulators") && string) { for (count = 1, sptr = string; sptr != NULL;) if ((sptr = strchr(sptr, ' ')) != NULL) @@ -2850,8 +2850,6 @@ ppd_read(cups_file_t *fp, /* I - File to read from */ if (ch == 0x0a) cupsFileGetChar(fp); } - - ch = '\n'; } else if (ch < ' ' && ch != '\t' && cg->ppd_conform == PPD_CONFORM_STRICT) { diff --git a/cups/request.c b/cups/request.c index 36b02b912..f8978a627 100644 --- a/cups/request.c +++ b/cups/request.c @@ -572,7 +572,6 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP * Loop until we can send the request without authorization problems. */ - status = HTTP_ERROR; expect = HTTP_CONTINUE; for (;;) diff --git a/cups/sidechannel.c b/cups/sidechannel.c index bbb8dab02..acf9743e8 100644 --- a/cups/sidechannel.c +++ b/cups/sidechannel.c @@ -218,7 +218,7 @@ cupsSideChannelRead( *status = CUPS_SC_STATUS_TOO_BIG; } - else if (templen > *datalen || templen > (bytes - 4)) + else if (!datalen || templen > *datalen || templen > (bytes - 4)) { /* * Either the response is bigger than the provided buffer or the diff --git a/cups/testadmin.c b/cups/testadmin.c index 5091f11b8..f6afd21b9 100644 --- a/cups/testadmin.c +++ b/cups/testadmin.c @@ -61,7 +61,7 @@ main(int argc, /* I - Number of command-line args */ if (argc > 1) { - for (i = 1, num_settings = 0; i < argc; i ++) + for (i = 1, num_settings = 0, settings = NULL; i < argc; i ++) num_settings = cupsParseOptions(argv[i], num_settings, &settings); if (cupsAdminSetServerSettings(http, num_settings, settings)) diff --git a/cups/testcups.c b/cups/testcups.c index 1ac4456bd..087ed4310 100644 --- a/cups/testcups.c +++ b/cups/testcups.c @@ -3,7 +3,7 @@ * * CUPS API test program for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -155,7 +155,6 @@ main(int argc, /* I - Number of command-line arguments */ if ((dest = cupsGetDest(dests[num_dests / 2].name, NULL, num_dests, dests)) == NULL) { - status = 1; puts("FAIL"); return (1); } @@ -201,8 +200,8 @@ main(int argc, /* I - Number of command-line arguments */ if (cupsPrintFile(dest->name, "../data/testprint.ps", "Test Page", dest->num_options, dest->options) <= 0) { - status = 1; puts("FAIL"); + return (1); } else puts("PASS"); @@ -216,7 +215,6 @@ main(int argc, /* I - Number of command-line arguments */ if ((ppdfile = cupsGetPPD(dest->name)) == NULL) { - status = 1; puts("FAIL"); } else @@ -282,7 +280,7 @@ dests_equal(cups_dest_t *a, /* I - First destination */ if (a == b) return (1); - if ((!a && b) || (a && !b)) + if (!a || !b) return (0); if (strcasecmp(a->name, b->name) || @@ -345,5 +343,5 @@ show_diffs(cups_dest_t *a, /* I - First destination */ /* - * End of "$Id: testfile.c 6192 2007-01-10 19:26:48Z mike $". + * End of "$Id$". */ diff --git a/cups/testfile.c b/cups/testfile.c index 117b3c9e5..52bfeedb4 100644 --- a/cups/testfile.c +++ b/cups/testfile.c @@ -87,7 +87,7 @@ main(int argc, /* I - Number of command-line arguments */ * Do uncompressed random I/O tests... */ - status = random_tests(); + status += random_tests(); /* * Test fdopen and close without reading... diff --git a/cups/testhttp.c b/cups/testhttp.c index b445bf9d6..302d4fde5 100644 --- a/cups/testhttp.c +++ b/cups/testhttp.c @@ -3,7 +3,7 @@ * * HTTP test program for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -25,7 +25,7 @@ #include #include -#include "http.h" +#include "http-private.h" #include "string.h" @@ -452,6 +452,29 @@ main(int argc, /* I - Number of command-line arguments */ return (failures); } + else if (strstr(argv[1], "._tcp")) + { + /* + * Test resolving an mDNS name. + */ + + char resolved[1024]; /* Resolved URI */ + + + printf("_httpResolveURI(%s): ", argv[1]); + fflush(stdout); + + if (!_httpResolveURI(argv[1], resolved, sizeof(resolved))) + { + puts("FAIL"); + return (1); + } + else + { + printf("PASS (%s)\n", resolved); + return (0); + } + } /* * Test HTTP GET requests... diff --git a/desktop/cups.desktop b/desktop/cups.desktop index 1a9b33a76..1f264ad0a 100644 --- a/desktop/cups.desktop +++ b/desktop/cups.desktop @@ -27,6 +27,8 @@ Name[pl]=Zarządzanie drukowaniem Comment[pl]=Interfejs WWW CUPS Name[it]=Gestione stampa Comment[it]=Interfaccia web di CUPS +Name[ja]=印刷の管理 +Comment[ja]=CUPS Web インタフェース Name[he]=נהל הדפסות Comment[he]=ממשק דפדפן של CUPS Name[zh_TW]=印表管理 diff --git a/doc/help/ref-cupsd-conf.html.in b/doc/help/ref-cupsd-conf.html.in index b61ef0b66..37ddc448a 100644 --- a/doc/help/ref-cupsd-conf.html.in +++ b/doc/help/ref-cupsd-conf.html.in @@ -71,6 +71,38 @@ information to the system log instead of a plain file.

@CUPS_LOGDIR@/access_log.

+

AccessLogLevel

+ +

Examples

+ +
+AccessLogLevel config
+AccessLogLevel actions
+AccessLogLevel all
+
+ +

Description

+ +

The AccessLogLevel directive controls which requests are logged +to the access log file. The following levels are defined:

+ +
    + +
  • config; Log when printers and classes are added, + deleted, or modified and when configuration files are accessed or + updated.
  • + +
  • actions; Log when print jobs are submitted, + held, released, modified, or canceled, and any of the conditions + for config.
  • + +
  • all; Log all requests.
  • + +
+ +

The default access log level is @CUPS_ACCESS_LOG_LEVEL@.

+ +

Allow

Examples

@@ -1884,7 +1916,7 @@ everything under the preceding levels):

  • notice - Log temporary error conditions
  • info - Log all requests and state - changes (default)
  • + changes
  • debug - Log basic debugging information
  • @@ -1894,6 +1926,8 @@ everything under the preceding levels):

    +

    The default LogLevel is @CUPS_LOG_LEVEL@.

    +

    MaxClients

    diff --git a/driver/cmyk.c b/driver/cmyk.c index 01b87714d..b5ab4ede4 100644 --- a/driver/cmyk.c +++ b/driver/cmyk.c @@ -3,7 +3,7 @@ * * CMYK color separation code for CUPS. * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1993-2005 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -76,8 +76,6 @@ cupsCMYKDoBlack(const cups_cmyk_t *cmyk, { int k; /* Current black value */ const short **channels; /* Copy of channel LUTs */ - const unsigned char *black_lut, /* Black LUT */ - *color_lut; /* Color LUT */ int ink, /* Amount of ink */ ink_limit; /* Ink limit from separation */ @@ -94,8 +92,6 @@ cupsCMYKDoBlack(const cups_cmyk_t *cmyk, */ channels = (const short **)cmyk->channels; - black_lut = cmyk->black_lut; - color_lut = cmyk->color_lut; ink_limit = cmyk->ink_limit; switch (cmyk->num_channels) @@ -266,8 +262,6 @@ cupsCMYKDoCMYK(const cups_cmyk_t *cmyk, y, /* Current yellow value */ k; /* Current black value */ const short **channels; /* Copy of channel LUTs */ - const unsigned char *black_lut, /* Black LUT */ - *color_lut; /* Color LUT */ int ink, /* Amount of ink */ ink_limit; /* Ink limit from separation */ @@ -284,8 +278,6 @@ cupsCMYKDoCMYK(const cups_cmyk_t *cmyk, */ channels = (const short **)cmyk->channels; - black_lut = cmyk->black_lut; - color_lut = cmyk->color_lut; ink_limit = cmyk->ink_limit; switch (cmyk->num_channels) @@ -540,8 +532,6 @@ cupsCMYKDoGray(const cups_cmyk_t *cmyk, int k, /* Current black value */ kc; /* Current black color value */ const short **channels; /* Copy of channel LUTs */ - const unsigned char *black_lut, /* Black LUT */ - *color_lut; /* Color LUT */ int ink, /* Amount of ink */ ink_limit; /* Ink limit from separation */ @@ -558,8 +548,6 @@ cupsCMYKDoGray(const cups_cmyk_t *cmyk, */ channels = (const short **)cmyk->channels; - black_lut = cmyk->black_lut; - color_lut = cmyk->color_lut; ink_limit = cmyk->ink_limit; switch (cmyk->num_channels) @@ -775,8 +763,6 @@ cupsCMYKDoRGB(const cups_cmyk_t *cmyk, kc, /* Current black color value */ km; /* Maximum black value */ const short **channels; /* Copy of channel LUTs */ - const unsigned char *black_lut, /* Black LUT */ - *color_lut; /* Color LUT */ int ink, /* Amount of ink */ ink_limit; /* Ink limit from separation */ @@ -793,8 +779,6 @@ cupsCMYKDoRGB(const cups_cmyk_t *cmyk, */ channels = (const short **)cmyk->channels; - black_lut = cmyk->black_lut; - color_lut = cmyk->color_lut; ink_limit = cmyk->ink_limit; switch (cmyk->num_channels) diff --git a/driver/rastertoescpx.c b/driver/rastertoescpx.c index 362086e45..a60901190 100644 --- a/driver/rastertoescpx.c +++ b/driver/rastertoescpx.c @@ -913,6 +913,12 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ band->buffer = calloc(DotRowCount, DotBufferSize); } + if (!DotAvailList) + { + fputs("ERROR: Unable to allocate band list!\n", stderr); + exit(1); + } + fputs("DEBUG: Pointer list at start of page...\n", stderr); for (band = DotAvailList; band != NULL; band = band->next) @@ -1571,7 +1577,6 @@ ProcessLine(ppd_file_t *ppd, /* I - PPD file */ * Perform the color separation... */ - offset = 0; width = header->cupsWidth; subwidth = header->cupsWidth / DotColStep; xstep = 3600 / header->HWResolution[0]; diff --git a/filter/image-colorspace.c b/filter/image-colorspace.c index 01bed936c..8854a90bd 100644 --- a/filter/image-colorspace.c +++ b/filter/image-colorspace.c @@ -3,7 +3,7 @@ * * Colorspace conversions for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1993-2006 by Easy Software Products. * * The color saturation/hue matrix stuff is provided thanks to Mr. Paul @@ -507,8 +507,7 @@ cupsImageRGBAdjust(cups_ib_t *pixels, /* IO - Input/output pixels */ static cups_clut_t *lut = NULL; /* Lookup table for matrix */ - if (saturation != last_sat || - hue != last_hue) + if (saturation != last_sat || hue != last_hue || !lut) { /* * Build the color adjustment matrix... diff --git a/filter/image-gif.c b/filter/image-gif.c index caa39439e..d70230230 100644 --- a/filter/image-gif.c +++ b/filter/image-gif.c @@ -372,7 +372,6 @@ gif_get_code(FILE *fp, /* I - File to read from */ lastbit = last_byte * 8; } - ret = 0; for (ret = 0, i = curbit + code_size - 1, j = code_size; j > 0; i --, j --) @@ -611,6 +610,8 @@ gif_read_lzw(FILE *fp, /* I - File to read from */ return (firstcode); } + else if (!table) + return (0); if (sp > stack) return (*--sp); diff --git a/filter/pstops.c b/filter/pstops.c index 7517a4978..c6c1129a4 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -1054,7 +1054,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ */ if (!JobCanceled) - linelen = copy_trailer(fp, doc, ppd, number, line, linelen, linesize); + copy_trailer(fp, doc, ppd, number, line, linelen, linesize); } @@ -2227,7 +2227,6 @@ include_feature( char name[255], /* Option name */ value[255]; /* Option value */ ppd_option_t *option; /* Option in file */ - ppd_choice_t *choice; /* Choice */ /* @@ -2258,7 +2257,7 @@ include_feature( return (num_options); } - if ((choice = ppdFindChoice(option, value)) == NULL) + if (!ppdFindChoice(option, value)) { fprintf(stderr, _("WARNING: Unknown choice \"%s\" for option \"%s\"!\n"), value, name + 1); @@ -2917,10 +2916,7 @@ start_nup(pstops_doc_t *doc, /* I - Document information */ w / bboxw, l / bboxl); } else - { w = PageWidth; - l = PageLength; - } break; case 2 : diff --git a/filter/raster.c b/filter/raster.c index 015c5a8c4..bcfcd97b5 100644 --- a/filter/raster.c +++ b/filter/raster.c @@ -1015,8 +1015,7 @@ cups_raster_write( *plast; /* Pointer to last pixel */ unsigned char *wptr; /* Pointer into write buffer */ int bpp, /* Bytes per pixel */ - count, /* Count */ - maxrun; /* Maximum run of 128 * bpp */ + count; /* Count */ DEBUG_printf(("cups_raster_write(r=%p, pixels=%p)\n", r, pixels)); @@ -1049,7 +1048,6 @@ cups_raster_write( plast = pend - bpp; wptr = r->buffer; *wptr++ = r->count - 1; - maxrun = 128 * bpp; /* * Write using a modified TIFF "packbits" compression... diff --git a/filter/rastertolabel.c b/filter/rastertolabel.c index a529e281a..20cb77a44 100644 --- a/filter/rastertolabel.c +++ b/filter/rastertolabel.c @@ -1030,9 +1030,6 @@ PCLCompress(unsigned char *line, /* I - Line to compress */ comp_ptr += count; } - line_ptr = CompBuffer; - line_end = comp_ptr; - /* * Set the length of the data and write it... */ diff --git a/filter/testimage.c b/filter/testimage.c index 3a538830e..0c5727971 100644 --- a/filter/testimage.c +++ b/filter/testimage.c @@ -1,5 +1,5 @@ /* - * "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $" + * "$Id$" * * Image library test program for the Common UNIX Printing System (CUPS). * @@ -95,5 +95,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $". + * End of "$Id$". */ diff --git a/filter/texttops.c b/filter/texttops.c index e3391ad88..c84a447bc 100644 --- a/filter/texttops.c +++ b/filter/texttops.c @@ -3,7 +3,7 @@ * * Text to PostScript filter for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1993-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -1005,7 +1005,7 @@ write_line(int row, /* I - Row number (0 to N) */ lchar_t *start; /* First character in sequence */ - for (col = 0, start = line; col < SizeColumns;) + for (col = 0; col < SizeColumns;) { while (col < SizeColumns && (line->ch == ' ' || line->ch == 0)) { diff --git a/locale/strings2po.c b/locale/strings2po.c index ab9b09108..4eeb6a2e4 100644 --- a/locale/strings2po.c +++ b/locale/strings2po.c @@ -148,7 +148,7 @@ read_strings(FILE *strings, /* I - .strings file */ if (*bufptr != '\"') continue; - *bufptr++ = '\0'; + *bufptr = '\0'; return (1); } diff --git a/man/cupsd.conf.man.in b/man/cupsd.conf.man.in index 5423988e9..6fbdd31bb 100644 --- a/man/cupsd.conf.man.in +++ b/man/cupsd.conf.man.in @@ -33,6 +33,14 @@ AccessLog syslog .br Defines the access log filename. .TP 5 +AccessLogLevel config +.TP 5 +AccessLogLevel actions +.TP 5 +AccessLogLevel all +.br +Specifies the logging level for the AccessLog file. +.TP 5 Allow all .TP 5 Allow none diff --git a/man/mantohtml.c b/man/mantohtml.c index 12059ac45..01a475196 100644 --- a/man/mantohtml.c +++ b/man/mantohtml.c @@ -3,7 +3,7 @@ * * Man page to HTML conversion program. * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 2004-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -648,7 +648,6 @@ process_text: if (blist) { fputs("\n\n", outfile); - blist = 0; } if (list) @@ -659,7 +658,6 @@ process_text: fputs("\n", outfile); fputs("\n", outfile); - list = 0; } fputs("\n" diff --git a/packaging/cups.list.in b/packaging/cups.list.in index c0ffc9b52..648dcf6ca 100644 --- a/packaging/cups.list.in +++ b/packaging/cups.list.in @@ -293,7 +293,6 @@ f 0755 root sys $SERVERBIN/daemon/cups-deviced scheduler/cups-deviced f 0755 root sys $SERVERBIN/daemon/cups-driverd scheduler/cups-driverd f 0755 root sys $SERVERBIN/daemon/cups-polld scheduler/cups-polld d 0755 root sys $SERVERBIN/driver - -f 0755 root sys $SERVERBIN/driver/drv ppdc/drv d 0755 root sys $SERVERBIN/filter - f 0755 root sys $SERVERBIN/filter/commandtoespcx driver/commandtoescpx f 0755 root sys $SERVERBIN/filter/commandtopclx driver/commandtopclx diff --git a/packaging/cups.spec.in b/packaging/cups.spec.in index 3246b0b00..7b6e55b52 100644 --- a/packaging/cups.spec.in +++ b/packaging/cups.spec.in @@ -216,7 +216,6 @@ rm -rf $RPM_BUILD_ROOT /usr/lib/cups/daemon/cups-driverd /usr/lib/cups/daemon/cups-polld %dir /usr/lib/cups/driver -/usr/lib/cups/driver/drv %dir /usr/lib/cups/filter /usr/lib/cups/filter/* %dir /usr/lib/cups/monitor diff --git a/scheduler/classes.c b/scheduler/classes.c index 7fa3c4c5e..da828ce74 100644 --- a/scheduler/classes.c +++ b/scheduler/classes.c @@ -210,7 +210,8 @@ cupsdDeletePrinterFromClasses( c = (cupsd_printer_t *)cupsArrayNext(ImplicitPrinters)) if (c->num_printers == 0) { - cupsArrayRemove(ImplicitPrinters, c); + cupsdLogMessage(CUPSD_LOG_DEBUG, "Deleting implicit class \"%s\"...", + c->name); cupsdDeletePrinter(c, 0); } } @@ -600,7 +601,7 @@ cupsdLoadAllClasses(void) valueptr ++); if (*valueptr) - *valueptr++ = '\0'; + *valueptr = '\0'; cupsdSetString(&p->job_sheets[1], value); } diff --git a/scheduler/client.c b/scheduler/client.c index cf8365673..25be7a491 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -240,7 +240,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */ cupsdLogMessage(CUPSD_LOG_WARN, "Possible DoS attack - more than %d clients connecting " "from %s!", - MaxClientsPerHost, tempcon->http.hostname); + MaxClientsPerHost, con->http.hostname); } #ifdef WIN32 @@ -3246,15 +3246,15 @@ get_cdsa_certificate(cupsd_client_t *con) /* I - Client connection */ ssl_options; /* SSL Option for hostname */ - if ((err = SecPolicySearchCreate(CSSM_CERT_X_509v3, &CSSMOID_APPLE_TP_SSL, - NULL, &policy_search))) + if (SecPolicySearchCreate(CSSM_CERT_X_509v3, &CSSMOID_APPLE_TP_SSL, + NULL, &policy_search)) { cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot create a policy search reference"); CFRelease(keychain); return (NULL); } - if ((err = SecPolicySearchCopyNext(policy_search, &policy))) + if (SecPolicySearchCopyNext(policy_search, &policy)) { cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot find a policy to use for searching"); @@ -3271,7 +3271,7 @@ get_cdsa_certificate(cupsd_client_t *con) /* I - Client connection */ options.Data = (uint8 *)&ssl_options; options.Length = sizeof(ssl_options); - if ((err = SecPolicySetValue(policy, &options))) + if (SecPolicySetValue(policy, &options)) { cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot set policy value to use for searching"); @@ -3728,8 +3728,6 @@ is_cgi(cupsd_client_t *con, /* I - Client connection */ cupsdSetString(&con->command, filename); - filename = strrchr(filename, '/') + 1; /* Filename always absolute */ - if (options) cupsdSetStringf(&con->options, " %s", options); diff --git a/scheduler/conf.c b/scheduler/conf.c index 955dc2df1..78d5a413c 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -517,6 +517,7 @@ cupsdReadConfiguration(void) * Numeric options... */ + AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS; ConfigFilePerm = CUPS_DEFAULT_CONFIG_FILE_PERM; DefaultAuthType = CUPSD_AUTH_BASIC; #ifdef HAVE_SSL @@ -537,7 +538,7 @@ cupsdReadConfiguration(void) KeepAliveTimeout = DEFAULT_KEEPALIVE; ListenBackLog = SOMAXCONN; LogFilePerm = CUPS_DEFAULT_LOG_FILE_PERM; - LogLevel = CUPSD_LOG_ERROR; + LogLevel = CUPSD_LOG_WARN; MaxClients = 100; MaxClientsPerHost = 0; MaxLogSize = 1024 * 1024; @@ -2886,10 +2887,26 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown HostNameLookups %s on line %d.", value, linenum); } + else if (!strcasecmp(line, "AccessLogLevel") && value) + { + /* + * Amount of logging to do to access log... + */ + + if (!strcasecmp(value, "all")) + AccessLogLevel = CUPSD_ACCESSLOG_ALL; + else if (!strcasecmp(value, "actions")) + AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS; + else if (!strcasecmp(value, "config")) + AccessLogLevel = CUPSD_ACCESSLOG_CONFIG; + else + cupsdLogMessage(CUPSD_LOG_WARN, "Unknown AccessLogLevel %s on line %d.", + value, linenum); + } else if (!strcasecmp(line, "LogLevel") && value) { /* - * Amount of logging to do... + * Amount of logging to do to error log... */ if (!strcasecmp(value, "debug2")) diff --git a/scheduler/conf.h b/scheduler/conf.h index d5c483cc4..e3040d438 100644 --- a/scheduler/conf.h +++ b/scheduler/conf.h @@ -4,7 +4,7 @@ * Configuration file definitions for the Common UNIX Printing System (CUPS) * scheduler. * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -37,6 +37,13 @@ typedef enum CUPSD_LOG_DEBUG2 /* Detailed debugging */ } cupsd_loglevel_t; +typedef enum +{ + CUPSD_ACCESSLOG_CONFIG, /* Log config requests */ + CUPSD_ACCESSLOG_ACTIONS, /* Log config, print, and job management requests */ + CUPSD_ACCESSLOG_ALL /* Log everything */ +} cupsd_accesslog_t; + /* * Printcap formats... @@ -117,14 +124,16 @@ VAR uid_t User VALUE(1); /* User ID for server */ VAR gid_t Group VALUE(0); /* Group ID for server */ -VAR int ClassifyOverride VALUE(0), +VAR int AccessLogLevel VALUE(CUPSD_ACCESSLOG_ACTIONS), + /* Access log level */ + ClassifyOverride VALUE(0), /* Allow overrides? */ ConfigFilePerm VALUE(0640), /* Permissions for config files */ LogFilePerm VALUE(0644), /* Permissions for log files */ - LogLevel VALUE(CUPSD_LOG_ERROR), - /* Log level */ + LogLevel VALUE(CUPSD_LOG_WARN), + /* Error log level */ MaxClients VALUE(0), /* Maximum number of clients */ MaxClientsPerHost VALUE(0), diff --git a/scheduler/cups-deviced.c b/scheduler/cups-deviced.c index 4d05b53c0..3fb619e1e 100644 --- a/scheduler/cups-deviced.c +++ b/scheduler/cups-deviced.c @@ -347,8 +347,7 @@ add_device( const char *device_uri, /* I - Device URI */ const char *device_id) /* I - 1284 device ID */ { - cupsd_device_t *device, /* New device */ - *temp; /* Found device */ + cupsd_device_t *device; /* New device */ /* @@ -377,7 +376,7 @@ add_device( * Add the device to the array and return... */ - if ((temp = cupsArrayFind(devices, device)) != NULL) + if (cupsArrayFind(devices, device)) { /* * Avoid duplicates! diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index ca918c462..55ac71b68 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -287,19 +287,24 @@ main(int argc, /* I - Number of command-line arguments */ break; case 0x05 : /* Remove jobs */ - /* - * Grab the agent and skip to the list of users and/or jobs. - */ + if (list) + { + /* + * Grab the agent and skip to the list of users and/or jobs. + */ - agent = list; + agent = list; - for (; *list && !isspace(*list & 255); list ++); - while (isspace(*list & 255)) - *list++ = '\0'; + for (; *list && !isspace(*list & 255); list ++); + while (isspace(*list & 255)) + *list++ = '\0'; - syslog(LOG_INFO, "Remove jobs %s on %s by %s", list, dest, agent); + syslog(LOG_INFO, "Remove jobs %s on %s by %s", list, dest, agent); - status = remove_jobs(dest, agent, list); + status = remove_jobs(dest, agent, list); + } + else + status = 1; putchar(status); break; diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index 51509b850..f9c82f076 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -557,7 +557,7 @@ cupsdLoadRemoteCache(void) for (value = valueptr; *valueptr && !isspace(*valueptr & 255); valueptr ++); if (*valueptr) - *valueptr++ = '\0'; + *valueptr = '\0'; cupsdSetString(&p->job_sheets[1], value); } @@ -802,7 +802,7 @@ cupsdSendBrowseList(void) to; /* Timeout time */ - if (!Browsing || !BrowseLocalProtocols || !Printers) + if (!Browsing || !Printers) return; /* @@ -816,7 +816,7 @@ cupsdSendBrowseList(void) * Figure out how many printers need an update... */ - if (BrowseInterval > 0) + if (BrowseInterval > 0 && BrowseLocalProtocols) { int max_count; /* Maximum number to update */ @@ -894,7 +894,7 @@ cupsdSendBrowseList(void) } /* - * Loop through all of the printers and send local updates as needed... + * Loop through all of the printers and timeout old printers as needed... */ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); @@ -905,25 +905,24 @@ cupsdSendBrowseList(void) * If this is a remote queue, see if it needs to be timed out... */ - if (p->type & CUPS_PRINTER_DISCOVERED) + if ((p->type & CUPS_PRINTER_DISCOVERED) && + !(p->type & CUPS_PRINTER_IMPLICIT) && + p->browse_expire < to) { - if (p->browse_expire < to) - { - cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL, - "%s \'%s\' deleted by directory services (timeout).", - (p->type & CUPS_PRINTER_CLASS) ? "Class" : "Printer", - p->name); + cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL, + "%s \'%s\' deleted by directory services (timeout).", + (p->type & CUPS_PRINTER_CLASS) ? "Class" : "Printer", + p->name); - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Remote destination \"%s\" has timed out; " - "deleting it...", - p->name); + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Remote destination \"%s\" has timed out; " + "deleting it...", + p->name); - cupsArraySave(Printers); - cupsdDeletePrinter(p, 1); - cupsArrayRestore(Printers); - cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP | CUPSD_DIRTY_REMOTE); - } + cupsArraySave(Printers); + cupsdDeletePrinter(p, 1); + cupsArrayRestore(Printers); + cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP | CUPSD_DIRTY_REMOTE); } } } @@ -2439,13 +2438,23 @@ process_browse_data( newname[IPP_MAX_NAME], /* New name of printer */ *hptr, /* Pointer into hostname */ *sptr; /* Pointer into ServerName */ + const char *shortname; /* Short queue name (queue) */ char local_make_model[IPP_MAX_NAME]; /* Local make and model */ cupsd_printer_t *p; /* Printer information */ const char *ipp_options, /* ipp-options value */ *lease_duration; /* lease-duration value */ + int is_class; /* Is this queue a class? */ + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "process_browse_data(uri=\"%s\", host=\"%s\", " + "resource=\"%s\", type=%x, state=%d, location=\"%s\", " + "info=\"%s\", make_model=\"%s\", num_attrs=%d, attrs=%p)", + uri, host, resource, type, state, + location ? location : "(nil)", info ? info : "(nil)", + make_model ? make_model : "(nil)", num_attrs, attrs); + /* * Determine if the URI contains any illegal characters in it... */ @@ -2454,9 +2463,7 @@ process_browse_data( (strncmp(resource, "/printers/", 10) && strncmp(resource, "/classes/", 9))) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "process_browse_data: Bad printer URI in browse data: %s", - uri); + cupsdLogMessage(CUPSD_LOG_ERROR, "Bad printer URI in browse data: %s", uri); return; } @@ -2464,8 +2471,7 @@ process_browse_data( (!strncmp(resource, "/printers/", 10) && strchr(resource + 10, '/')) || (!strncmp(resource, "/classes/", 9) && strchr(resource + 9, '/'))) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "process_browse_data: Bad resource in browse data: %s", + cupsdLogMessage(CUPSD_LOG_ERROR, "Bad resource in browse data: %s", resource); return; } @@ -2520,11 +2526,12 @@ process_browse_data( * See if we already have it listed in the Printers list, and add it if not... */ - type |= CUPS_PRINTER_REMOTE | CUPS_PRINTER_DISCOVERED; - type &= ~CUPS_PRINTER_IMPLICIT; - update = 0; - hptr = strchr(host, '.'); - sptr = strchr(ServerName, '.'); + type |= CUPS_PRINTER_REMOTE | CUPS_PRINTER_DISCOVERED; + type &= ~CUPS_PRINTER_IMPLICIT; + update = 0; + hptr = strchr(host, '.'); + sptr = strchr(ServerName, '.'); + is_class = type & CUPS_PRINTER_CLASS; if (!ServerNameIsIP && sptr != NULL && hptr != NULL) { @@ -2544,7 +2551,7 @@ process_browse_data( } } - if (type & CUPS_PRINTER_CLASS) + if (is_class) { /* * Remote destination is a class... @@ -2555,210 +2562,140 @@ process_browse_data( else return; - if (hptr && !*hptr) - *hptr = '.'; /* Resource FQDN */ + shortname = resource + 9; + } + else + { + /* + * Remote destination is a printer... + */ - if ((p = cupsdFindDest(name)) == NULL && BrowseShortNames) - { - if ((p = cupsdFindDest(resource + 9)) != NULL) - { - if (p->hostname && strcasecmp(p->hostname, host)) - { - /* - * Nope, this isn't the same host; if the hostname isn't the local host, - * add it to the other class and then find a class using the full host - * name... - */ + if (!strncmp(resource, "/printers/", 10)) + snprintf(name, sizeof(name), "%s@%s", resource + 10, host); + else + return; - if (p->type & CUPS_PRINTER_REMOTE) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Renamed remote class \"%s\" to \"%s@%s\"...", - p->name, p->name, p->hostname); - cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL, - "Class \'%s\' deleted by directory services.", - p->name); - - snprintf(newname, sizeof(newname), "%s@%s", p->name, p->hostname); - cupsdRenamePrinter(p, newname); - - cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, - "Class \'%s\' added by directory services.", - p->name); - } + shortname = resource + 10; + } - p = NULL; - } - else if (!p->hostname) - { - /* - * Hostname not set, so this must be a cached remote printer - * that was created for a pending print job... - */ + if (hptr && !*hptr) + *hptr = '.'; /* Resource FQDN */ - cupsdSetString(&p->hostname, host); - cupsdSetString(&p->uri, uri); - cupsdSetString(&p->device_uri, uri); - update = 1; - } - } - else - { - /* - * Use the short name for this shared class. - */ + if ((p = cupsdFindDest(name)) == NULL && BrowseShortNames) + { + /* + * Long name doesn't exist, try short name... + */ - strlcpy(name, resource + 9, sizeof(name)); - } - } - else if (p && !p->hostname) + cupsdLogMessage(CUPSD_LOG_DEBUG, "process_browse_data: %s not found...", + name); + + if ((p = cupsdFindDest(shortname)) == NULL) { /* - * Hostname not set, so this must be a cached remote printer - * that was created for a pending print job... + * Short name doesn't exist, use it for this shared queue. */ - cupsdSetString(&p->hostname, host); - cupsdSetString(&p->uri, uri); - cupsdSetString(&p->device_uri, uri); - update = 1; + cupsdLogMessage(CUPSD_LOG_DEBUG2, "process_browse_data: %s not found...", + shortname); + strlcpy(name, shortname, sizeof(name)); } - - if (!p) + else { /* - * Class doesn't exist; add it... + * Short name exists... */ - p = cupsdAddClass(name); - - cupsdLogMessage(CUPSD_LOG_DEBUG, "Added remote class \"%s\"...", name); - - cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, - "Class \'%s\' added by directory services.", name); + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "process_browse_data: %s found, type=%x, hostname=%s...", + shortname, p->type, p->hostname ? p->hostname : "(nil)"); - /* - * Force the URI to point to the real server... - */ + if (p->type & CUPS_PRINTER_IMPLICIT) + p = NULL; /* Don't replace implicit classes */ + else if (p->hostname && strcasecmp(p->hostname, host)) + { + /* + * Short name exists but is for a different host. If this is a remote + * queue, rename it and use the long name... + */ - p->type = type & ~CUPS_PRINTER_REJECTING; - p->accepting = 1; - cupsdSetString(&p->uri, uri); - cupsdSetString(&p->device_uri, uri); - cupsdSetString(&p->hostname, host); + if (p->type & CUPS_PRINTER_REMOTE) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Renamed remote %s \"%s\" to \"%s@%s\"...", + is_class ? "class" : "printer", p->name, p->name, + p->hostname); + cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL, + "%s \'%s\' deleted by directory services.", + is_class ? "Class" : "Printer", p->name); + + snprintf(newname, sizeof(newname), "%s@%s", p->name, p->hostname); + cupsdRenamePrinter(p, newname); + + cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, + "%s \'%s\' added by directory services.", + is_class ? "Class" : "Printer", p->name); + } - update = 1; + /* + * Force creation with long name... + */ - cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP | CUPSD_DIRTY_REMOTE); + p = NULL; + } } } else + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "process_browse_data: %s found, type=%x, hostname=%s...", + name, p->type, p->hostname ? p->hostname : "(nil)"); + + if (!p) { /* - * Remote destination is a printer... + * Queue doesn't exist; add it... */ - if (!strncmp(resource, "/printers/", 10)) - snprintf(name, sizeof(name), "%s@%s", resource + 10, host); + if (is_class) + p = cupsdAddClass(name); else - return; - - if (hptr && !*hptr) - *hptr = '.'; /* Resource FQDN */ - - if ((p = cupsdFindDest(name)) == NULL && BrowseShortNames) - { - if ((p = cupsdFindDest(resource + 10)) != NULL) - { - if (p->hostname && strcasecmp(p->hostname, host)) - { - /* - * Nope, this isn't the same host; if the hostname isn't the local host, - * add it to the other printer and then find a printer using the full host - * name... - */ - - if (p->type & CUPS_PRINTER_REMOTE) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Renamed remote printer \"%s\" to \"%s@%s\"...", - p->name, p->name, p->hostname); - cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL, - "Printer \'%s\' deleted by directory services.", - p->name); - - snprintf(newname, sizeof(newname), "%s@%s", p->name, p->hostname); - cupsdRenamePrinter(p, newname); - - cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, - "Printer \'%s\' added by directory services.", - p->name); - } - - p = NULL; - } - else if (!p->hostname) - { - /* - * Hostname not set, so this must be a cached remote printer - * that was created for a pending print job... - */ - - cupsdSetString(&p->hostname, host); - cupsdSetString(&p->uri, uri); - cupsdSetString(&p->device_uri, uri); - update = 1; - } - } - else - { - /* - * Use the short name for this shared printer. - */ + p = cupsdAddPrinter(name); - strlcpy(name, resource + 10, sizeof(name)); - } - } - else if (p && !p->hostname) - { - /* - * Hostname not set, so this must be a cached remote printer - * that was created for a pending print job... - */ + cupsdClearString(&(p->hostname)); - cupsdSetString(&p->hostname, host); - cupsdSetString(&p->uri, uri); - cupsdSetString(&p->device_uri, uri); - update = 1; - } + cupsdLogMessage(CUPSD_LOG_DEBUG, "Added remote %s \"%s\"...", + is_class ? "class" : "printer", name); - if (!p) - { - /* - * Printer doesn't exist; add it... - */ + cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, + "%s \'%s\' added by directory services.", + is_class ? "Class" : "Printer", name); - p = cupsdAddPrinter(name); + /* + * Force the URI to point to the real server... + */ - cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, - "Printer \'%s\' added by directory services.", name); + p->type = type & ~CUPS_PRINTER_REJECTING; + p->accepting = 1; - cupsdLogMessage(CUPSD_LOG_DEBUG, "Added remote printer \"%s\"...", name); + cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP); + } - /* - * Force the URI to point to the real server... - */ + if (!p) + return; - p->type = type & ~CUPS_PRINTER_REJECTING; - p->accepting = 1; - cupsdSetString(&p->hostname, host); - cupsdSetString(&p->uri, uri); - cupsdSetString(&p->device_uri, uri); + if (!p->hostname) + { + /* + * Hostname not set, so this must be a cached remote printer + * that was created for a pending print job... + */ - update = 1; + cupsdSetString(&p->hostname, host); + cupsdSetString(&p->uri, uri); + cupsdSetString(&p->device_uri, uri); + update = 1; - cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP | CUPSD_DIRTY_REMOTE); - } + cupsdMarkDirty(CUPSD_DIRTY_REMOTE); } /* @@ -2823,7 +2760,7 @@ process_browse_data( if (!make_model || !make_model[0]) { - if (type & CUPS_PRINTER_CLASS) + if (is_class) snprintf(local_make_model, sizeof(local_make_model), "Remote Class on %s", host); else @@ -2877,7 +2814,7 @@ process_browse_data( { cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL, "%s \'%s\' deleted by directory services.", - (type & CUPS_PRINTER_CLASS) ? "Class" : "Printer", p->name); + is_class ? "Class" : "Printer", p->name); cupsdExpireSubscriptions(p, NULL); diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 7562cd9e2..621663e3a 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1670,8 +1670,7 @@ add_job(cupsd_client_t *con, /* I - Client connection */ IPP_TAG_INTEGER)) != NULL) attr->values[0].integer = 0; else - attr = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, - "job-k-octets", 0); + ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-k-octets", 0); if ((attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_KEYWORD)) == NULL) @@ -2001,9 +2000,7 @@ add_job_subscriptions( * none... */ - for (attr = job->attrs->attrs, prev = NULL; - attr; - prev = attr, attr = attr->next) + for (attr = job->attrs->attrs; attr; attr = attr->next) if (attr->group_tag == IPP_TAG_SUBSCRIPTION) break; @@ -2175,6 +2172,9 @@ add_job_subscriptions( /* * Remove all of the subscription attributes from the job request... + * + * TODO: Optimize this since subscription groups have to come at the + * end of the request... */ for (attr = job->attrs->attrs, prev = NULL; attr; attr = next) @@ -3480,7 +3480,8 @@ apply_printer_defaults( * job object... */ - for (i = printer->num_options, num_options = 0, option = printer->options; + for (i = printer->num_options, num_options = 0, options = NULL, + option = printer->options; i > 0; i --, option ++) if (!ippFindAttribute(job->attrs, option->name, IPP_TAG_ZERO)) @@ -5033,8 +5034,6 @@ copy_model(cupsd_client_t *con, /* I - Client connection */ * See if we have data ready... */ - bytes = 0; - FD_ZERO(&input); FD_SET(temppipe[0], &input); FD_SET(CGIPipes[0], &input); @@ -9845,9 +9844,9 @@ send_http_error( static void send_ipp_status(cupsd_client_t *con, /* I - Client connection */ - ipp_status_t status, /* I - IPP status code */ - const char *message, /* I - Status message */ - ...) /* I - Additional args as needed */ + ipp_status_t status, /* I - IPP status code */ + const char *message,/* I - Status message */ + ...) /* I - Additional args as needed */ { va_list ap; /* Pointer to additional args */ char formatted[1024]; /* Formatted errror message */ diff --git a/scheduler/job.c b/scheduler/job.c index 8dbee2b59..9b025a387 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -2436,8 +2436,8 @@ set_hold_until(cupsd_job_t *job, /* I - Job to update */ */ if (attr == NULL) - attr = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, - "job-hold-until", NULL, holdstr); + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-hold-until", + NULL, holdstr); else cupsdSetString(&attr->values[0].string.text, holdstr); @@ -2821,7 +2821,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ i = ipp_length(job->attrs); - if (i > optlength) + if (i > optlength || !options) { if (optlength == 0) optptr = malloc(i); @@ -3807,23 +3807,25 @@ update_job(cupsd_job_t *job) /* I - Job to check */ { cupsdLogJob(job, loglevel, "%s", message); - strlcpy(job->printer->state_message, message, - sizeof(job->printer->state_message)); - cupsdAddPrinterHistory(job->printer); + if (loglevel < CUPSD_LOG_DEBUG) + { + strlcpy(job->printer->state_message, message, + sizeof(job->printer->state_message)); + cupsdAddPrinterHistory(job->printer); - if (loglevel <= CUPSD_LOG_INFO) event |= CUPSD_EVENT_PRINTER_STATE; - if (loglevel <= job->status_level) - { - /* - * Some messages show in the printer-state-message attribute... - */ + if (loglevel <= job->status_level) + { + /* + * Some messages show in the printer-state-message attribute... + */ - if (loglevel != CUPSD_LOG_NOTICE) - job->status_level = loglevel; + if (loglevel != CUPSD_LOG_NOTICE) + job->status_level = loglevel; - update_job_attrs(job, 1); + update_job_attrs(job, 1); + } } } diff --git a/scheduler/log.c b/scheduler/log.c index ea6d7755d..1eb10c2d0 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -150,12 +150,8 @@ cupsdLogGSSMessage( &major_status_string); if (!GSS_ERROR(err_major_status)) - err_major_status = gss_display_status(&err_minor_status, - minor_status, - GSS_C_MECH_CODE, - GSS_C_NULL_OID, - &msg_ctx, - &minor_status_string); + gss_display_status(&err_minor_status, minor_status, GSS_C_MECH_CODE, + GSS_C_NULL_OID, &msg_ctx, &minor_status_string); ret = cupsdLogMessage(level, "%s: %s, %s", message, (char *)major_status_string.value, @@ -481,6 +477,112 @@ cupsdLogRequest(cupsd_client_t *con, /* I - Request to log */ }; + /* + * Filter requests as needed... + */ + + if (AccessLogLevel < CUPSD_ACCESSLOG_ALL) + { + /* + * Eliminate simple GET requests... + */ + + if ((con->operation == HTTP_GET && + strncmp(con->uri, "/admin/conf", 11) && + 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)) + return (1); + + if (con->request && con->response && + con->response->request.status.status_code < IPP_REDIRECTION_OTHER_SITE) + { + /* + * Check successful requests... + */ + + ipp_op_t op = con->request->request.op.operation_id; + static cupsd_accesslog_t standard_ops[] = + { + CUPSD_ACCESSLOG_ALL, /* reserved */ + CUPSD_ACCESSLOG_ALL, /* reserved */ + CUPSD_ACCESSLOG_ACTIONS,/* Print-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Print-URI */ + CUPSD_ACCESSLOG_ACTIONS,/* Validate-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Create-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Send-Document */ + CUPSD_ACCESSLOG_ACTIONS,/* Send-URI */ + CUPSD_ACCESSLOG_ACTIONS,/* Cancel-Job */ + CUPSD_ACCESSLOG_ALL, /* Get-Job-Attributes */ + CUPSD_ACCESSLOG_ALL, /* Get-Jobs */ + CUPSD_ACCESSLOG_ALL, /* Get-Printer-Attributes */ + CUPSD_ACCESSLOG_ACTIONS,/* Hold-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Release-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Restart-Job */ + CUPSD_ACCESSLOG_ALL, /* reserved */ + CUPSD_ACCESSLOG_CONFIG, /* Pause-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* Resume-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* Purge-Jobs */ + CUPSD_ACCESSLOG_CONFIG, /* Set-Printer-Attributes */ + CUPSD_ACCESSLOG_ACTIONS,/* Set-Job-Attributes */ + CUPSD_ACCESSLOG_CONFIG, /* Get-Printer-Supported-Values */ + CUPSD_ACCESSLOG_ACTIONS,/* Create-Printer-Subscription */ + CUPSD_ACCESSLOG_ACTIONS,/* Create-Job-Subscription */ + CUPSD_ACCESSLOG_ALL, /* Get-Subscription-Attributes */ + CUPSD_ACCESSLOG_ALL, /* Get-Subscriptions */ + CUPSD_ACCESSLOG_ACTIONS,/* Renew-Subscription */ + CUPSD_ACCESSLOG_ACTIONS,/* Cancel-Subscription */ + CUPSD_ACCESSLOG_ALL, /* Get-Notifications */ + CUPSD_ACCESSLOG_ACTIONS,/* Send-Notifications */ + CUPSD_ACCESSLOG_ALL, /* reserved */ + CUPSD_ACCESSLOG_ALL, /* reserved */ + CUPSD_ACCESSLOG_ALL, /* reserved */ + CUPSD_ACCESSLOG_ALL, /* Get-Print-Support-Files */ + CUPSD_ACCESSLOG_CONFIG, /* Enable-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* Disable-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* Pause-Printer-After-Current-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Hold-New-Jobs */ + CUPSD_ACCESSLOG_ACTIONS,/* Release-Held-New-Jobs */ + CUPSD_ACCESSLOG_CONFIG, /* Deactivate-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* Activate-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* Restart-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* Shutdown-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* Startup-Printer */ + CUPSD_ACCESSLOG_ACTIONS,/* Reprocess-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Cancel-Current-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Suspend-Current-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Resume-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* Promote-Job */ + CUPSD_ACCESSLOG_ACTIONS /* Schedule-Job-After */ + }; + static cupsd_accesslog_t cups_ops[] = + { + CUPSD_ACCESSLOG_ALL, /* CUPS-Get-Default */ + CUPSD_ACCESSLOG_ALL, /* CUPS-Get-Printers */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Add-Modify-Printer */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Delete-Printer */ + CUPSD_ACCESSLOG_ALL, /* CUPS-Get-Classes */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Add-Modify-Class */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Delete-Class */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Accept-Jobs */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Reject-Jobs */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Set-Default */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Get-Devices */ + CUPSD_ACCESSLOG_CONFIG, /* CUPS-Get-PPDs */ + CUPSD_ACCESSLOG_ACTIONS,/* CUPS-Move-Job */ + CUPSD_ACCESSLOG_ACTIONS,/* CUPS-Authenticate-Job */ + CUPSD_ACCESSLOG_ALL /* CUPS-Get-PPD */ + }; + + + if ((op <= IPP_SCHEDULE_JOB_AFTER && standard_ops[op] > AccessLogLevel) || + (op >= CUPS_GET_DEFAULT && op <= CUPS_GET_PPD && + cups_ops[op - CUPS_GET_DEFAULT] > AccessLogLevel)) + return (1); + } + } + #ifdef HAVE_VSYSLOG /* * See if we are logging accesses via syslog... @@ -818,7 +920,7 @@ format_log_line(const char *message, /* I - Printf-style format string */ log_linesize = len; } - len = vsnprintf(log_line, log_linesize, message, ap); + vsnprintf(log_line, log_linesize, message, ap); } return (log_line); diff --git a/scheduler/main.c b/scheduler/main.c index e3319467a..b6beb3ee0 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -941,7 +941,7 @@ main(int argc, /* I - Number of command-line args */ #endif /* HAVE_LDAP */ } - if (Browsing && BrowseLocalProtocols && current_time > browse_time) + if (Browsing && current_time > browse_time) { cupsdSendBrowseList(); browse_time = current_time; diff --git a/scheduler/printers.c b/scheduler/printers.c index c5f4a91a9..c675e090d 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -133,6 +133,8 @@ cupsdAddPrinter(const char *name) /* I - Name of printer */ if (!Printers) Printers = cupsArrayNew(compare_printers, NULL); + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdAddPrinter: Adding %s to Printers", p->name); cupsArrayAdd(Printers, p); if (!ImplicitPrinters) @@ -640,10 +642,17 @@ cupsdDeletePrinter( * Remove the printer from the list... */ + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdDeletePrinter: Removing %s from Printers", p->name); cupsArrayRemove(Printers, p); if (p->type & CUPS_PRINTER_IMPLICIT) + { + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdDeletePrinter: Removing %s from ImplicitPrinters", + p->name); cupsArrayRemove(ImplicitPrinters, p); + } /* * Remove the dummy interface/icon/option files under IRIX... @@ -1128,7 +1137,7 @@ cupsdLoadAllPrinters(void) for (value = valueptr; *valueptr && !isspace(*valueptr & 255); valueptr ++); if (*valueptr) - *valueptr++ = '\0'; + *valueptr = '\0'; cupsdSetString(&p->job_sheets[1], value); } @@ -1285,10 +1294,17 @@ cupsdRenamePrinter( * Remove the printer from the array(s) first... */ + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdRenamePrinter: Removing %s from Printers", p->name); cupsArrayRemove(Printers, p); if (p->type & CUPS_PRINTER_IMPLICIT) + { + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdRenamePrinter: Removing %s from ImplicitPrinters", + p->name); cupsArrayRemove(ImplicitPrinters, p); + } /* * Rename the printer type... @@ -1316,10 +1332,17 @@ cupsdRenamePrinter( * Add the printer back to the printer array(s)... */ + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdRenamePrinter: Adding %s to Printers", p->name); cupsArrayAdd(Printers, p); if (p->type & CUPS_PRINTER_IMPLICIT) + { + cupsdLogMessage(CUPSD_LOG_DEBUG2, + "cupsdRenamePrinter: Adding %s to ImplicitPrinters", + p->name); cupsArrayAdd(ImplicitPrinters, p); + } } @@ -1574,7 +1597,7 @@ cupsdSaveAllPrinters(void) { cupsFilePrintf(fp, "Attribute %s ", marker->name); - if (!ptr && (ptr = strchr(marker->values[0].string.text, '#')) != NULL) + if ((ptr = strchr(marker->values[0].string.text, '#')) != NULL) { cupsFileWrite(fp, marker->values[0].string.text, ptr - marker->values[0].string.text); @@ -3740,7 +3763,7 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */ * Add all of the default options from the .conf files... */ - for (num_options = 0, i = p->num_options, option = p->options; + for (num_options = 0, options = NULL, i = p->num_options, option = p->options; i > 0; i --, option ++) { @@ -3825,7 +3848,8 @@ add_printer_filter( * super/type cost program */ - if (sscanf(filter, "%15[^/]/%31s%d%1023s", super, type, &cost, program) != 4) + if (sscanf(filter, "%15[^/]/%31s%d%*[ \t]%1023[^\n]", super, type, &cost, + program) != 4) { cupsdLogMessage(CUPSD_LOG_ERROR, "%s: invalid filter string \"%s\"!", p->name, filter); diff --git a/scheduler/removefile.c b/scheduler/removefile.c index 10de4ea74..5cf16bfda 100644 --- a/scheduler/removefile.c +++ b/scheduler/removefile.c @@ -196,8 +196,9 @@ overwrite_data(int fd, /* I - File descriptor */ #ifdef TEST +# define testmain main int -main(void) +testmain(void) { FILE *fp; diff --git a/scheduler/select.c b/scheduler/select.c index 6f6843685..20c9547fd 100644 --- a/scheduler/select.c +++ b/scheduler/select.c @@ -3,7 +3,7 @@ * * Select abstraction functions for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 2006-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -259,7 +259,9 @@ cupsdAddSelect(int fd, /* I - File descriptor */ void *data) /* I - Data to pass to callback */ { _cupsd_fd_t *fdptr; /* File descriptor record */ +#ifdef HAVE_EPOLL int added; /* 1 if added, 0 if modified */ +#endif /* HAVE_EPOLL */ /* @@ -296,10 +298,14 @@ cupsdAddSelect(int fd, /* I - File descriptor */ return (0); } +#ifdef HAVE_EPOLL added = 1; } else added = 0; +#else + } +#endif /* HAVE_EPOLL */ #ifdef HAVE_KQUEUE { diff --git a/scheduler/testspeed.c b/scheduler/testspeed.c index 11cdfcae6..c9fe4ed68 100644 --- a/scheduler/testspeed.c +++ b/scheduler/testspeed.c @@ -305,8 +305,6 @@ do_test(const char *server, /* I - Server to use */ case IPP_PRINT_JOB : ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "ipp://localhost/printers/test"); - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-hold-until", - NULL, "indefinite"); ippDelete(cupsDoFileRequest(http, request, "/printers/test", "../data/testprint.ps")); break; diff --git a/scheduler/type.c b/scheduler/type.c index 6532b9c08..e93720d07 100644 --- a/scheduler/type.c +++ b/scheduler/type.c @@ -284,8 +284,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ while (isalnum(*rule & 255) && (ptr - name) < (sizeof(name) - 1)) *ptr++ = *rule++; - *ptr = '\0'; - num_values = 0; + *ptr = '\0'; if (*rule == '(') { @@ -415,7 +414,6 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ snprintf(value[0], sizeof(value[0]), "*.%s", name); length[0] = strlen(value[0]); - num_values = 1; op = MIME_MAGIC_MATCH; } diff --git a/systemv/cancel.c b/systemv/cancel.c index 8d057bbdd..7b4d0db4d 100644 --- a/systemv/cancel.c +++ b/systemv/cancel.c @@ -3,7 +3,7 @@ * * "cancel" command for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -59,7 +59,6 @@ main(int argc, /* I - Number of command-line arguments */ op = IPP_CANCEL_JOB; purge = 0; - job_id = 0; dest = NULL; user = NULL; http = NULL; diff --git a/systemv/cupsctl.c b/systemv/cupsctl.c index 1cd6fc832..9c8e4f8c1 100644 --- a/systemv/cupsctl.c +++ b/systemv/cupsctl.c @@ -1,5 +1,5 @@ /* - * "$Id: cupsctl.c 6379 2007-03-21 14:57:22Z mike $" + * "$Id$" * * CUPS control program for the Common UNIX Printing System (CUPS). * @@ -222,5 +222,5 @@ usage(const char *opt) /* I - Option character/string */ /* - * End of "$Id: cupsctl.c 6379 2007-03-21 14:57:22Z mike $". + * End of "$Id$". */ diff --git a/systemv/cupstestdsc.c b/systemv/cupstestdsc.c index ce4a8a707..e2267c2ad 100644 --- a/systemv/cupstestdsc.c +++ b/systemv/cupstestdsc.c @@ -3,7 +3,7 @@ * * DSC test program for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -192,7 +192,6 @@ check_file(const char *filename) /* I - File to read from */ if (!status) _cupsLangPuts(stdout, _("FAIL\n")); - status ++; _cupsLangPuts(stdout, _(" Missing %!PS-Adobe-3.0 on first line!\n" " REF: Page 17, 3.1 Conforming Documents\n")); diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index b3b3ff0ce..b23175649 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -1628,12 +1628,12 @@ check_basics(const char *filename) /* I - PPD file to check */ if (eol == EOL_NONE) eol = EOL_CRLF; - else + else if (eol != EOL_CRLF) mixed = 1; } else if (eol == EOL_NONE) eol = EOL_CR; - else + else if (eol != EOL_CR) mixed = 1; } @@ -1831,11 +1831,12 @@ check_filters(ppd_file_t *ppd, /* I - PPD file */ int verbose, /* I - Verbosity level */ int warn) /* I - Warnings only? */ { + int i; /* Looping var */ ppd_attr_t *attr; /* PPD attribute */ const char *ptr; /* Pointer into string */ char super[16], /* Super-type for filter */ type[256], /* Type for filter */ - program[256], /* Program/filter name */ + program[1024], /* Program/filter name */ pathprog[1024]; /* Complete path to program/filter */ int cost; /* Cost of filter */ const char *prefix; /* WARN/FAIL prefix */ @@ -1843,13 +1844,10 @@ check_filters(ppd_file_t *ppd, /* I - PPD file */ prefix = warn ? " WARN " : "**FAIL**"; - for (attr = ppdFindAttr(ppd, "cupsFilter", NULL); - attr; - attr = ppdFindNextAttr(ppd, "cupsFilter", NULL)) + for (i = 0; i < ppd->num_filters; i ++) { - if (!attr->value || - sscanf(attr->value, "%15[^/]/%255s%d%255s", super, type, &cost, - program) != 4) + if (sscanf(ppd->filters[i], "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type, + &cost, program) != 4) { if (!warn && !errors && !verbose) _cupsLangPuts(stdout, _(" FAIL\n")); @@ -1857,7 +1855,7 @@ check_filters(ppd_file_t *ppd, /* I - PPD file */ if (verbose >= 0) _cupsLangPrintf(stdout, _(" %s Bad cupsFilter value \"%s\"!\n"), - prefix, attr->value ? attr->value : ""); + prefix, ppd->filters[i]); if (!warn) errors ++; @@ -1899,8 +1897,8 @@ check_filters(ppd_file_t *ppd, /* I - PPD file */ attr = ppdFindNextAttr(ppd, "cupsPreFilter", NULL)) { if (!attr->value || - sscanf(attr->value, "%15[^/]/%255s%d%255s", super, type, &cost, - program) != 4) + sscanf(attr->value, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type, + &cost, program) != 4) { if (!warn && !errors && !verbose) _cupsLangPuts(stdout, _(" FAIL\n")); diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c index 4448ecf62..5ee882342 100644 --- a/systemv/lpadmin.c +++ b/systemv/lpadmin.c @@ -3,7 +3,7 @@ * * "lpadmin" command for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -914,12 +914,13 @@ add_printer_to_class(http_t *http, /* I - Server connection */ attr = ippAddStrings(request, IPP_TAG_PRINTER, IPP_TAG_URI, "member-uris", members->num_values + 1, NULL, NULL); for (i = 0; i < members->num_values; i ++) - attr->values[i].string.text = strdup(members->values[i].string.text); + attr->values[i].string.text = _cupsStrAlloc(members->values[i].string.text); - attr->values[i].string.text = strdup(uri); + attr->values[i].string.text = _cupsStrAlloc(uri); } else - attr = ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "member-uris", NULL, uri); + ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "member-uris", NULL, + uri); /* * Then send the request... @@ -1189,7 +1190,8 @@ delete_printer_from_class( for (j = 0, k = 0; j < members->num_values; j ++) if (j != i) - attr->values[k ++].string.text = strdup(members->values[j].string.text); + attr->values[k ++].string.text = + _cupsStrAlloc(members->values[j].string.text); } /* diff --git a/systemv/lpoptions.c b/systemv/lpoptions.c index 0dc5d0b56..d2d42ce9c 100644 --- a/systemv/lpoptions.c +++ b/systemv/lpoptions.c @@ -3,7 +3,7 @@ * * Printer option program for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -96,7 +96,9 @@ main(int argc, /* I - Number of command-line arguments */ if (num_dests == 0) num_dests = cupsGetDests(&dests); - if ((dest = cupsGetDest(printer, instance, num_dests, dests)) == NULL) + if (num_dests == 0 || !dests || + (dest = cupsGetDest(printer, instance, num_dests, + dests)) == NULL) { _cupsLangPuts(stderr, _("lpoptions: Unknown printer or class!\n")); @@ -463,8 +465,8 @@ list_group(ppd_file_t *ppd, /* I - PPD file */ while (cparam) { - _cupsLangPrintf(stdout, "%s%s=%s", choice->marked ? "*" : "", - cparam->name, types[cparam->type]); + _cupsLangPrintf(stdout, "%s%s=%s", prefix, cparam->name, + types[cparam->type]); cparam = (ppd_cparam_t *)cupsArrayNext(coption->params); prefix = " "; } diff --git a/test/ipptest.c b/test/ipptest.c index 5b22888ed..f2bc6f714 100644 --- a/test/ipptest.c +++ b/test/ipptest.c @@ -308,7 +308,6 @@ do_tests(const char *uri, /* I - URI to connect on */ request = ippNew(); op = (ipp_op_t)0; group = IPP_TAG_ZERO; - value = IPP_TAG_ZERO; num_statuses = 0; num_expects = 0; num_displayed = 0;