]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/auth.c
Merge changes from CUPS 1.5svn-r9022.
[thirdparty/cups.git] / cups / auth.c
index d37b685f96311305b5ac047547add2704e659db3..63e5ed28250cec1cce7f8c6bdf50d967cc88f515 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Authentication functions for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2009 by Apple Inc.
+ *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   This file contains Kerberos support code, copyright 2006 by
@@ -98,10 +98,6 @@ cupsDoAuthentication(
 
   DEBUG_printf(("cupsDoAuthentication(http=%p, method=\"%s\", resource=\"%s\")",
                 http, method, resource));
-  DEBUG_printf(("2cupsDoAuthentication: digest_tries=%d, userpass=\"%s\"",
-                http->digest_tries, http->userpass));
-  DEBUG_printf(("2cupsDoAuthentication: WWW-Authenticate=\"%s\"",
-                httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE)));
 
   if (!http)
     http = _cupsConnect();
@@ -109,6 +105,11 @@ cupsDoAuthentication(
   if (!http || !method || !resource)
     return (-1);
 
+  DEBUG_printf(("2cupsDoAuthentication: digest_tries=%d, userpass=\"%s\"",
+                http->digest_tries, http->userpass));
+  DEBUG_printf(("2cupsDoAuthentication: WWW-Authenticate=\"%s\"",
+                httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE)));
+
  /*
   * Clear the current authentication string...
   */
@@ -181,6 +182,15 @@ cupsDoAuthentication(
   else if (http->status == HTTP_UNAUTHORIZED)
     http->digest_tries ++;
 
+  if (http->status == HTTP_UNAUTHORIZED && http->digest_tries >= 3)
+  {
+    DEBUG_printf(("1cupsDoAuthentication: Too many authentication tries (%d)",
+                 http->digest_tries));
+
+    http->status = HTTP_AUTHORIZATION_CANCELED;
+    return (-1);
+  }
+
  /*
   * Got a password; encode it for the server...
   */
@@ -222,15 +232,6 @@ cupsDoAuthentication(
     }
 #  endif /* __APPLE__ */
 
-    if (http->status == HTTP_UNAUTHORIZED && http->digest_tries >= 3)
-    {
-      DEBUG_printf(("1cupsDoAuthentication: too many Negotiate tries (%d)",
-                    http->digest_tries));
-      http->status = HTTP_AUTHORIZATION_CANCELED;
-  
-      return (-1);
-    }
-
     if (http->gssname == GSS_C_NO_NAME)
     {
       if ((gss_service_name = getenv("CUPS_GSSSERVICENAME")) == NULL)