]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: passdb-cache - Preserve cached fields when verifying password with worker
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 9 Nov 2021 12:37:07 +0000 (14:37 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 10 Nov 2021 09:48:26 +0000 (09:48 +0000)
src/auth/passdb-cache.c

index 9daa0f97b5ea4a6f5a1d0b9599da6a9e485cd02b..ecababde4e3179909cc536ab023c5c324e7f13fc 100644 (file)
@@ -59,6 +59,8 @@ static bool passdb_cache_verify_plain_callback(const char *reply, void *context)
        enum passdb_result result;
 
        result = passdb_blocking_auth_worker_reply_parse(request, reply);
+       if (result != PASSDB_RESULT_OK)
+               auth_fields_rollback(request->fields.extra_fields);
        auth_request_verify_plain_callback_finish(result, request);
        auth_request_unref(&request);
        return TRUE;
@@ -110,6 +112,10 @@ bool passdb_cache_verify_plain(struct auth_request *request, const char *key,
                e_debug(authdb_event(request), "cache: "
                        "validating password on worker");
                auth_request_ref(request);
+               /* Save the extra fields already here, and take a snapshot.
+                  If verification fails, roll back fields. */
+               auth_request_set_fields(request, list + 1, NULL);
+               auth_fields_snapshot(request->fields.extra_fields);
                auth_worker_call(request->pool, request->fields.user, str_c(str),
                                 passdb_cache_verify_plain_callback, request);
                return TRUE;