]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: sasl-server - Move nologin flag from local variable to client struct
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 20 Oct 2023 02:41:11 +0000 (04:41 +0200)
committerstephan.bosch <stephan.bosch@open-xchange.com>
Mon, 23 Oct 2023 15:50:54 +0000 (15:50 +0000)
src/login-common/client-common.h
src/login-common/sasl-server.c

index a1630155a1e5cb69e149a7197937960637690e10..017e06f495f80fe2c294429b277d8efe460a00b4 100644 (file)
@@ -277,6 +277,7 @@ struct client {
        bool auth_initializing:1;
        bool auth_process_comm_fail:1;
        bool auth_anonymous:1;
+       bool auth_nologin:1;
        bool auth_nologin_referral:1;
        bool proxy_auth_failed:1;
        bool proxy_noauth:1;
index 6edf6a4cd01a9a70e9dec94703341f284395e311..cb0370884ae9c15009ed366bed5dfa0489e45109 100644 (file)
@@ -323,13 +323,12 @@ args_parse_user(struct client *client, const char *key, const char *value)
 }
 
 static void
-sasl_server_auth_success_finish(struct client *client,
-                               bool nologin, const char *const *args)
+sasl_server_auth_success_finish(struct client *client, const char *const *args)
 {
        struct auth_client_request *request = client->auth_request;
 
        client->auth_request = NULL;
-       if (nologin) {
+       if (client->auth_nologin) {
                client->authenticating = FALSE;
                call_client_callback(client, SASL_SERVER_REPLY_SUCCESS,
                                     NULL, args);
@@ -347,7 +346,6 @@ authenticate_callback(struct auth_client_request *request,
 {
        struct client *client = context;
        unsigned int i;
-       bool nologin;
 
        if (!client->authenticating) {
                /* client aborted */
@@ -369,7 +367,6 @@ authenticate_callback(struct auth_client_request *request,
                client->auth_passdb_args = p_strarray_dup(client->pool, args);
                client->postlogin_socket_path = NULL;
 
-               nologin = FALSE;
                for (i = 0; args[i] != NULL; i++) {
                        const char *key, *value;
                        t_split_key_value_eq(args[i], &key, &value);
@@ -383,7 +380,7 @@ authenticate_callback(struct auth_client_request *request,
                        } else if (strcmp(key, "nologin") == 0 ||
                                   strcmp(key, "proxy") == 0) {
                                /* user can't login */
-                               nologin = TRUE;
+                               client->auth_nologin = TRUE;
                        } else if (strcmp(key, "anonymous") == 0) {
                                client->auth_anonymous = TRUE;
                        } else if (str_begins(args[i], "event_", &key)) {
@@ -391,7 +388,7 @@ authenticate_callback(struct auth_client_request *request,
                        }
                }
 
-               sasl_server_auth_success_finish(client, nologin, args);
+               sasl_server_auth_success_finish(client, args);
                break;
        case AUTH_REQUEST_STATUS_INTERNAL_FAIL:
                client->auth_process_comm_fail = TRUE;
@@ -535,6 +532,7 @@ void sasl_server_auth_begin(struct client *client, const char *mech_name,
 
        client->auth_attempts++;
        client->auth_aborted_by_client = FALSE;
+       client->auth_nologin = FALSE;
        client->authenticating = TRUE;
        client->master_auth_id = 0;
        if (client->auth_first_started.tv_sec == 0)