* This file contains Kerberos support code, copyright 2006 by
* Jelmer Vernooij.
*
- * 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
- * missing or damaged, see the license at "http://www.cups.org/".
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
/*
int sub_id; /* Subscription ID */
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdProcessIPPRequest(%p[%d]): operation_id = %04x",
- con, con->number, con->request->request.op.operation_id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdProcessIPPRequest(%p[%d]): operation_id=%04x(%s)", con, con->number, con->request->request.op.operation_id, ippOpString(con->request->request.op.operation_id));
+
+ if (LogLevel >= CUPSD_LOG_DEBUG2)
+ {
+ for (group = IPP_TAG_ZERO, attr = ippFirstAttribute(con->request); attr; attr = ippNextAttribute(con->request))
+ {
+ const char *name; /* Attribute name */
+ char value[1024]; /* Attribute value */
+
+ if (group != ippGetGroupTag(attr))
+ {
+ group = ippGetGroupTag(attr);
+ if (group != IPP_TAG_ZERO)
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdProcessIPPRequest: %s", ippTagString(group));
+ }
+
+ if ((name = ippGetName(attr)) == NULL)
+ continue;
+
+ ippAttributeString(attr, value, sizeof(value));
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdProcessIPPRequest: %s %s%s '%s'", name, ippGetCount(attr) > 1 ? "1setOf " : "", ippTagString(ippGetValueTag(attr)), value);
+ }
+ }
/*
* First build an empty response message for this request...
pclass = cupsdAddClass(resource + 9);
modify = 0;
+
+ pclass->printer_id = NextPrinterId ++;
}
else if ((status = cupsdCheckPolicy(pclass->op_policy_ptr, con,
NULL)) != HTTP_OK)
return (NULL);
}
+ attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME);
+
+ if (attr && !ippValidateAttribute(attr))
+ {
+ send_ipp_status(con, IPP_ATTRIBUTES, _("Bad requesting-user-name value: %s"), cupsLastErrorString());
+ if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL)
+ attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
+ return (NULL);
+ }
+
if ((job = cupsdAddJob(priority, printer->name)) == NULL)
{
send_ipp_status(con, IPP_INTERNAL_ERROR,
add_job_uuid(job);
apply_printer_defaults(printer, job);
- attr = ippFindAttribute(job->attrs, "requesting-user-name", IPP_TAG_NAME);
-
if (con->username[0])
{
cupsdSetString(&job->username, con->username);
printer = cupsdAddPrinter(resource + 10);
modify = 0;
+
+ printer->printer_id = NextPrinterId ++;
}
else if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
NULL)) != HTTP_OK)
* Update the printer attributes and return...
*/
- cupsdSetPrinterAttrs(printer);
if (!printer->temporary)
+ {
+ if (!printer->printer_id)
+ printer->printer_id = NextPrinterId ++;
+
cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
+ }
+
+ cupsdSetPrinterAttrs(printer);
if (need_restart_job && printer->job)
{
*option; /* Current option */
+ cupsdLogJob(job, CUPSD_LOG_DEBUG, "Applying default options...");
+
/*
* Collect all of the default options and add the missing ones to the
* job object...
i --, option ++)
if (!ippFindAttribute(job->attrs, option->name, IPP_TAG_ZERO))
{
- num_options = cupsAddOption(option->name, option->value, num_options,
- &options);
+ if (!strcmp(option->name, "print-quality") && ippFindAttribute(job->attrs, "cupsPrintQuality", IPP_TAG_NAME))
+ continue; /* Don't override cupsPrintQuality */
+
+ cupsdLogJob(job, CUPSD_LOG_DEBUG, "Adding default %s=%s", option->name, option->value);
+
+ num_options = cupsAddOption(option->name, option->value, num_options, &options);
}
/*
}
}
else
- cupsdLogMessage(CUPSD_LOG_ERROR, "%s: PPD creation failed.", printer->name);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s: PPD creation failed: %s", printer->name, cupsLastErrorString());
return (NULL);
}
return;
}
+ printer->shared = 0;
+ printer->temporary = 1;
+
cupsdSetDeviceURI(printer, ippGetString(device_uri, 0, NULL));
if (printer_geo_location)
ipp_attribute_t *attr; /* Current attribute */
int limit; /* Max number of printers to return */
int count; /* Number of printers that match */
+ int printer_id; /* Printer we are interested in */
cupsd_printer_t *printer; /* Current printer pointer */
cups_ptype_t printer_type, /* printer-type attribute */
printer_mask; /* printer-type-mask attribute */
* Support filtering...
*/
+ if ((attr = ippFindAttribute(con->request, "printer-id", IPP_TAG_INTEGER)) != NULL)
+ {
+ if ((printer_id = ippGetInteger(attr, 0)) <= 0)
+ {
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Bad \"printer-id\" value %d."), printer_id);
+ return;
+ }
+ }
+ else
+ printer_id = 0;
+
if ((attr = ippFindAttribute(con->request, "printer-type",
IPP_TAG_ENUM)) != NULL)
printer_type = (cups_ptype_t)attr->values[0].integer;
if (!local && !printer->shared)
continue;
+ if (printer_id && printer->printer_id != printer_id)
+ continue;
+
if ((!type || (printer->type & CUPS_PRINTER_CLASS) == type) &&
(printer->type & printer_mask) == printer_type &&
(!location ||