]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: sasl-server - Split off sasl_server_auth_success_finish()
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 10 Oct 2023 00:23:58 +0000 (02:23 +0200)
committerstephan.bosch <stephan.bosch@open-xchange.com>
Mon, 23 Oct 2023 15:50:54 +0000 (15:50 +0000)
src/login-common/sasl-server.c

index 75b82036d4dd1d3883959682af084fe337eb8f4a..6edf6a4cd01a9a70e9dec94703341f284395e311 100644 (file)
@@ -322,6 +322,24 @@ args_parse_user(struct client *client, const char *key, const char *value)
        return TRUE;
 }
 
+static void
+sasl_server_auth_success_finish(struct client *client,
+                               bool nologin, const char *const *args)
+{
+       struct auth_client_request *request = client->auth_request;
+
+       client->auth_request = NULL;
+       if (nologin) {
+               client->authenticating = FALSE;
+               call_client_callback(client, SASL_SERVER_REPLY_SUCCESS,
+                                    NULL, args);
+       } else if (!sasl_server_check_login(client)) {
+               i_assert(!client->authenticating);
+       } else {
+               anvil_check_too_many_connections(client, request);
+       }
+}
+
 static void
 authenticate_callback(struct auth_client_request *request,
                      enum auth_request_status status, const char *data_base64,
@@ -347,7 +365,6 @@ authenticate_callback(struct auth_client_request *request,
                break;
        case AUTH_REQUEST_STATUS_OK:
                client->master_auth_id = auth_client_request_get_id(request);
-               client->auth_request = NULL;
                client->auth_successes++;
                client->auth_passdb_args = p_strarray_dup(client->pool, args);
                client->postlogin_socket_path = NULL;
@@ -374,15 +391,7 @@ authenticate_callback(struct auth_client_request *request,
                        }
                }
 
-               if (nologin) {
-                       client->authenticating = FALSE;
-                       call_client_callback(client, SASL_SERVER_REPLY_SUCCESS,
-                                            NULL, args);
-               } else if (!sasl_server_check_login(client)) {
-                       i_assert(!client->authenticating);
-               } else {
-                       anvil_check_too_many_connections(client, request);
-               }
+               sasl_server_auth_success_finish(client, nologin, args);
                break;
        case AUTH_REQUEST_STATUS_INTERNAL_FAIL:
                client->auth_process_comm_fail = TRUE;