else if (pclass->type & CUPS_PRINTER_IMPLICIT)
{
/*
- * Check the default policy, then tename the implicit class to "AnyClass"
+ * Check the default policy, then rename the implicit class to "AnyClass"
* or remove it...
*/
else if ((status = cupsdCheckPolicy(pclass->op_policy_ptr, con,
NULL)) != HTTP_OK)
{
- send_http_error(con, status, NULL);
+ send_http_error(con, status, pclass);
return;
}
else
else if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
NULL)) != HTTP_OK)
{
- send_http_error(con, status, NULL);
+ send_http_error(con, status, printer);
return;
}
else
* Do we have a valid device URI?
*/
+ http_uri_status_t uri_status; /* URI separation status */
+
+
need_restart_job = 1;
- httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, scheme,
- sizeof(scheme), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
+ uri_status = httpSeparateURI(HTTP_URI_CODING_ALL,
+ attr->values[0].string.text,
+ scheme, sizeof(scheme),
+ username, sizeof(username),
+ host, sizeof(host), &port,
+ resource, sizeof(resource));
+
+ if (uri_status < HTTP_URI_OK)
+ {
+ send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri \"%s\"!"),
+ attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_printer: httpSeparateURI returned %d", uri_status);
+ return;
+ }
if (!strcmp(scheme, "file"))
{
need_restart_job = 1;
supported = ippFindAttribute(printer->attrs, "port-monitor-supported",
- IPP_TAG_KEYWORD);
+ IPP_TAG_NAME);
for (i = 0; i < supported->num_values; i ++)
if (!strcmp(supported->values[i].string.text,
attr->values[0].string.text))
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- send_http_error(con, HTTP_UNAUTHORIZED, NULL);
+ send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- send_http_error(con, HTTP_UNAUTHORIZED, NULL);
+ send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
return;
}
if ((status = cupsdCheckPolicy(dest->op_policy_ptr, con, NULL)) != HTTP_OK)
{
- send_http_error(con, status, NULL);
+ send_http_error(con, status, dest);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- send_http_error(con, HTTP_UNAUTHORIZED, NULL);
+ send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- send_http_error(con, HTTP_UNAUTHORIZED, NULL);
+ send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- send_http_error(con, HTTP_UNAUTHORIZED, NULL);
+ send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- send_http_error(con, HTTP_UNAUTHORIZED, NULL);
+ send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- send_http_error(con, HTTP_UNAUTHORIZED, NULL);
+ send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
return;
}
printer && printer->num_auth_info_required > 0 &&
!strcmp(printer->auth_info_required[0], "negotiate"))
cupsdSendError(con, status, AUTH_NEGOTIATE);
+ else if (printer)
+ {
+ char resource[HTTP_MAX_URI]; /* Resource portion of URI */
+ cupsd_location_t *auth; /* Pointer to authentication element */
+
+
+ if (printer->type & CUPS_PRINTER_CLASS)
+ snprintf(resource, sizeof(resource), "/classes/%s", printer->name);
+ else
+ snprintf(resource, sizeof(resource), "/printers/%s", printer->name);
+
+ if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL ||
+ auth->type == AUTH_NONE)
+ auth = cupsdFindPolicyOp(printer->op_policy_ptr, IPP_PRINT_JOB);
+
+ cupsdSendError(con, status, auth ? auth->type : AUTH_NONE);
+ }
else
cupsdSendError(con, status, AUTH_NONE);
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- send_http_error(con, HTTP_UNAUTHORIZED, NULL);
+ send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
return;
}