]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: auth-request - Fix success response data without policy lookup
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 1 Nov 2023 23:06:06 +0000 (00:06 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Nov 2023 10:49:10 +0000 (10:49 +0000)
In that case the success data was discarded and not passed to the client.

src/auth/auth-request.c

index a7db045f8afd90240530a7acf9f5335aaaadbf57..3c563afa03c58e4dfdcd8f5d9231968d5b572c11 100644 (file)
@@ -185,23 +185,20 @@ void auth_request_success(struct auth_request *request,
        if (request->fields.userdb_reply != NULL)
                auth_fields_snapshot(request->fields.userdb_reply);
 
+       struct auth_policy_check_ctx *ctx;
+
+       ctx = p_new(request->pool, struct auth_policy_check_ctx, 1);
+       ctx->request = request;
+       ctx->success_data = buffer_create_dynamic(request->pool, data_size);
+       buffer_append(ctx->success_data, data, data_size);
+       ctx->type = AUTH_POLICY_CHECK_TYPE_SUCCESS;
+
        if (!request->set->policy_check_after_auth) {
-               struct auth_policy_check_ctx *ctx =
-                       p_new(request->pool, struct auth_policy_check_ctx, 1);
-               ctx->success_data = buffer_create_dynamic(request->pool, 1);
-               ctx->request = request;
-               ctx->type = AUTH_POLICY_CHECK_TYPE_SUCCESS;
                auth_request_policy_check_callback(0, ctx);
                return;
        }
 
        /* perform second policy lookup here */
-       struct auth_policy_check_ctx *ctx =
-               p_new(request->pool, struct auth_policy_check_ctx, 1);
-       ctx->request = request;
-       ctx->success_data = buffer_create_dynamic(request->pool, data_size);
-       buffer_append(ctx->success_data, data, data_size);
-       ctx->type = AUTH_POLICY_CHECK_TYPE_SUCCESS;
        auth_policy_check(request, request->mech_password,
                          auth_request_policy_check_callback, ctx);
 }