From: msweet Date: Wed, 19 Mar 2014 18:33:23 +0000 (+0000) Subject: Fix handling of default username. X-Git-Tag: v2.2b1~709 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4745f485c43795f86006bd159388c28606c5ce07;p=thirdparty%2Fcups.git Fix handling of default username. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11705 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/backend/ipp.c b/backend/ipp.c index 512490fda0..fb4d9e6357 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -3001,6 +3001,8 @@ password_cb(const char *prompt, /* I - Prompt (not used) */ { (*password_tries) ++; + cupsSetUser(username); + return (password); } else diff --git a/test/ipptool.c b/test/ipptool.c index 00124c1f0d..1fce1d8658 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -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); }