]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: If blocking passdb returned only NULLs for userdb_ fields, use userdb prefetch...
authorTimo Sirainen <tss@iki.fi>
Thu, 11 Jul 2013 23:43:43 +0000 (02:43 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 11 Jul 2013 23:43:43 +0000 (02:43 +0300)
src/auth/auth-request.c
src/auth/auth-request.h
src/auth/auth-worker-client.c

index cfcf24bcd75b0e190ad17cfae3e93cf2882dfd83..7fbfc13984371346a2da1c50ac92cf8e826e0858 100644 (file)
@@ -32,7 +32,6 @@
 #define AUTH_DNS_DEFAULT_TIMEOUT_MSECS (1000*10)
 #define AUTH_DNS_WARN_MSECS 500
 #define CACHED_PASSWORD_SCHEME "SHA1"
-#define AUTH_REQUEST_KEY_IGNORE " "
 
 struct auth_request_proxy_dns_lookup_ctx {
        struct auth_request *request;
@@ -928,7 +927,7 @@ static void auth_request_userdb_save_cache(struct auth_request *request,
                if (str_len(str) == 0) {
                        /* no userdb fields. but we can't save an empty string,
                           since that means "user unknown". */
-                       str_append(str, AUTH_REQUEST_KEY_IGNORE);
+                       str_append(str, AUTH_REQUEST_USER_KEY_IGNORE);
                }
                cache_value = str_c(str);
        }
@@ -1520,7 +1519,7 @@ void auth_request_set_userdb_field(struct auth_request *request,
                        warned = TRUE;
                }
                name = "system_groups_user";
-       } else if (strcmp(name, AUTH_REQUEST_KEY_IGNORE) == 0) {
+       } else if (strcmp(name, AUTH_REQUEST_USER_KEY_IGNORE) == 0) {
                return;
        }
 
index be02283cd3a8fc2ae08dd76b01802d8fb608de59..8581a83496fbcbe7e9858b50fcec63f6bb95f10c 100644 (file)
@@ -7,6 +7,8 @@
 #include "userdb.h"
 #include "passdb.h"
 
+#define AUTH_REQUEST_USER_KEY_IGNORE " "
+
 struct auth_client_connection;
 
 enum auth_request_state {
index 9667ff285c93e71cdb4c70637718adb4852ab3d7..1573576106218bfc475967dcf599e4abdbacf395 100644 (file)
@@ -109,6 +109,21 @@ static void auth_worker_send_reply(struct auth_worker_client *client,
        o_stream_nsend(client->output, str_data(str), str_len(str));
 }
 
+static void
+reply_append_extra_fields(string_t *str, struct auth_request *request)
+{
+       if (!auth_fields_is_empty(request->extra_fields)) {
+               str_append_c(str, '\t');
+               auth_fields_append(request->extra_fields, str, 0, 0);
+       }
+       if (request->userdb_reply != NULL &&
+           auth_fields_is_empty(request->userdb_reply)) {
+               /* all userdb_* fields had NULL values. we'll still
+                  need to tell this to the master */
+               str_append(str, "\tuserdb_"AUTH_REQUEST_USER_KEY_IGNORE);
+       }
+}
+
 static void verify_plain_callback(enum passdb_result result,
                                  struct auth_request *request)
 {
@@ -131,10 +146,7 @@ static void verify_plain_callback(enum passdb_result result,
                str_append_c(str, '\t');
                if (request->passdb_password != NULL)
                        str_append_tabescaped(str, request->passdb_password);
-               if (!auth_fields_is_empty(request->extra_fields)) {
-                       str_append_c(str, '\t');
-                       auth_fields_append(request->extra_fields, str, 0, 0);
-               }
+               reply_append_extra_fields(str, request);
        }
        str_append_c(str, '\n');
        auth_worker_send_reply(client, str);
@@ -215,11 +227,7 @@ lookup_credentials_callback(enum passdb_result result,
                str_append_tabescaped(str, request->user);
                str_printfa(str, "\t{%s.b64}", request->credentials_scheme);
                base64_encode(credentials, size, str);
-
-               if (!auth_fields_is_empty(request->extra_fields)) {
-                       str_append_c(str, '\t');
-                       auth_fields_append(request->extra_fields, str, 0, 0);
-               }
+               reply_append_extra_fields(str, request);
        }
        str_append_c(str, '\n');
        auth_worker_send_reply(client, str);