]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Fixed caching empty userdb result.
authorTimo Sirainen <tss@iki.fi>
Tue, 28 May 2013 13:30:38 +0000 (16:30 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 28 May 2013 13:30:38 +0000 (16:30 +0300)
src/auth/auth-request.c

index 593eec9bec771488dc10725019ba83953a605e02..53153af0134b3e1eeee1d31efd63ea33cc32ffba 100644 (file)
@@ -32,6 +32,7 @@
 #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;
@@ -923,6 +924,11 @@ static void auth_request_userdb_save_cache(struct auth_request *request,
                auth_fields_append(request->userdb_reply, str,
                                   AUTH_FIELD_FLAG_CHANGED,
                                   AUTH_FIELD_FLAG_CHANGED);
+               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);
+               }
                cache_value = str_c(str);
        }
        /* last_success has no meaning with userdb */
@@ -1503,6 +1509,8 @@ 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) {
+               return;
        }
 
        auth_fields_add(request->userdb_reply, name, value, 0);