| 10304 | */ |
| 10305 | |
| 10306 | static void |
| 10307 | send_http_error( |
| 10308 | cupsd_client_t *con, /* I - Client connection */ |
| 10309 | http_status_t status, /* I - HTTP status code */ |
| 10310 | cupsd_printer_t *printer) /* I - Printer, if any */ |
| 10311 | { |
| 10312 | ipp_attribute_t *uri; /* Request URI, if any */ |
| 10313 | |
| 10314 | |
| 10315 | if ((uri = ippFindAttribute(con->request, "printer-uri", |
| 10316 | IPP_TAG_URI)) == NULL) |
| 10317 | uri = ippFindAttribute(con->request, "job-uri", IPP_TAG_URI); |
| 10318 | |
| 10319 | cupsdLogMessage(status == HTTP_FORBIDDEN ? CUPSD_LOG_ERROR : CUPSD_LOG_DEBUG, |
| 10320 | "[Client %d] Returning HTTP %s for %s (%s) from %s", |
| 10321 | con->number, httpStatus(status), |
| 10322 | con->request ? |
| 10323 | ippOpString(con->request->request.op.operation_id) : |
| 10324 | "no operation-id", |
| 10325 | uri ? uri->values[0].string.text : "no URI", |
| 10326 | con->http->hostname); |
| 10327 | |
| 10328 | if (printer) |
| 10329 | { |
| 10330 | int auth_type; /* Type of authentication required */ |
| 10331 | |
| 10332 | |
| 10333 | auth_type = CUPSD_AUTH_NONE; |
| 10334 | |
| 10335 | if (status == HTTP_UNAUTHORIZED && |
| 10336 | printer->num_auth_info_required > 0 && |
| 10337 | !strcmp(printer->auth_info_required[0], "negotiate") && |
| 10338 | con->request && |
| 10339 | (con->request->request.op.operation_id == IPP_PRINT_JOB || |
| 10340 | con->request->request.op.operation_id == IPP_CREATE_JOB || |
| 10341 | con->request->request.op.operation_id == CUPS_AUTHENTICATE_JOB)) |
| 10342 | { |
| 10343 | /* |
| 10344 | * Creating and authenticating jobs requires Kerberos... |
| 10345 | */ |
| 10346 | |
| 10347 | auth_type = CUPSD_AUTH_NEGOTIATE; |
| 10348 | } |
| 10349 | else |
| 10350 | { |
| 10351 | /* |
| 10352 | * Use policy/location-defined authentication requirements... |
| 10353 | */ |
| 10354 | |
| 10355 | char resource[HTTP_MAX_URI]; /* Resource portion of URI */ |
| 10356 | cupsd_location_t *auth; /* Pointer to authentication element */ |
| 10357 | |
| 10358 | |
| 10359 | if (printer->type & CUPS_PRINTER_CLASS) |
| 10360 | snprintf(resource, sizeof(resource), "/classes/%s", printer->name); |
| 10361 | else |
| 10362 | snprintf(resource, sizeof(resource), "/printers/%s", printer->name); |
| 10363 |
no test coverage detected