]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: passdb credentials lookup fix when using multiple passdbs.
authorTimo Sirainen <tss@iki.fi>
Thu, 2 Dec 2010 19:10:23 +0000 (19:10 +0000)
committerTimo Sirainen <tss@iki.fi>
Thu, 2 Dec 2010 19:10:23 +0000 (19:10 +0000)
If at least one passdb returns "user unknown" and the last passdb returns
"credential lookup not supported", the proper return value is still
"user unknown".

src/auth/auth-request.c
src/auth/auth-request.h

index 63ce67deb3cb2f232f90b9da3de529df735e7a87..de592cf19c25ea9cb2c38c77d28fa93eb1a55240 100644 (file)
@@ -440,7 +440,11 @@ auth_request_handle_passdb_callback(enum passdb_result *result,
                 request->passdb = request->passdb->next;
                request->passdb_password = NULL;
 
-                if (*result == PASSDB_RESULT_INTERNAL_FAILURE) {
+               if (*result == PASSDB_RESULT_USER_UNKNOWN) {
+                       /* remember that we did at least one successful
+                          passdb lookup */
+                       request->passdb_user_unknown = TRUE;
+               } else if (*result == PASSDB_RESULT_INTERNAL_FAILURE) {
                        /* remember that we have had an internal failure. at
                           the end return internal failure if we couldn't
                           successfully login. */
@@ -596,6 +600,12 @@ auth_request_lookup_credentials_finish(enum passdb_result result,
                                "Credentials: %s",
                                binary_to_hex(credentials, size));
                }
+               if (result == PASSDB_RESULT_SCHEME_NOT_AVAILABLE &&
+                   request->passdb_user_unknown) {
+                       /* one of the passdbs accepted the scheme,
+                          but the user was unknown there */
+                       result = PASSDB_RESULT_USER_UNKNOWN;
+               }
                request->private_callback.
                        lookup_credentials(result, credentials, size, request);
        }
index eeadb799c1693a70bc28049ee02eaa081915cda5..42cffd12aa72f2f840ab1568bfdc9b51f25e323e 100644 (file)
@@ -92,6 +92,7 @@ struct auth_request {
        unsigned int successful:1;
        unsigned int passdb_failure:1;
        unsigned int internal_failure:1;
+       unsigned int passdb_user_unknown:1;
        unsigned int passdb_internal_failure:1;
        unsigned int userdb_internal_failure:1;
        unsigned int delayed_failure:1;