]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Set correct passdb entry in auth_worker_handle_passw
authorPxPert <pxpert@gmail.com>
Wed, 8 Jun 2022 11:03:20 +0000 (13:03 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 25 Sep 2023 10:38:49 +0000 (13:38 +0300)
src/auth/auth-worker-server.c

index d0c154345f9b64315a78086e572ee46482f10ac5..bd9abd85d9b61107f620b4ebf408eb6c3c6c7c9e 100644 (file)
@@ -301,6 +301,7 @@ auth_worker_handle_passw(struct auth_worker_command *cmd,
 {
        struct auth_worker_server *server = cmd->server;
        struct auth_request *request;
+       struct auth_passdb *passdb;
        string_t *str;
        const char *password;
        const char *crypted, *scheme, *error;
@@ -327,6 +328,25 @@ auth_worker_handle_passw(struct auth_worker_command *cmd,
        request->mech_password =
                p_strdup(request->pool, password);
 
+       passdb = request->passdb;
+       while (passdb != NULL && passdb->passdb->id != passdb_id)
+               passdb = passdb->next;
+
+       if (passdb == NULL) {
+               /* could be a masterdb */
+               passdb = auth_request_get_auth(request)->masterdbs;
+               while (passdb != NULL && passdb->passdb->id != passdb_id)
+                       passdb = passdb->next;
+
+               if (passdb == NULL) {
+                       *error_r = "BUG: PASSW had invalid passdb ID";
+                       auth_request_unref(&request);
+                       return FALSE;
+               }
+       }
+
+       request->passdb = passdb;
+
        ret = auth_request_password_verify(request, password,
                                           crypted, scheme, "cache");
        str = t_str_new(128);