]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix handling of default username.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 19 Mar 2014 18:33:23 +0000 (18:33 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 19 Mar 2014 18:33:23 +0000 (18:33 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11705 a1ca3aef-8c08-0410-bb20-df032aa958be

backend/ipp.c
test/ipptool.c

index 512490fda0b75d45b99dddd5042e201fcb985f20..fb4d9e6357fa2599446642d0d7ea2b7ebd410a04 100644 (file)
@@ -3001,6 +3001,8 @@ password_cb(const char *prompt,           /* I - Prompt (not used) */
   {
     (*password_tries) ++;
 
+    cupsSetUser(username);
+
     return (password);
   }
   else
index 00124c1f0d48b953921f046e3ba62c779c5ecbdb..1fce1d865892cdf616e577a843071d9717915b81 100644 (file)
@@ -138,7 +138,9 @@ static int  Cancel = 0,             /* Cancel test? */
                PassCount = 0,          /* Number of passing tests */
                FailCount = 0,          /* Number of failing tests */
                SkipCount = 0;          /* Number of skipped tests */
-static char    *Password = NULL;       /* Password from URI */
+static char    *Username = NULL,       /* Username from URI */
+               *Password = NULL;       /* Password from URI */
+static int     PasswordTries = 0;      /* Number of tries with password */
 
 
 /*
@@ -591,7 +593,7 @@ main(int  argc,                             /* I - Number of command-line args */
         if ((Password = strchr(vars.userpass, ':')) != NULL)
          *Password++ = '\0';
 
-        cupsSetUser(vars.userpass);
+        Username = vars.userpass;
        cupsSetPasswordCB(password_cb);
        set_variable(&vars, "uriuser", vars.userpass);
       }
@@ -2404,6 +2406,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
       goto skip_error;
     }
 
+    PasswordTries   = 0;
     repeat_count    = 0;
     repeat_interval = 1;
     repeat_prev     = 1;
@@ -2412,7 +2415,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
     {
       repeat_count ++;
 
-      status = HTTP_OK;
+      status = HTTP_STATUS_OK;
 
       if (transfer == _CUPS_TRANSFER_CHUNKED ||
          (transfer == _CUPS_TRANSFER_AUTO && filename[0]))
@@ -2452,7 +2455,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
       repeat_test = 0;
       prev_pass   = 1;
 
-      if (status != HTTP_ERROR)
+      if (status != HTTP_STATUS_ERROR)
       {
        while (!response && !Cancel && prev_pass)
        {
@@ -2463,14 +2466,14 @@ do_tests(_cups_vars_t *vars,            /* I - Variables */
            httpSetField(http, HTTP_FIELD_CONTENT_ENCODING, compression);
 #endif /* HAVE_LIBZ */
 
-         if (!Cancel && status == HTTP_CONTINUE &&
+         if (!Cancel && status == HTTP_STATUS_CONTINUE &&
              request->state == IPP_DATA && filename[0])
          {
            if ((reqfile = cupsFileOpen(filename, "r")) != NULL)
            {
              while (!Cancel &&
                     (bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0)
-               if ((status = cupsWriteRequestData(http, buffer, (size_t)bytes)) != HTTP_CONTINUE)
+               if ((status = cupsWriteRequestData(http, buffer, (size_t)bytes)) != HTTP_STATUS_CONTINUE)
                  break;
 
              cupsFileClose(reqfile);
@@ -2481,7 +2484,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
                       strerror(errno));
              _cupsSetError(IPP_INTERNAL_ERROR, buffer, 0);
 
-             status = HTTP_ERROR;
+             status = HTTP_STATUS_ERROR;
            }
          }
 
@@ -2489,13 +2492,13 @@ do_tests(_cups_vars_t *vars,            /* I - Variables */
          * Get the server's response...
          */
 
-         if (!Cancel && status != HTTP_ERROR)
+         if (!Cancel && status != HTTP_STATUS_ERROR)
          {
            response = cupsGetResponse(http, resource);
            status   = httpGetStatus(http);
          }
 
-         if (!Cancel && status == HTTP_ERROR && http->error != EINVAL &&
+         if (!Cancel && status == HTTP_STATUS_ERROR && http->error != EINVAL &&
 #ifdef WIN32
              http->error != WSAETIMEDOUT)
 #else
@@ -2505,12 +2508,12 @@ do_tests(_cups_vars_t *vars,            /* I - Variables */
            if (httpReconnect(http))
              prev_pass = 0;
          }
-         else if (status == HTTP_ERROR)
+         else if (status == HTTP_STATUS_ERROR || status == HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED)
          {
            prev_pass = 0;
            break;
          }
-         else if (status != HTTP_OK)
+         else if (status != HTTP_STATUS_OK)
          {
            httpFlush(http);
 
@@ -2522,7 +2525,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
        }
       }
 
-      if (!Cancel && status == HTTP_ERROR && http->error != EINVAL &&
+      if (!Cancel && status == HTTP_STATUS_ERROR && http->error != EINVAL &&
 #ifdef WIN32
          http->error != WSAETIMEDOUT)
 #else
@@ -2532,14 +2535,14 @@ do_tests(_cups_vars_t *vars,            /* I - Variables */
        if (httpReconnect(http))
          prev_pass = 0;
       }
-      else if (status == HTTP_ERROR)
+      else if (status == HTTP_STATUS_ERROR)
       {
         if (!Cancel)
           httpReconnect(http);
 
        prev_pass = 0;
       }
-      else if (status != HTTP_OK)
+      else if (status != HTTP_STATUS_OK)
       {
         httpFlush(http);
         prev_pass = 0;
@@ -3895,7 +3898,16 @@ password_cb(const char *prompt)          /* I - Prompt (unused) */
 {
   (void)prompt;
 
-  return (Password);
+  if (PasswordTries < 3)
+  {
+    PasswordTries ++;
+
+    cupsSetUser(Username);
+
+    return (Password);
+  }
+  else
+    return (NULL);
 }