auth-workaround-for-certain-web-browsers.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From 4feb1fe2e5bb9f418f51f5f517f70b451159baa2 Mon Sep 17 00:00:00 2001
  2. From: Michael R Sweet <michael.r.sweet@gmail.com>
  3. Date: Mon, 16 Apr 2018 17:16:31 -0400
  4. Subject: [PATCH] - Added a workaround for certain web browsers that do not
  5. support multiple authentication schemes in a single response header (Issue
  6. #5289)
  7. ---
  8. scheduler/client.c | 22 +++++++++++++++++-----
  9. scheduler/client.h | 8 +++++---
  10. 2 files changed, 22 insertions(+), 8 deletions(-)
  11. diff --git a/scheduler/client.c b/scheduler/client.c
  12. index f388499dc..95c34877d 100644
  13. --- a/scheduler/client.c
  14. +++ b/scheduler/client.c
  15. @@ -813,6 +814,18 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
  16. if (status == HTTP_STATUS_OK)
  17. {
  18. + /*
  19. + * Record whether the client is a web browser. "Mozilla" was the original
  20. + * and it seems that every web browser in existence now uses that as the
  21. + * prefix with additional information identifying *which* browser.
  22. + *
  23. + * Chrome (at least) has problems with multiple WWW-Authenticate values in
  24. + * a single header, so we only report Basic or Negotiate to web browsers and
  25. + * leave the multiple choices to the native CUPS client...
  26. + */
  27. +
  28. + con->is_browser = !strncmp(httpGetField(con->http, HTTP_FIELD_USER_AGENT), "Mozilla/", 8);
  29. +
  30. if (httpGetField(con->http, HTTP_FIELD_ACCEPT_LANGUAGE)[0])
  31. {
  32. /*
  33. @@ -2103,8 +2116,7 @@ cupsdSendHeader(
  34. strlcpy(auth_str, "Negotiate", sizeof(auth_str));
  35. }
  36. - if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE &&
  37. - !_cups_strcasecmp(httpGetHostname(con->http, NULL, 0), "localhost"))
  38. + if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE && !con->is_browser && !_cups_strcasecmp(httpGetHostname(con->http, NULL, 0), "localhost"))
  39. {
  40. /*
  41. * Add a "trc" (try root certification) parameter for local non-Kerberos
  42. diff --git a/scheduler/client.h b/scheduler/client.h
  43. index aaca8279a..fc7af5400 100644
  44. --- a/scheduler/client.h
  45. +++ b/scheduler/client.h
  46. @@ -26,6 +27,7 @@ struct cupsd_client_s
  47. struct timeval start; /* Request start time */
  48. http_state_t operation; /* Request operation */
  49. off_t bytes; /* Bytes transferred for this request */
  50. + int is_browser; /* Is the client a web browser? */
  51. int type; /* AuthType for username */
  52. char username[HTTP_MAX_VALUE],
  53. /* Username from Authorization: line */
  54. --
  55. 2.17.0