- Documentation fixes (STR #2994, STR #2995, STR #3008, STR #3056,
STR #3057)
+ - Fixed a Valgrind-detected initialization error when creating a
+ missing directory on startup.
+ - The scheduler did not always read all of the HTTP headers from a
+ CGI script/program.
+ - The scheduler did not always set the "air" property in Bonjour/DNS-SD
+ registrations.
+ - The scheduler incorrectly compared Mac OS X UUIDs for access
+ control, preventing access in certain configurations.
+ - The IPP backend incorrectly reset the required authentication
+ to Kerberos when authentication failed.
+ - The scheduler no longer looks up the local hostname by default;
+ turn on hostname lookups to restore the previous behavior.
- The scheduler did not always load MIME type rules correctly
(STR #3059)
- The test page did not format correctly on A4 paper (STR #3060)
-CHANGES.txt - 2009-01-14
+CHANGES.txt - 2009-01-23
------------------------
CHANGES IN CUPS V1.4b3
- Documentation fixes (STR #3044, STR #3057)
+ - The configure script incorrectly allowed Avahi to be used for DNS-SD
+ printer discovery (STR #3065)
+ - The web interface and scheduler did not support URIs up to 1024 bytes
+ in length (STR #3072)
+ - Fixed pdftops issues with page sizes (STR #3063)
+ - Fixed pdftops issues with Ghostscript (STR #3062)
+ - The scheduler incorrectly registered default profiles for PostScript
+ printers with no specified colorspace.
+ - The scheduler incorrectly created an empty org.cups.printers.plist
+ file on Mac OS X.
+ - cupsGetPPD3() did not look for local PPDs in the right directory.
+ - SNMP lookups via side-channel did not work for NULL-VALUE and
+ and OCTET-STRING OIDs containing nul characters.
- The libusb-based USB backend did not work.
- The scheduler did not set the printer-commands attribute correctly
for some PPDs.
page_count > start_count)
fprintf(stderr, "PAGE: total %d\n", page_count - start_count);
+ /*
+ * Update auth-info-required as needed...
+ */
+
+ if (ipp_status == IPP_NOT_AUTHORIZED)
+ {
+ if (!strncmp(httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE),
+ "Negotiate", 9))
+ fputs("ATTR: auth-info-required=negotiate\n", stderr);
+ else
+ fputs("ATTR: auth-info-required=username,password\n", stderr);
+ }
+
/*
* Free memory...
*/
*/
if (ipp_status == IPP_NOT_AUTHORIZED)
- {
- /*
- * Authorization failures here mean that we need Kerberos. Username +
- * password authentication is handled in the password_cb function.
- */
-
- fputs("ATTR: auth-info-required=negotiate\n", stderr);
return (CUPS_BACKEND_AUTH_REQUIRED);
- }
else if (ipp_status > IPP_OK_CONFLICT)
return (CUPS_BACKEND_FAILED);
else
*
* Common network APIs for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
case CUPS_ASN1_BOOLEAN :
snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
packet.object_value.boolean);
+ datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_INTEGER :
snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
packet.object_value.integer);
+ datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_BIT_STRING :
case CUPS_ASN1_OCTET_STRING :
- strlcpy(dataptr, packet.object_value.string,
- sizeof(data) - (dataptr - data));
+ i = (int)(sizeof(data) - (dataptr - data));
+ if (packet.object_value.string.num_bytes < i)
+ i = packet.object_value.string.num_bytes;
+
+ memcpy(dataptr, packet.object_value.string.bytes, i);
+
+ datalen += i;
break;
case CUPS_ASN1_OID :
_cupsSNMPOIDToString(packet.object_value.oid, dataptr,
sizeof(data) - (dataptr - data));
+ datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_HEX_STRING :
for (i = 0;
- i < packet.object_value.hex_string.num_bytes &&
+ i < packet.object_value.string.num_bytes &&
dataptr < (data + sizeof(data) - 3);
i ++, dataptr += 2)
sprintf(dataptr, "%02X",
- packet.object_value.hex_string.bytes[i]);
+ packet.object_value.string.bytes[i]);
+ datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_COUNTER :
snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
packet.object_value.counter);
+ datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_GAUGE :
snprintf(dataptr, sizeof(data) - (dataptr - data), "%u",
packet.object_value.gauge);
+ datalen += (int)strlen(dataptr);
break;
case CUPS_ASN1_TIMETICKS :
snprintf(dataptr, sizeof(data) - (dataptr - data), "%u",
packet.object_value.timeticks);
+ datalen += (int)strlen(dataptr);
break;
default :
fprintf(stderr, "DEBUG: Unknown OID value type %02X!\n",
packet.object_type);
+
+ case CUPS_ASN1_NULL_VALUE :
+ dataptr[0] = '\0';
break;
}
fprintf(stderr, "DEBUG: Returning %s %s\n", data, data + datalen);
- status = CUPS_SC_STATUS_OK;
- datalen += (int)strlen(data + datalen);
+ status = CUPS_SC_STATUS_OK;
}
else
fputs("DEBUG: SNMP read error...\n", stderr);
if (_cupsSNMPRead(snmp_fd, &packet, 1.0) &&
packet.object_type == CUPS_ASN1_OCTET_STRING)
{
- strlcpy(data, packet.object_value.string, sizeof(data));
+ strlcpy(data, (char *)packet.object_value.string.bytes,
+ sizeof(data));
datalen = (int)strlen(data);
status = CUPS_SC_STATUS_OK;
}
{
strlcpy(data, device_id, sizeof(data));
datalen = (int)strlen(data);
+ status = CUPS_SC_STATUS_OK;
break;
}
*
* SNMP supplies functions for the Common UNIX Printing System (CUPS).
*
- * Copyright 2008 by Apple Inc.
+ * Copyright 2008-2009 by Apple Inc.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
packet.object_type != CUPS_ASN1_OCTET_STRING)
return (-1);
- i = ((packet.object_value.string[0] & 255) << 8) |
- (packet.object_value.string[1] & 255);
+ i = (packet.object_value.string.bytes[0] << 8) |
+ packet.object_value.string.bytes[1];
if (i & CUPS_TC_lowPaper)
fputs("STATE: +media-low-report\n", stderr);
num_supplies = 0;
}
else
- strlcpy(description, packet.object_value.string, sizeof(description));
+ strlcpy(description, (char *)packet.object_value.string.bytes,
+ sizeof(description));
/*
* See if we have already queried this device...
i = packet->object_name[prtMarkerColorantValueOffset];
fprintf(stderr, "DEBUG2: prtMarkerColorantValue.1.%d = \"%s\"\n", i,
- packet->object_value.string);
+ (char *)packet->object_value.string.bytes);
for (j = 0; j < num_supplies; j ++)
if (supplies[j].colorant == i)
{
for (k = 0; k < (int)(sizeof(colors) / sizeof(colors[0])); k ++)
- if (!strcmp(colors[k][0], packet->object_value.string))
+ if (!strcmp(colors[k][0], (char *)packet->object_value.string.bytes))
{
strcpy(supplies[j].color, colors[k][1]);
break;
return;
fprintf(stderr, "DEBUG2: prtMarkerSuppliesDescription.1.%d = \"%s\"\n", i,
- packet->object_value.string);
+ (char *)packet->object_value.string.bytes);
if (i > num_supplies)
num_supplies = i;
- strlcpy(supplies[i - 1].name, packet->object_value.string,
+ strlcpy(supplies[i - 1].name, (char *)packet->object_value.string.bytes,
sizeof(supplies[0].name));
}
else if (_cupsSNMPIsOIDPrefixed(packet, prtMarkerSuppliesLevel))
*
* SNMP discovery backend for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
char make_model[256]; /* Make and model */
- if (strchr(packet.object_value.string, ':') &&
- strchr(packet.object_value.string, ';'))
+ if (strchr((char *)packet.object_value.string.bytes, ':') &&
+ strchr((char *)packet.object_value.string.bytes, ';'))
{
/*
* Description is the IEEE-1284 device ID...
*/
if (!device->id)
- device->id = strdup(packet.object_value.string);
+ device->id = strdup((char *)packet.object_value.string.bytes);
- backendGetMakeModel(packet.object_value.string, make_model,
- sizeof(make_model));
+ backendGetMakeModel((char *)packet.object_value.string.bytes,
+ make_model, sizeof(make_model));
if (device->info)
free(device->info);
* Description is plain text...
*/
- fix_make_model(make_model, packet.object_value.string,
+ fix_make_model(make_model, (char *)packet.object_value.string.bytes,
sizeof(make_model));
if (device->info)
free(device->info);
- device->info = strdup(packet.object_value.string);
+ device->info = strdup((char *)packet.object_value.string.bytes);
}
if (!device->make_and_model)
if (device->id)
free(device->id);
- device->id = strdup(packet.object_value.string);
+ device->id = strdup((char *)packet.object_value.string.bytes);
/*
* Convert the ID to a make and model string...
*/
- backendGetMakeModel(packet.object_value.string, make_model,
- sizeof(make_model));
+ backendGetMakeModel((char *)packet.object_value.string.bytes,
+ make_model, sizeof(make_model));
if (device->make_and_model)
free(device->make_and_model);
case DEVICE_LOCATION :
if (device && packet.object_type == CUPS_ASN1_OCTET_STRING &&
!device->location)
- device->location = strdup(packet.object_value.string);
+ device->location = strdup((char *)packet.object_value.string.bytes);
break;
case DEVICE_PRODUCT :
*/
if (!device->info)
- device->info = strdup(packet.object_value.string);
+ device->info = strdup((char *)packet.object_value.string.bytes);
if (device->make_and_model)
free(device->make_and_model);
- device->make_and_model = strdup(packet.object_value.string);
+ device->make_and_model = strdup((char *)packet.object_value.string.bytes);
}
break;
* Update an existing cache entry...
*/
- if (!strncmp(packet.object_value.string, "lpr:", 4))
+ if (!strncmp((char *)packet.object_value.string.bytes, "lpr:", 4))
{
/*
* We want "lpd://..." for the URI...
*/
- packet.object_value.string[2] = 'd';
+ packet.object_value.string.bytes[2] = 'd';
}
- device->uri = strdup(packet.object_value.string);
+ device->uri = strdup((char *)packet.object_value.string.bytes);
}
break;
}
cgiEndMultipart(void)
{
if (cgi_multipart)
+ {
printf("\n%s--\n", cgi_multipart);
+ fflush(stdout);
+ }
}
void
cgiStartMultipart(void)
{
- puts("MIME-Version: 1.0");
- puts("Content-Type: multipart/x-mixed-replace; boundary=\"CUPS-MULTIPART\"\n");
+ puts("MIME-Version: 1.0\n"
+ "Content-Type: multipart/x-mixed-replace; boundary=\"CUPS-MULTIPART\"\n");
+ fflush(stdout);
+
cgi_multipart = "--CUPS-MULTIPART";
}
case "$uname" in
Darwin*)
# Darwin and MacOS X...
- DNSSDLIBS="-framework CoreFoundation -framework SystemConfiguration"
AC_DEFINE(HAVE_DNSSD)
AC_DEFINE(HAVE_COREFOUNDATION)
AC_DEFINE(HAVE_SYSTEMCONFIGURATION)
+ DNSSDLIBS="-framework CoreFoundation -framework SystemConfiguration"
DNSSD_BACKEND="dnssd"
;;
*)
# All others...
- AC_CHECK_LIB(dns_sd,TXTRecordGetValuePtr,
+ AC_MSG_CHECKING(for current version of dns_sd library)
+ SAVELIBS="$LIBS"
+ LIBS="$LIBS -ldns_sd"
+ AC_TRY_COMPILE([#include <dns_sd.h],
+ [int constant = kDNSServiceFlagsShareConnection;
+ unsigned char txtRecord[100];
+ uint8_t valueLen;
+ TXTRecordGetValuePtr(sizeof(txtRecord),
+ txtRecord, "value", &valueLen);],
+ AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DNSSD)
- DNSSDLIBS="-ldns_sd")
+ DNSSDLIBS="-ldns_sd"
+ DNSSD_BACKEND="dnssd",
+ AC_MSG_RESULT(no))
+ LIBS="$SAVELIBS"
;;
esac
])
# Darwin, MacOS X
if test "x$with_pam_module" != x; then
PAMFILE="pam.$with_pam_module"
- elif test -f /usr/lib/pam/pam_opendirectory.so; then
+ elif test -f /usr/lib/pam/pam_opendirectory.so.2; then
PAMFILE="pam.opendirectory"
else
PAMFILE="pam.securityserver"
int j; /* Looping var */
ppd_choice_t *cptr; /* Current choice */
cups_array_t *test; /* Test array for conflicts */
+ ppd_size_t *size; /* Current page size */
for (i = consts->num_constraints, constptr = consts->constraints;
* Is this the option we are changing?
*/
- if (option && !strcasecmp(constptr->option->keyword, option))
+ if (option &&
+ (!strcasecmp(constptr->option->keyword, option) ||
+ (!strcasecmp(option, "PageSize") &&
+ !strcasecmp(constptr->option->keyword, "PageRegion")) ||
+ (!strcasecmp(option, "PageRegion") &&
+ !strcasecmp(constptr->option->keyword, "PageSize"))))
continue;
/*
if ((value = cupsGetOption(constptr->option->keyword, num_newopts,
newopts)) == NULL)
{
- marked = ppdFindMarkedChoice(ppd, constptr->option->keyword);
- value = marked ? marked->choice : "";
+ if (!strcasecmp(constptr->option->keyword, "PageSize") ||
+ !strcasecmp(constptr->option->keyword, "PageRegion"))
+ {
+ if ((value = cupsGetOption("PageSize", num_newopts,
+ newopts)) == NULL)
+ value = cupsGetOption("PageRegion", num_newopts, newopts);
+
+ if (!value)
+ {
+ if ((size = ppdPageSize(ppd, NULL)) != NULL)
+ value = size->name;
+ else
+ value = "";
+ }
+ }
+ else
+ {
+ marked = ppdFindMarkedChoice(ppd, constptr->option->keyword);
+ value = marked ? marked->choice : "";
+ }
}
+ if (!strncasecmp(value, "Custom.", 7))
+ value = "Custom";
+
/*
* Try the default choice...
*/
if (strcasecmp(value, cptr->choice) &&
strcasecmp(constptr->option->defchoice, cptr->choice) &&
+ strcasecmp("Custom", cptr->choice) &&
(test = ppd_test_constraints(ppd, constptr->option->keyword,
cptr->choice, num_newopts,
newopts,
cupsArrayRestore(ppd->sorted_attrs);
+ DEBUG_printf(("cupsResolveConflicts: Returning %d options:", num_newopts));
+#ifdef DEBUG
+ for (i = 0; i < num_newopts; i ++)
+ DEBUG_printf(("cupsResolveConflicts: options[%d]: %s=%s", i,
+ newopts[i].name, newopts[i].value));
+#endif /* DEBUG */
+
return (1);
/*
cupsArrayRestore(ppd->sorted_attrs);
+ DEBUG_puts("cupsResolveConflicts: Unable to resolve conflicts!");
+
return (0);
}
*marked; /* Marked choice */
cups_array_t *active = NULL; /* Active constraints */
const char *value; /* Current value */
- int option_conflict;/* Conflict with current option? */
DEBUG_printf(("ppd_test_constraints(ppd=%p, num_options=%d, options=%p, "
DEBUG_puts("ppd_test_constraints: Testing...");
- for (i = consts->num_constraints, constptr = consts->constraints,
- option_conflict = 0;
+ for (i = consts->num_constraints, constptr = consts->constraints;
i > 0;
i --, constptr ++)
{
!strcasecmp(option, "PageRegion")))
{
value = choice;
-
- if (!strcasecmp(value, constptr->choice->choice))
- option_conflict = 1;
}
else if ((value = cupsGetOption("PageSize", num_options,
options)) == NULL)
value = size->name;
}
+ if (value && !strncasecmp(value, "Custom.", 7))
+ value = "Custom";
+
if (!value || strcasecmp(value, constptr->choice->choice))
{
DEBUG_puts("ppd_test_constraints: NO");
{
if (option && choice && !strcasecmp(option, constptr->option->keyword))
{
- if (strcasecmp(choice, constptr->choice->choice))
- break;
+ if (!strncasecmp(choice, "Custom.", 7))
+ value = "Custom";
+ else
+ value = choice;
- option_conflict = 1;
+ if (strcasecmp(value, constptr->choice->choice))
+ {
+ DEBUG_puts("ppd_test_constraints: NO");
+ break;
+ }
}
else if ((value = cupsGetOption(constptr->option->keyword, num_options,
options)) != NULL)
{
+ if (!strncasecmp(value, "Custom.", 7))
+ value = "Custom";
+
if (strcasecmp(value, constptr->choice->choice))
{
DEBUG_puts("ppd_test_constraints: NO");
{
if (!strcasecmp(choice, "None") || !strcasecmp(choice, "Off") ||
!strcasecmp(choice, "False"))
+ {
+ DEBUG_puts("ppd_test_constraints: NO");
break;
-
- option_conflict = 1;
+ }
}
else if ((value = cupsGetOption(constptr->option->keyword, num_options,
options)) != NULL)
}
}
- if (i <= 0 && (!option || option_conflict))
+ if (i <= 0)
{
if (!active)
active = cupsArrayNew(NULL, NULL);
int num_dests, /* I - Number of destinations */
cups_dest_t **dests) /* IO - Destinations */
{
- int i; /* Looping var */
cups_dest_t *dest; /* Current destination */
ipp_t *request, /* IPP Request */
*response; /* IPP Response */
static const char * const pattrs[] = /* Attributes we're interested in */
{
"auth-info-required",
+ "device-uri",
"job-sheets-default",
"marker-change-time",
"marker-colors",
"media-supported",
#endif /* __APPLE__ */
"printer-commands",
+ "printer-defaults",
"printer-info",
"printer-is-accepting-jobs",
"printer-is-shared",
"printer-state-change-time",
"printer-state-reasons",
"printer-type",
- "printer-defaults"
+ "printer-uri-supported"
};
attr->value_tag != IPP_TAG_NAME &&
attr->value_tag != IPP_TAG_NAMELANG &&
attr->value_tag != IPP_TAG_KEYWORD &&
- attr->value_tag != IPP_TAG_RANGE)
+ attr->value_tag != IPP_TAG_RANGE &&
+ attr->value_tag != IPP_TAG_URI)
continue;
if (!strcmp(attr->name, "auth-info-required") ||
+ !strcmp(attr->name, "device-uri") ||
!strcmp(attr->name, "marker-change-time") ||
!strcmp(attr->name, "marker-colors") ||
!strcmp(attr->name, "marker-high-levels") ||
!strcmp(attr->name, "printer-type") ||
!strcmp(attr->name, "printer-is-accepting-jobs") ||
!strcmp(attr->name, "printer-location") ||
- !strcmp(attr->name, "printer-state-reasons"))
+ !strcmp(attr->name, "printer-state-reasons") ||
+ !strcmp(attr->name, "printer-uri-supported"))
{
/*
* Add a printer description attribute...
* See if we can set a default media size...
*/
+ int i; /* Looping var */
+
for (i = 0; i < attr->num_values; i ++)
if (!strcasecmp(media_default, attr->values[i].string.text))
{
{ 0, "compression", IPP_TAG_KEYWORD, IPP_TAG_OPERATION },
{ 0, "copies", IPP_TAG_INTEGER, IPP_TAG_JOB },
{ 0, "copies-default", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
+ { 0, "device-uri", IPP_TAG_URI, IPP_TAG_PRINTER },
{ 0, "document-format", IPP_TAG_MIMETYPE, IPP_TAG_OPERATION },
{ 0, "document-format-default", IPP_TAG_MIMETYPE, IPP_TAG_PRINTER },
{ 1, "exclude-schemes", IPP_TAG_NAME, IPP_TAG_OPERATION },
{ 1, "printer-state-reasons", IPP_TAG_KEYWORD, IPP_TAG_PRINTER },
{ 0, "printer-type", IPP_TAG_ENUM, IPP_TAG_PRINTER },
{ 0, "printer-uri", IPP_TAG_URI, IPP_TAG_OPERATION },
+ { 1, "printer-uri-supported", IPP_TAG_URI, IPP_TAG_PRINTER },
{ 0, "queued-job-count", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
{ 0, "raw", IPP_TAG_MIMETYPE, IPP_TAG_OPERATION },
{ 1, "requested-attributes", IPP_TAG_NAME, IPP_TAG_OPERATION },
bytes = (ssize_t)recv(http->fd, buffer, (int)length, 0);
#else
while ((bytes = recv(http->fd, buffer, length, 0)) < 0)
- if (errno != EINTR)
+ if (errno != EINTR && errno != EAGAIN)
break;
#endif /* WIN32 */
#ifdef WIN32
http->error = WSAGetLastError();
#else
- if (errno == EINTR)
+ if (errno == EINTR || errno == EAGAIN)
bytes = 0;
else
http->error = errno;
}
}
- if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) <= 0)
+ if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) < 0)
+ {
+#ifdef WIN32
+ break;
+#else
+ if (errno != EAGAIN && errno != EINTR)
+ break;
+
+ bytes = 0;
+#endif /* WIN32 */
+ }
+ else if (bytes == 0)
break;
}
}
ppdFindMarkedChoice(ppd_file_t *ppd, /* I - PPD file */
const char *option) /* I - Keyword/option name */
{
- ppd_choice_t key; /* Search key for choice */
+ ppd_choice_t key, /* Search key for choice */
+ *marked; /* Marked choice */
+ DEBUG_printf(("ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option));
+
if ((key.option = ppdFindOption(ppd, option)) == NULL)
+ {
+ DEBUG_puts("ppdFindMarkedChoice: Option not found, returning NULL");
return (NULL);
+ }
+
+ marked = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key);
+
+ DEBUG_printf(("ppdFindMarkedChoice: Returning %p(%s)...", marked,
+ marked ? marked->choice : "NULL"));
- return ((ppd_choice_t *)cupsArrayFind(ppd->marked, &key));
+ return (marked);
}
*
* Page size functions for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
#include "ppd.h"
#include "string.h"
#include <ctype.h>
+#include "debug.h"
/*
ppd_cparam_t *cparam; /* Custom option parameter */
+ DEBUG_printf(("ppdPageSize(ppd=%p, name=\"%s\")", ppd, name));
+
if (!ppd)
+ {
+ DEBUG_puts("ppdPageSize: Bad PPD pointer, returning NULL...");
return (NULL);
+ }
if (name)
{
break;
if (!i)
+ {
+ DEBUG_puts("ppdPageSize: No custom sizes, returning NULL...");
return (NULL);
+ }
/*
* Variable size; size name can be one of the following:
* Return the page size...
*/
+ DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
+ size->name, size->width, size->length));
+
return (size);
}
else
*/
for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
- if (!strcmp(name, size->name))
+ if (!strcasecmp(name, size->name))
+ {
+ DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
+ size->name, size->width, size->length));
+
return (size);
+ }
}
}
else
for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
if (size->marked)
+ {
+ DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
+ size->name, size->width, size->length));
+
return (size);
+ }
}
+ DEBUG_puts("ppdPageSize: Size not found, returning NULL");
+
return (NULL);
}
*
* Side-channel API code for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
return (CUPS_SC_STATUS_OK);
}
+ if (real_datalen < sizeof(real_data))
+ real_data[real_datalen] = '\0';
+
real_oidlen = strlen(real_data) + 1;
real_datalen -= real_oidlen;
* This API is PRIVATE and subject to change. No third-party applications
* should use the SNMP API defined in this file.
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
};
typedef enum cups_asn1_e cups_asn1_t; /**** ASN1 request/object types ****/
-struct cups_snmp_hexstring_s /**** Hex-STRING value ****/
+typedef struct cups_snmp_string_s /**** String value ****/
{
unsigned char bytes[CUPS_SNMP_MAX_STRING];
/* Bytes in string */
int num_bytes; /* Number of bytes */
-};
+} cups_snmp_string_t;
union cups_snmp_value_u /**** Object value ****/
{
unsigned gauge; /* Gauge value */
unsigned timeticks; /* Timeticks value */
int oid[CUPS_SNMP_MAX_OID]; /* OID value */
- char string[CUPS_SNMP_MAX_STRING];
- /* String value */
- struct cups_snmp_hexstring_s hex_string;
- /* Hex string value */
+ cups_snmp_string_t string; /* String value */
};
typedef struct cups_snmp_s /**** SNMP data packet ****/
*
* SNMP functions for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
break;
case CUPS_ASN1_OCTET_STRING :
+ case CUPS_ASN1_BIT_STRING :
+ case CUPS_ASN1_HEX_STRING :
+ packet->object_value.string.num_bytes = length;
asn1_get_string(&bufptr, bufend, length,
- packet->object_value.string,
+ (char *)packet->object_value.string.bytes,
CUPS_SNMP_MAX_STRING);
break;
packet->object_value.oid, CUPS_SNMP_MAX_OID);
break;
- case CUPS_ASN1_HEX_STRING :
- packet->object_value.hex_string.num_bytes = length;
-
- asn1_get_string(&bufptr, bufend, length,
- (char *)packet->object_value.hex_string.bytes,
- CUPS_SNMP_MAX_STRING);
- break;
-
case CUPS_ASN1_COUNTER :
packet->object_value.counter =
asn1_get_integer(&bufptr, bufend, length);
break;
case CUPS_ASN1_OCTET_STRING :
- valuelen = strlen(packet->object_value.string);
+ valuelen = packet->object_value.string.num_bytes;
break;
case CUPS_ASN1_OID :
case CUPS_ASN1_OCTET_STRING :
*bufptr++ = CUPS_ASN1_OCTET_STRING;
asn1_set_length(&bufptr, valuelen);
- memcpy(bufptr, packet->object_value.string, valuelen);
+ memcpy(bufptr, packet->object_value.string.bytes, valuelen);
bufptr += valuelen;
break;
{
int i; /* Looping var */
ppd_file_t *ppd; /* PPD file loaded from disk */
- char line[256]; /* Input buffer */
+ char line[256], /* Input buffer */
+ *ptr, /* Pointer into buffer */
+ *optr, /* Pointer to first option name */
+ *cptr; /* Pointer to first choice */
int num_options; /* Number of options */
cups_option_t *options; /* Options */
char *option, /* Current option */
if (!cupsResolveConflicts(ppd, option, choice, &num_options, &options))
puts("Unable to resolve conflicts!");
- else if (num_options > 0)
+ else if ((!option && num_options > 0) || (option && num_options > 1))
{
fputs("Resolved conflicts with the following options:\n ", stdout);
for (i = 0; i < num_options; i ++)
- printf(" %s=%s", options[i].name, options[i].value);
+ if (!option || strcasecmp(option, options[i].name))
+ printf(" %s=%s", options[i].name, options[i].value);
putchar('\n');
cupsFreeOptions(num_options, options);
if (!fgets(line, sizeof(line), stdin) || line[0] == '\n')
break;
- num_options = cupsParseOptions(line, 0, &options);
- if (num_options > 0)
- {
- option = strdup(options[0].name);
- choice = strdup(options[0].value);
- }
+ for (ptr = line; isspace(*ptr & 255); ptr ++);
+ for (optr = ptr; *ptr && *ptr != '='; ptr ++);
+ if (!*ptr)
+ break;
+ for (*ptr++ = '\0', cptr = ptr; *ptr && !isspace(*ptr & 255); ptr ++);
+ if (!*ptr)
+ break;
+ *ptr++ = '\0';
+
+ option = strdup(optr);
+ choice = strdup(cptr);
+ num_options = cupsParseOptions(ptr, 0, &options);
+ ppdMarkOption(ppd, option, choice);
if (cupsMarkOptions(ppd, num_options, options))
puts("Options Conflict!");
cupsFreeOptions(num_options, options);
else
{
const char *filename; /* PPD filename */
+ struct stat fileinfo; /* File information */
if (!strncmp(argv[1], "-d", 2))
else
filename = argv[1];
+ if (lstat(filename, &fileinfo))
+ {
+ printf("%s: %s\n", filename, strerror(errno));
+ return (1);
+ }
+
+ if (S_ISLNK(fileinfo.st_mode))
+ {
+ char realfile[1024]; /* Real file path */
+ ssize_t realsize; /* Size of real file path */
+
+
+ if ((realsize = readlink(filename, realfile, sizeof(realfile) - 1)) < 0)
+ strcpy(realfile, "Unknown");
+ else
+ realfile[realsize] = '\0';
+
+ if (stat(realfile, &fileinfo))
+ printf("%s: symlink to \"%s\", %s\n", filename, realfile,
+ strerror(errno));
+ else
+ printf("%s: symlink to \"%s\", %ld bytes\n", filename, realfile,
+ (long)fileinfo.st_size);
+ }
+ else
+ printf("%s: regular file, %ld bytes\n", filename, (long)fileinfo.st_size);
+
if ((ppd = ppdOpenFile(filename)) == NULL)
{
ppd_status_t err; /* Last error in file */
*
* SNMP test program for the Common UNIX Printing System (CUPS).
*
- * Copyright 2008 by Apple Inc.
+ * Copyright 2008-2009 by Apple Inc.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
break;
case CUPS_ASN1_BIT_STRING :
- printf("BIT-STRING \"%s\"\n", packet->object_value.string);
+ printf("BIT-STRING \"%s\"\n",
+ (char *)packet->object_value.string.bytes);
break;
case CUPS_ASN1_OCTET_STRING :
- printf("OCTET-STRING \"%s\"\n", packet->object_value.string);
+ printf("OCTET-STRING \"%s\"\n",
+ (char *)packet->object_value.string.bytes);
break;
case CUPS_ASN1_NULL_VALUE :
case CUPS_ASN1_HEX_STRING :
fputs("Hex-STRING", stdout);
- for (i = 0; i < packet->object_value.hex_string.num_bytes; i ++)
- printf(" %02X", packet->object_value.hex_string.bytes[i]);
+ for (i = 0; i < packet->object_value.string.num_bytes; i ++)
+ printf(" %02X", packet->object_value.string.bytes[i]);
putchar('\n');
break;
*
* Printing utilities for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
struct stat ppdinfo; /* PPD file information */
- snprintf(ppdname, sizeof(ppdname), "%s/%s.ppd", cg->cups_serverroot, name);
+ snprintf(ppdname, sizeof(ppdname), "%s/ppd/%s.ppd", cg->cups_serverroot,
+ name);
if (!stat(ppdname, &ppdinfo))
{
/*
}
}
- if (*modtime <= ppdinfo.st_mtime)
+ if (*modtime >= ppdinfo.st_mtime)
return (HTTP_NOT_MODIFIED);
else
{
* PDF to PostScript filter front-end for the Common UNIX Printing
* System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
pdfstatus, /* Status from pdftops */
pdfargc; /* Number of args for pdftops */
char *pdfargv[100], /* Arguments for pdftops/gs */
-#ifdef HAVE_PDFTOPS
pdfwidth[255], /* Paper width */
pdfheight[255]; /* Paper height */
-#else
- pdfgeometry[255]; /* Paper width and height */
-#endif /* HAVE_PDFTOPS */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
*/
size = ppdPageSize(ppd, NULL);
- if (size)
+ if (size &&
+ (cupsGetOption("media", num_options, options) ||
+ cupsGetOption("media-col", num_options, options) ||
+ cupsGetOption("PageRegion", num_options, options) ||
+ cupsGetOption("PageSize", num_options, options))
{
/*
* Got the size, now get the orientation...
pdfargv[pdfargc++] = pdfwidth;
pdfargv[pdfargc++] = (char *)"-paperh";
pdfargv[pdfargc++] = pdfheight;
+
+ if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
+ strcasecmp(val, "no") && strcasecmp(val, "off") &&
+ strcasecmp(val, "false"))
+ pdfargv[pdfargc++] = (char *)"-expand";
+
#else
if (orientation & 1)
- snprintf(pdfgeometry, sizeof(pdfgeometry), "-g%.0fx%.0f", size->length,
+ {
+ snprintf(pdfwidth, sizeof(pdfwidth), "-dDEVICEWIDTHPOINTS=%.0f",
+ size->length);
+ snprintf(pdfheight, sizeof(pdfheight), "-dDEVICEHEIGHTPOINTS=%.0f",
size->width);
+ }
else
- snprintf(pdfgeometry, sizeof(pdfgeometry), "-g%.0fx%.0f", size->width,
+ {
+ snprintf(pdfwidth, sizeof(pdfwidth), "-dDEVICEWIDTHPOINTS=%.0f",
+ size->width);
+ snprintf(pdfheight, sizeof(pdfheight), "-dDEVICEHEIGHTPOINTS=%.0f",
size->length);
+ }
- pdfargv[pdfargc++] = pdfgeometry;
+ pdfargv[pdfargc++] = pdfwidth;
+ pdfargv[pdfargc++] = pdfheight;
#endif /* HAVE_PDFTOPS */
}
}
#ifdef HAVE_PDFTOPS
- if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
- strcasecmp(val, "no") && strcasecmp(val, "off") &&
- strcasecmp(val, "false"))
- pdfargv[pdfargc++] = (char *)"-expand";
-
pdfargv[pdfargc++] = filename;
pdfargv[pdfargc++] = (char *)"-";
#else
continue;
if (!o->text->value || !strcmp(o->name->value, o->text->value))
- cupsFilePrintf(fp, "*OpenUI *%s: ", o->name->value,
+ cupsFilePrintf(fp, "*OpenUI *%s/%s: ", o->name->value,
catalog->find_message(o->name->value));
else
cupsFilePrintf(fp, "*OpenUI *%s/%s: ", o->name->value,
{
cups_file_t *fp; /* classes.conf file */
int linenum; /* Current line number */
- char line[1024], /* Line from file */
+ char line[4096], /* Line from file */
*value, /* Pointer to value */
*valueptr; /* Pointer into value */
cupsd_printer_t *p, /* Current printer class */
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* This file contains Kerberos support code, copyright 2006 by
* Map accesses from the same host to the server name.
*/
- for (addr = ServerAddrs; addr; addr = addr->next)
- if (httpAddrEqual(con->http.hostaddr, &(addr->addr)))
- break;
-
- if (addr)
- {
- strlcpy(con->http.hostname, ServerName, sizeof(con->http.hostname));
- hostname = con->http.hostname;
- }
- else if (HostNameLookups)
+ if (HostNameLookups)
hostname = httpAddrLookup(con->http.hostaddr, con->http.hostname,
sizeof(con->http.hostname));
else
buf[bytes] = '\0';
for (bufptr = buf; !con->got_fields && *bufptr; bufptr ++)
+ {
if (*bufptr == '\n')
{
/*
bufptr[-1] = '\0';
*bufptr++ = '\0';
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "Script header: %s", buf);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Script header: %s", buf);
if (!con->sent_header)
{
*/
bytes -= (bufptr - buf);
- memmove(buf, bufptr, bytes + 1);
+
+ if (bytes > 0)
+ memmove(buf, bufptr, bytes + 1);
+ else
+ buf[0] = '\0';
+
bufptr = buf - 1;
/*
}
else if (*bufptr != '\r')
con->field_col ++;
+ }
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdWriteClient: %d bytes=%d, got_fields=%d",
*
* Client definitions for the Common UNIX Printing System (CUPS) scheduler.
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
/* HTTP clients */
*ActiveClients VALUE(NULL);
/* Active HTTP clients */
-VAR http_addrlist_t *ServerAddrs VALUE(NULL);
- /* Server address(es) */
VAR char *ServerHeader VALUE(NULL);
/* Server header in requests */
VAR int CGIPipes[2] VALUE2(-1,-1);
*
* Configuration routines for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
return (-1);
}
- dir_created = 1;
+ dir_created = 1;
+ fileinfo.st_mode = mode | S_IFDIR;
}
else
return (create_dir ? -1 : 1);
cupsdDeleteAllListeners();
+ RemoteAccessEnabled = 0;
+
/*
* String options...
*/
- cupsdSetString(&ServerName, httpGetHostname(NULL, temp, sizeof(temp)));
- cupsdSetStringf(&ServerAdmin, "root@%s", temp);
+ cupsdClearString(&ServerName);
+ cupsdClearString(&ServerAdmin);
cupsdSetString(&ServerBin, CUPS_SERVERBIN);
cupsdSetString(&RequestRoot, CUPS_REQUESTS);
cupsdSetString(&CacheDir, CUPS_CACHEDIR);
RunUser = getuid();
+ cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
+ RemoteAccessEnabled ? "enabled" : "disabled");
+
/*
* See if the ServerName is an IP address...
*/
+ if (!ServerName)
+ {
+ if (HostNameLookups || RemoteAccessEnabled)
+ httpGetHostname(NULL, temp, sizeof(temp));
+ else if (gethostname(temp, sizeof(temp)))
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get hostname: %s",
+ strerror(errno));
+ strlcpy(temp, "localhost", sizeof(temp));
+ }
+
+ cupsdSetString(&ServerName, temp);
+ }
+
for (slash = ServerName; isdigit(*slash & 255) || *slash == '.'; slash ++);
ServerNameIsIP = !*slash;
+ /*
+ * Make sure ServerAdmin is initialized...
+ */
+
+ if (!ServerAdmin)
+ cupsdSetStringf(&ServerAdmin, "root@%s", ServerName);
+
/*
* Use the default system group if none was supplied in cupsd.conf...
*/
#endif /* AF_LOCAL */
cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
ntohs(lis->address.ipv4.sin_port));
+
+ if (!httpAddrLocalhost(&(lis->address)))
+ RemoteAccessEnabled = 1;
}
/*
/* Directory for request files */
*DocumentRoot VALUE(NULL);
/* Root directory for documents */
-VAR int ServerNameIsIP VALUE(0);
+VAR int RemoteAccessEnabled VALUE(0),
+ /* Are we listening on non-local addresses? */
+ ServerNameIsIP VALUE(0);
+ /* Is the ServerName an IP address? */
VAR int NumSystemGroups VALUE(0);
/* Number of system group names */
VAR char *SystemGroups[MAX_SYSTEM_GROUPS]
/* Permissions for log files */
LogLevel VALUE(CUPSD_LOG_WARN),
/* Error log level */
- MaxClients VALUE(0),
+ MaxClients VALUE(100),
/* Maximum number of clients */
MaxClientsPerHost VALUE(0),
/* Maximum number of clients per host */
for (d = (ppdcDriver *)src->drivers->first();
d;
d = (ppdcDriver *)src->drivers->next())
- if (!strcasecmp(pc_file_name, d->pc_file_name->value) ||
- (d->file_name && !strcasecmp(pc_file_name, d->file_name->value)))
+ if (!strcmp(pc_file_name, d->pc_file_name->value) ||
+ (d->file_name && !strcmp(pc_file_name, d->file_name->value)))
break;
if (d)
int diff; /* Difference between strings */
- if ((diff = strcasecmp(p0->record.filename, p1->record.filename)) != 0)
+ if ((diff = strcmp(p0->record.filename, p1->record.filename)) != 0)
return (diff);
else
- return (strcasecmp(p0->record.name, p1->record.name));
+ return (strcmp(p0->record.name, p1->record.name));
}
p1->record.make_and_model)) != 0)
return (diff);
else
- return (strcasecmp(p0->record.languages[0],
- p1->record.languages[0]));
+ return (strcmp(p0->record.languages[0], p1->record.languages[0]));
}
{
for (i = 0; i < PPD_MAX_LANG; i ++)
if (!ppd->record.languages[i][0] ||
- !strcasecmp(ppd->record.languages[i], language))
+ !strcmp(ppd->record.languages[i], language))
{
ppd->matches ++;
break;
ppd->found = 1;
}
while ((ppd = (ppd_info_t *)cupsArrayNext(PPDsByName)) != NULL &&
- !strcasecmp(ppd->record.filename, name));
+ !strcmp(ppd->record.filename, name));
continue;
}
}
for (i = 0; i < (int)(sizeof(languages) / sizeof(languages[0])); i ++)
- if (!strcasecmp(languages[i].version, lang_version))
+ if (!strcmp(languages[i].version, lang_version))
break;
if (i < (int)(sizeof(languages) / sizeof(languages[0])))
*
* Directory services routines for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
{
cups_file_t *fp; /* remote.cache file */
int linenum; /* Current line number */
- char line[1024], /* Line from file */
+ char line[4096], /* Line from file */
*value, /* Pointer to value */
*valueptr, /* Pointer into value */
scheme[32], /* Scheme portion of URI */
rp_str[1024], /* Queue name string buffer */
air_str[1024], /* auth-info-required string buffer */
*keyvalue[32][2]; /* Table of key/value pairs */
+ ipp_attribute_t *air_attr; /* auth-info-required attribute */
/*
keyvalue[i ][0] = "pdl";
keyvalue[i++][1] = p->pdl ? p->pdl : "application/postscript";
- if (p->num_auth_info_required)
+ if ((air_attr = ippFindAttribute(p->attrs, "auth-info-required",
+ IPP_TAG_KEYWORD)) != NULL &&
+ strcmp(air_attr->values[0].string.text, "none"))
{
char *air = air_str; /* Pointer into string */
- for (j = 0; j < p->num_auth_info_required; j ++)
+ for (j = 0; j < air_attr->num_values; j ++)
{
if (air >= (air_str + sizeof(air_str) - 2))
break;
if (j)
*air++ = ',';
- strlcpy(air, p->auth_info_required[j], sizeof(air_str) - (air - air_str));
+ strlcpy(air, air_attr->values[j].string.text,
+ sizeof(air_str) - (air - air_str));
air += strlen(air);
}
uri ? uri->values[0].string.text : "no URI",
con->http.hostname);
+ if (LogLevel == CUPSD_LOG_DEBUG2)
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdProcessIPPRequest: ippLength(response)=%ld",
+ (long)ippLength(con->response));
+
if (cupsdSendHeader(con, HTTP_OK, "application/ipp", CUPSD_AUTH_NONE))
{
#ifdef CUPSD_USE_CHUNKING
* Use the default colorspace...
*/
- num_profiles = 1 + ppd->colorspace != PPD_CS_GRAY;
-
+ num_profiles = 2;
+
if ((profiles = calloc(num_profiles, sizeof(CMDeviceProfileArray))) == NULL)
{
cupsdLogMessage(CUPSD_LOG_ERROR,
break;
case PPD_CS_N :
+ default :
apple_init_profile(ppd, NULL, profiles->profiles + 1,
_ppdHashName("DeviceN.."), "DeviceN", "DeviceN",
NULL);
break;
-
- default :
- break;
}
}
"entry ignored", p->users[i]);
}
- if ((mbr_err = mbr_check_membership(usr_uuid, usr2_uuid,
- &is_member)) != 0)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "check_quotas: User \"%s\" identity check failed "
- "(err=%d)", p->users[i], mbr_err);
- is_member = 0;
- }
-
- if (is_member)
+ if (!uuid_compare(usr_uuid, usr2_uuid))
break;
}
#else
completed = 0;
list = Jobs;
}
- else if (attr && !strcmp(attr->values[0].string.text, "printing"))
+ else if (attr && !strcmp(attr->values[0].string.text, "processing"))
{
completed = 0;
list = PrintingJobs;
* Filter out jobs that don't match...
*/
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: job->id = %d", job->id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "get_jobs: job->id=%d, dest=\"%s\", username=\"%s\", "
+ "state_value=%d, attrs=%p", job->id, job->dest,
+ job->username, job->state_value, job->attrs);
if (!job->dest || !job->username)
cupsdLoadJob(job);
cupsdLoadJob(job);
if (!job->attrs)
+ {
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: No attributes for job %d!",
+ job->id);
continue;
+ }
if (username[0] && strcasecmp(username, job->username))
continue;
count ++;
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count = %d", count);
-
copy_job_attrs(con, job, ra);
}
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count=%d", count);
+
cupsArrayDelete(ra);
con->response->request.status.status_code = IPP_OK;
* Server listening routines for the Common UNIX Printing System (CUPS)
* scheduler.
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdStartListening: %d Listeners",
cupsArrayCount(Listeners));
- /*
- * Get the server's IP address...
- */
-
- if (ServerAddrs)
- httpAddrFreeList(ServerAddrs);
-
- if ((ServerAddrs = httpAddrGetList(ServerName, AF_UNSPEC, NULL)) == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to find IP address for server name \"%s\"!",
- ServerName);
-
- if (FatalErrors & CUPSD_FATAL_LISTEN)
- cupsdEndProcess(getpid(), 0);
- }
-
/*
* Setup socket listeners...
*/
* Network interface functions for the Common UNIX Printing System
* (CUPS) scheduler.
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2009 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
cupsd_netif_t *temp; /* New interface */
struct ifaddrs *addrs, /* Interface address list */
*addr; /* Current interface address */
- http_addrlist_t *saddr; /* Current server address */
char hostname[1024]; /* Hostname for address */
* Try looking up the hostname for the address as needed...
*/
- if (HostNameLookups)
+ if (HostNameLookups || RemoteAccessEnabled)
httpAddrLookup((http_addr_t *)(addr->ifa_addr), hostname,
sizeof(hostname));
else
if (httpAddrLocalhost((http_addr_t *)(addr->ifa_addr)))
strcpy(hostname, "localhost");
else
- {
- for (saddr = ServerAddrs; saddr; saddr = saddr->next)
- if (httpAddrEqual((http_addr_t *)(addr->ifa_addr), &(saddr->addr)))
- break;
-
- if (saddr)
- strlcpy(hostname, ServerName, sizeof(hostname));
- else
- httpAddrString((http_addr_t *)(addr->ifa_addr), hostname,
- sizeof(hostname));
- }
+ httpAddrString((http_addr_t *)(addr->ifa_addr), hostname,
+ sizeof(hostname));
}
/*
{
cups_file_t *fp; /* printers.conf file */
int linenum; /* Current line number */
- char line[1024], /* Line from file */
+ char line[4096], /* Line from file */
*value, /* Pointer to value */
*valueptr; /* Pointer into value */
cupsd_printer_t *p; /* Current printer */
*rptr; /* Pointer into reason */
+ if (!p || !s)
+ {
+ cupsdLogMessage(CUPSD_LOG_EMERG,
+ "cupsdSetPrinterReasons called with p=%p and s=%p!", p, s);
+ return;
+ }
+
+ if (LogLevel == CUPSD_LOG_DEBUG2)
+ {
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSetPrinterReasons(p=%p(%s),s=\"%s\"", p, p->name, s);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSetPrinterReasons: num_reasons=%d",
+ p->num_reasons);
+ for (i = 0; i < p->num_reasons; i ++)
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSetPrinterReasons: reasons[%d]=%p(\"%s\")", i,
+ p->reasons[i], p->reasons[i]);
+ }
+
if (s[0] == '-' || s[0] == '+')
{
/*
*/
for (i = 0; i < p->num_reasons; i ++)
- if (!strcasecmp(reason, p->reasons[i]))
+ if (!strcmp(reason, p->reasons[i]))
{
/*
* Found a match, so remove it...
*/
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSetPrinterReasons: Removing \"%s\" at index %d",
+ reason, i);
+
p->num_reasons --;
_cupsStrFree(p->reasons[i]);
memmove(p->reasons + i, p->reasons + i + 1,
(p->num_reasons - i) * sizeof(char *));
- i --;
-
if (!strcmp(reason, "paused") && p->state == IPP_PRINTER_STOPPED)
cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1);
if (PrintcapFormat == PRINTCAP_PLIST)
cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
+
+ break;
}
}
else if (p->num_reasons < (int)(sizeof(p->reasons) / sizeof(p->reasons[0])))
*/
for (i = 0; i < p->num_reasons; i ++)
- if (!strcasecmp(reason, p->reasons[i]))
+ if (!strcmp(reason, p->reasons[i]))
break;
if (i >= p->num_reasons)
{
+ if (i >= (int)(sizeof(p->reasons) / sizeof(p->reasons[0])))
+ {
+ cupsdLogMessage(CUPSD_LOG_ALERT,
+ "Too many printer-state-reasons values for %s (%d)",
+ p->name, i + 1);
+ return;
+ }
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSetPrinterReasons: Adding \"%s\" at index %d",
+ reason, i);
+
p->reasons[i] = _cupsStrAlloc(reason);
p->num_reasons ++;
}
}
}
+
+ if (LogLevel == CUPSD_LOG_DEBUG2)
+ {
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSetPrinterReasons: NEW num_reasons=%d",
+ p->num_reasons);
+ for (i = 0; i < p->num_reasons; i ++)
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSetPrinterReasons: NEW reasons[%d]=%p(\"%s\")", i,
+ p->reasons[i], p->reasons[i]);
+ }
}
"# %s/printers.conf file. All changes to this file\n"
"# will be lost.\n", ServerRoot);
- if (Printers)
+ /*
+ * Write a new printcap with the current list of printers.
+ */
+
+ switch (PrintcapFormat)
{
- /*
- * Write a new printcap with the current list of printers.
- */
+ case PRINTCAP_BSD :
+ /*
+ * Each printer is put in the file as:
+ *
+ * Printer1:
+ * Printer2:
+ * Printer3:
+ * ...
+ * PrinterN:
+ */
- switch (PrintcapFormat)
- {
- case PRINTCAP_BSD :
- /*
- * Each printer is put in the file as:
- *
- * Printer1:
- * Printer2:
- * Printer3:
- * ...
- * PrinterN:
- */
+ if (DefaultPrinter)
+ cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name,
+ DefaultPrinter->info, ServerName,
+ DefaultPrinter->name);
+
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+ p;
+ p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ if (p != DefaultPrinter)
+ cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info,
+ ServerName, p->name);
+ break;
- if (DefaultPrinter)
- cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name,
- DefaultPrinter->info, ServerName,
- DefaultPrinter->name);
-
- for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
- p;
- p = (cupsd_printer_t *)cupsArrayNext(Printers))
- if (p != DefaultPrinter)
- cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info,
- ServerName, p->name);
- break;
-
- case PRINTCAP_PLIST :
- /*
- * Each printer is written as a dictionary in a plist file.
- * Currently the printer-name, printer-info, printer-is-accepting-jobs,
- * printer-location, printer-make-and-model, printer-state,
- * printer-state-reasons, printer-type, and (sanitized) device-uri.
- */
+ case PRINTCAP_PLIST :
+ /*
+ * Each printer is written as a dictionary in a plist file.
+ * Currently the printer-name, printer-info, printer-is-accepting-jobs,
+ * printer-location, printer-make-and-model, printer-state,
+ * printer-state-reasons, printer-type, and (sanitized) device-uri.
+ */
- cupsFilePuts(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD "
- "PLIST 1.0//EN\" \"http://www.apple.com/DTDs/"
- "PropertyList-1.0.dtd\">\n"
- "<plist version=\"1.0\">\n"
- "<array>\n");
-
- for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
- p;
- p = (cupsd_printer_t *)cupsArrayNext(Printers))
- {
- cupsFilePuts(fp, "\t<dict>\n"
- "\t\t<key>printer-name</key>\n"
- "\t\t<string>");
- write_xml_string(fp, p->name);
- cupsFilePuts(fp, "</string>\n"
- "\t\t<key>printer-info</key>\n"
- "\t\t<string>");
- write_xml_string(fp, p->info);
- cupsFilePrintf(fp, "</string>\n"
- "\t\t<key>printer-is-accepting-jobs</key>\n"
- "\t\t<%s/>\n"
- "\t\t<key>printer-location</key>\n"
- "\t\t<string>", p->accepting ? "true" : "false");
- write_xml_string(fp, p->location);
- cupsFilePuts(fp, "</string>\n"
- "\t\t<key>printer-make-and-model</key>\n"
- "\t\t<string>");
- write_xml_string(fp, p->make_model);
- cupsFilePrintf(fp, "</string>\n"
- "\t\t<key>printer-state</key>\n"
- "\t\t<integer>%d</integer>\n"
- "\t\t<key>printer-state-reasons</key>\n"
- "\t\t<array>\n", p->state);
- for (i = 0; i < p->num_reasons; i ++)
- {
- cupsFilePuts(fp, "\t\t\t<string>");
- write_xml_string(fp, p->reasons[i]);
- cupsFilePuts(fp, "</string>\n");
- }
- cupsFilePrintf(fp, "\t\t</array>\n"
- "\t\t<key>printer-type</key>\n"
- "\t\t<integer>%d</integer>\n"
- "\t\t<key>device-uri</key>\n"
- "\t\t<string>", p->type);
- write_xml_string(fp, p->sanitized_device_uri);
- cupsFilePuts(fp, "</string>\n"
- "\t</dict>\n");
- }
- cupsFilePuts(fp, "</array>\n"
- "</plist>\n");
- break;
+ cupsFilePuts(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD "
+ "PLIST 1.0//EN\" \"http://www.apple.com/DTDs/"
+ "PropertyList-1.0.dtd\">\n"
+ "<plist version=\"1.0\">\n"
+ "<array>\n");
- case PRINTCAP_SOLARIS :
- /*
- * Each printer is put in the file as:
- *
- * _all:all=Printer1,Printer2,Printer3,...,PrinterN
- * _default:use=DefaultPrinter
- * Printer1:\
- * :bsdaddr=ServerName,Printer1:\
- * :description=Description:
- * Printer2:
- * :bsdaddr=ServerName,Printer2:\
- * :description=Description:
- * Printer3:
- * :bsdaddr=ServerName,Printer3:\
- * :description=Description:
- * ...
- * PrinterN:
- * :bsdaddr=ServerName,PrinterN:\
- * :description=Description:
- */
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+ p;
+ p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ {
+ cupsFilePuts(fp, "\t<dict>\n"
+ "\t\t<key>printer-name</key>\n"
+ "\t\t<string>");
+ write_xml_string(fp, p->name);
+ cupsFilePuts(fp, "</string>\n"
+ "\t\t<key>printer-info</key>\n"
+ "\t\t<string>");
+ write_xml_string(fp, p->info);
+ cupsFilePrintf(fp, "</string>\n"
+ "\t\t<key>printer-is-accepting-jobs</key>\n"
+ "\t\t<%s/>\n"
+ "\t\t<key>printer-location</key>\n"
+ "\t\t<string>", p->accepting ? "true" : "false");
+ write_xml_string(fp, p->location);
+ cupsFilePuts(fp, "</string>\n"
+ "\t\t<key>printer-make-and-model</key>\n"
+ "\t\t<string>");
+ write_xml_string(fp, p->make_model);
+ cupsFilePrintf(fp, "</string>\n"
+ "\t\t<key>printer-state</key>\n"
+ "\t\t<integer>%d</integer>\n"
+ "\t\t<key>printer-state-reasons</key>\n"
+ "\t\t<array>\n", p->state);
+ for (i = 0; i < p->num_reasons; i ++)
+ {
+ cupsFilePuts(fp, "\t\t\t<string>");
+ write_xml_string(fp, p->reasons[i]);
+ cupsFilePuts(fp, "</string>\n");
+ }
+ cupsFilePrintf(fp, "\t\t</array>\n"
+ "\t\t<key>printer-type</key>\n"
+ "\t\t<integer>%d</integer>\n"
+ "\t\t<key>device-uri</key>\n"
+ "\t\t<string>", p->type);
+ write_xml_string(fp, p->sanitized_device_uri);
+ cupsFilePuts(fp, "</string>\n"
+ "\t</dict>\n");
+ }
+ cupsFilePuts(fp, "</array>\n"
+ "</plist>\n");
+ break;
- cupsFilePuts(fp, "_all:all=");
- for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
- p;
- p = (cupsd_printer_t *)cupsArrayCurrent(Printers))
- cupsFilePrintf(fp, "%s%c", p->name,
- cupsArrayNext(Printers) ? ',' : '\n');
-
- if (DefaultPrinter)
- cupsFilePrintf(fp, "_default:use=%s\n", DefaultPrinter->name);
-
- for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
- p;
- p = (cupsd_printer_t *)cupsArrayNext(Printers))
- cupsFilePrintf(fp, "%s:\\\n"
- "\t:bsdaddr=%s,%s:\\\n"
- "\t:description=%s:\n",
- p->name, ServerName, p->name,
- p->info ? p->info : "");
- break;
- }
+ case PRINTCAP_SOLARIS :
+ /*
+ * Each printer is put in the file as:
+ *
+ * _all:all=Printer1,Printer2,Printer3,...,PrinterN
+ * _default:use=DefaultPrinter
+ * Printer1:\
+ * :bsdaddr=ServerName,Printer1:\
+ * :description=Description:
+ * Printer2:
+ * :bsdaddr=ServerName,Printer2:\
+ * :description=Description:
+ * Printer3:
+ * :bsdaddr=ServerName,Printer3:\
+ * :description=Description:
+ * ...
+ * PrinterN:
+ * :bsdaddr=ServerName,PrinterN:\
+ * :description=Description:
+ */
+
+ cupsFilePuts(fp, "_all:all=");
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+ p;
+ p = (cupsd_printer_t *)cupsArrayCurrent(Printers))
+ cupsFilePrintf(fp, "%s%c", p->name,
+ cupsArrayNext(Printers) ? ',' : '\n');
+
+ if (DefaultPrinter)
+ cupsFilePrintf(fp, "_default:use=%s\n", DefaultPrinter->name);
+
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+ p;
+ p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ cupsFilePrintf(fp, "%s:\\\n"
+ "\t:bsdaddr=%s,%s:\\\n"
+ "\t:description=%s:\n",
+ p->name, ServerName, p->name,
+ p->info ? p->info : "");
+ break;
}
/*
ipp_pstate_t state; /* Printer state */
char state_message[1024]; /* Printer state message */
int num_reasons; /* Number of printer-state-reasons */
- char *reasons[16]; /* printer-state-reasons strings */
+ char *reasons[64]; /* printer-state-reasons strings */
time_t state_time; /* Time at this state */
char *job_sheets[2]; /* Banners/job sheets */
cups_ptype_t type; /* Printer type (color, small, etc.) */
<TABLE>
<TR>
<TH CLASS="label">Connection:</TH>
-<TD><INPUT TYPE="TEXT" SIZE="60" MAXLENGTH="1024" NAME="DEVICE_URI" VALUE="{current_device_uri?{current_device_uri}:{device_uri}}"></TD>
+<TD><INPUT TYPE="TEXT" SIZE="60" MAXLENGTH="1023" NAME="DEVICE_URI" VALUE="{current_device_uri?{current_device_uri}:{device_uri}}"></TD>
</TR>
<TR>
<TD></TD>
<TABLE>
<TR>
<TH CLASS="label">Conexión:</TH>
-<TD><INPUT TYPE="TEXT" SIZE="60" MAXLENGTH="1024" NAME="DEVICE_URI" VALUE="{current_device_uri?{current_device_uri}:{device_uri}}"></TD>
+<TD><INPUT TYPE="TEXT" SIZE="60" MAXLENGTH="1023" NAME="DEVICE_URI" VALUE="{current_device_uri?{current_device_uri}:{device_uri}}"></TD>
</TR>
<TR>
<TD></TD>
#
# Test the lpadmin command.
#
-# Copyright 2007 by Apple Inc.
+# Copyright 2007-2009 by Apple Inc.
# Copyright 1997-2005 by Easy Software Products, all rights reserved.
#
# These coded instructions, statements, and computer programs are the
echo "Add Printer Test"
echo ""
-echo " lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/DESKJET.PPD"
-../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/DESKJET.PPD 2>&1
+echo " lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd"
+../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd 2>&1
if test $? != 0; then
echo " FAILED"
exit 1
--- /dev/null
+#
+# "$Id: 4.4-subscription-ops.test 4840 2005-11-14 21:53:30Z mike $"
+#
+# Verify that the CUPS subscription operations work.
+#
+{
+ # The name of the test...
+ NAME "Add Printer Subscription w/Lease"
+
+ # The operation to use
+ OPERATION Create-Printer-Subscription
+ RESOURCE /
+
+ # The attributes to send
+ GROUP operation
+ ATTR charset attributes-charset utf-8
+ ATTR language attributes-natural-language en
+ ATTR uri printer-uri $uri
+
+ GROUP subscription
+ ATTR uri notify-recipient testnotify://nowait
+ ATTR keyword notify-events printer-state-changed
+
+ # What statuses are OK?
+ STATUS successful-ok
+
+ # What attributes do we expect?
+ EXPECT attributes-charset
+ EXPECT attributes-natural-language
+ EXPECT notify-subscription-id
+ DISPLAY notify-subscription-id
+}
+
+#
+# End of "$Id: 4.4-subscription-ops.test 4840 2005-11-14 21:53:30Z mike $"
+#
--- /dev/null
+# Get subscriptions using Get-Subscriptions
+{
+ # The name of the test...
+ NAME "Get subscriptions using Get-Subscriptions"
+
+ # The resource to use for the POST
+ # RESOURCE /admin
+
+ # The operation to use
+ OPERATION Get-Subscriptions
+
+ # Attributes, starting in the operation group...
+ GROUP operation
+ ATTR charset attributes-charset utf-8
+ ATTR language attributes-natural-language en
+ ATTR uri printer-uri $uri
+
+ # What statuses are OK?
+ STATUS ok
+ STATUS ok-subst
+}
# Perform the complete set of IPP compliance tests specified in the
# CUPS Software Test Plan.
#
-# Copyright 2007-2008 by Apple Inc.
+# Copyright 2007-2009 by Apple Inc.
# Copyright 1997-2007 by Easy Software Products, all rights reserved.
#
# These coded instructions, statements, and computer programs are the
case "$usevalgrind" in
Y* | y*)
- valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind --error-limit=no --leak-check=yes --trace-children=yes"
+ valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind.%p --error-limit=no --leak-check=yes --trace-children=yes --read-var-info=yes"
echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..."
;;