]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: sasl-server - Rename mech_name field to name in struct sasl_server_mech_def
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sun, 26 Mar 2023 17:33:40 +0000 (19:33 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 9 Oct 2025 08:41:22 +0000 (08:41 +0000)
23 files changed:
src/auth/auth-client-connection.c
src/auth/auth-request-fields.c
src/auth/auth-request-handler.c
src/auth/auth-request.c
src/auth/auth-sasl-mech-apop.c
src/auth/auth-sasl-mech-dovecot-token.c
src/auth/auth-sasl-mech-oauth2.c
src/auth/auth.c
src/auth/mech.c
src/auth/sasl-server-mech-anonymous.c
src/auth/sasl-server-mech-cram-md5.c
src/auth/sasl-server-mech-digest-md5.c
src/auth/sasl-server-mech-external.c
src/auth/sasl-server-mech-gssapi.c
src/auth/sasl-server-mech-login.c
src/auth/sasl-server-mech-oauth2.c
src/auth/sasl-server-mech-otp.c
src/auth/sasl-server-mech-plain.c
src/auth/sasl-server-mech-scram.c
src/auth/sasl-server-mech-winbind.c
src/auth/sasl-server-protected.h
src/auth/sasl-server-request.c
src/auth/test-mech.c

index 48a1a6dfde5d714213d6833b6dce2bde7fdc4cee..28de8929514da70e1a432d7061735141322a844a 100644 (file)
@@ -193,7 +193,7 @@ static void auth_client_finish_handshake(struct auth_client_connection *conn)
 
        if (conn->token_auth) {
                mechanisms = t_strconcat("MECH\t",
-                       mech_dovecot_token.mech_name, "\tprivate\n", NULL);
+                       mech_dovecot_token.name, "\tprivate\n", NULL);
        } else {
                mechanisms = str_c(conn->auth->reg->handshake);
                if (conn->conn.minor_version >= AUTH_CLIENT_MINOR_VERSION_CHANNEL_BINDING) {
index e332e0349daa8d317acd134a9eb9751e4ad7012d..c86b3f7c870fa771b1e935dfdcbcf16c317d901e 100644 (file)
@@ -20,9 +20,9 @@ void auth_request_fields_alloc(struct auth_request *request)
 void auth_request_fields_init(struct auth_request *request)
 {
        if (request->mech != NULL) {
-               request->fields.mech_name = request->mech->mech_name;
+               request->fields.mech_name = request->mech->name;
                event_add_str(request->event, "mechanism",
-                             request->mech->mech_name);
+                             request->mech->name);
        }
 }
 
index 90c3a56d1239ffa86308ea582ff495e229794b13..0a2f5c1e0b5dde07933b404f89adfe99533af63a 100644 (file)
@@ -576,7 +576,7 @@ auth_request_handler_find_mech(struct auth_request_handler *handler,
 
        if (handler->token_auth) {
                mech = &mech_dovecot_token;
-               if (strcmp(mech_name, mech->mech_name) == 0) {
+               if (strcmp(mech_name, mech->name) == 0) {
                        *mech_r = mech;
                        return 0;
                }
@@ -850,7 +850,7 @@ static void auth_str_append_userdb_extra_fields(struct auth_request *request,
                auth_str_add_keyvalue(dest, "master_user",
                                      request->fields.master_user);
        }
-       auth_str_add_keyvalue(dest, "auth_mech", request->mech->mech_name);
+       auth_str_add_keyvalue(dest, "auth_mech", request->mech->name);
        if (*request->set->anonymous_username != '\0' &&
            strcmp(request->fields.user, request->set->anonymous_username) == 0) {
                /* this is an anonymous login, either via ANONYMOUS
index 3bc0f555e9f299dd9d22eed9714b75cd9cf0a939..d955868b03957171bb336690dfd8a70bc2ed817a 100644 (file)
@@ -87,7 +87,7 @@ static const char *get_log_prefix(struct auth_request *auth_request)
        }
        if (auth_request->mech != NULL) {
                str_append(str, ",sasl:");
-               str_append(str, t_str_lcase(auth_request->mech->mech_name));
+               str_append(str, t_str_lcase(auth_request->mech->name));
        }
        if (auth_request->fields.requested_login_user != NULL)
                str_append(str, ",master");
@@ -197,7 +197,7 @@ void auth_request_init_sasl(struct auth_request *request,
        request->mech = mech;
 
        const char *prefix = t_strconcat(
-               t_str_lcase(request->mech->mech_name), ": ", NULL);
+               t_str_lcase(request->mech->name), ": ", NULL);
 
        request->mech_event = event_create(request->event);
        event_set_append_log_prefix(request->mech_event, prefix);
@@ -533,7 +533,7 @@ auth_request_mechanism_accepted(const char *const *mechs,
        if (mech == NULL)
                return str_array_icase_find(mechs, "lookup");
        /* check if request mechanism is accepted */
-       return str_array_icase_find(mechs, mech->mech_name);
+       return str_array_icase_find(mechs, mech->name);
 }
 
 /**
index ae200ce745ed1e0a5bbd0931f29710ab258a24f5..95b954b71569185f9d870dfaf082b585af2a5b77 100644 (file)
@@ -160,7 +160,7 @@ static const struct sasl_server_mech_funcs mech_apop_funcs = {
 };
 
 const struct sasl_server_mech_def mech_apop = {
-       .mech_name = "APOP",
+       .name = "APOP",
 
        .flags = SASL_MECH_SEC_PRIVATE | SASL_MECH_SEC_DICTIONARY |
                 SASL_MECH_SEC_ACTIVE | SASL_MECH_SEC_ALLOW_NULS,
index e1b2453d72c3964121475ead7e05bd819611f83e..365f7be30834812b38d4a450b4238a7744bade19 100644 (file)
@@ -74,7 +74,7 @@ static const struct sasl_server_mech_funcs mech_dovecot_token_funcs = {
 };
 
 const struct sasl_server_mech_def mech_dovecot_token = {
-       .mech_name = "DOVECOT-TOKEN",
+       .name = "DOVECOT-TOKEN",
 
        .flags = SASL_MECH_SEC_PRIVATE | SASL_MECH_SEC_ALLOW_NULS,
        .passdb_need = SASL_MECH_PASSDB_NEED_NOTHING,
index 8c2d5a30ede6d6843c73fad69461b6fe801fea74..e9b81055f85624f09588fcc8ee01e50c60e9ab4c 100644 (file)
@@ -173,8 +173,8 @@ void auth_sasl_oauth2_initialize(void)
 {
        const char *mech, *error;
        array_foreach_elem(&global_auth_settings->mechanisms, mech) {
-               if (strcasecmp(mech, mech_xoauth2.mech_name) == 0 ||
-                   strcasecmp(mech, mech_oauthbearer.mech_name) == 0) {
+               if (strcasecmp(mech, mech_xoauth2.name) == 0 ||
+                   strcasecmp(mech, mech_oauthbearer.name) == 0) {
                        if (db_oauth2_init(auth_event, FALSE,
                                           &db_oauth2, &error) < 0)
                                i_fatal("Cannot initialize oauth2: %s", error);
index 813183f08f50389c24f9aa86671a05a8dcc9adaf..b18e7709a45473c96fb0fab5bc95f8e3175f0855 100644 (file)
@@ -280,10 +280,10 @@ static void auth_mech_list_verify_passdb(const struct auth *auth)
                if (auth->passdbs == NULL) {
                        i_fatal("No passdbs specified in configuration file. "
                                "%s mechanism needs one",
-                               list->module->mech_name);
+                               list->module->name);
                }
                i_fatal("%s mechanism can't be supported with given passdbs",
-                       list->module->mech_name);
+                       list->module->name);
        }
 }
 
index 8668c818de96cdd6b749171c38d44eec1fbc3c47..4bbc17e60f36dbb09ee0309fe6ee4e942e093380 100644 (file)
@@ -15,7 +15,7 @@ static struct mech_module_list *mech_modules;
 void mech_register_module(const struct sasl_server_mech_def *module)
 {
        struct mech_module_list *list;
-       i_assert(strcmp(module->mech_name, t_str_ucase(module->mech_name)) == 0);
+       i_assert(strcmp(module->name, t_str_ucase(module->name)) == 0);
 
        list = i_new(struct mech_module_list, 1);
        list->module = module;
@@ -29,7 +29,7 @@ void mech_unregister_module(const struct sasl_server_mech_def *module)
        struct mech_module_list **pos, *list;
 
        for (pos = &mech_modules; *pos != NULL; pos = &(*pos)->next) {
-               if (strcmp((*pos)->module->mech_name, module->mech_name) == 0) {
+               if (strcmp((*pos)->module->name, module->name) == 0) {
                        list = *pos;
                        *pos = (*pos)->next;
                        i_free(list);
@@ -44,7 +44,7 @@ const struct sasl_server_mech_def *mech_module_find(const char *name)
        name = t_str_ucase(name);
 
        for (list = mech_modules; list != NULL; list = list->next) {
-               if (strcmp(list->module->mech_name, name) == 0)
+               if (strcmp(list->module->name, name) == 0)
                        return list->module;
        }
        return NULL;
@@ -87,7 +87,7 @@ static void mech_register_add(struct mechanisms_register *reg,
        else
                handshake = reg->handshake;
 
-       str_printfa(handshake, "MECH\t%s", mech->mech_name);
+       str_printfa(handshake, "MECH\t%s", mech->name);
        if ((mech->flags & SASL_MECH_SEC_PRIVATE) != 0)
                str_append(handshake, "\tprivate");
        if ((mech->flags & SASL_MECH_SEC_ANONYMOUS) != 0)
@@ -180,7 +180,7 @@ mech_register_find(const struct mechanisms_register *reg, const char *name)
        name = t_str_ucase(name);
 
        for (list = reg->modules; list != NULL; list = list->next) {
-               if (strcmp(list->module->mech_name, name) == 0)
+               if (strcmp(list->module->name, name) == 0)
                        return list->module;
        }
        return NULL;
index d0dd09c3ad784a04c864c85c3eeab68c99b23885..60a1825d1e8aea7c88667edb16e00bed5291bd18 100644 (file)
@@ -25,7 +25,7 @@ static const struct sasl_server_mech_funcs mech_anonymous_funcs = {
 };
 
 const struct sasl_server_mech_def mech_anonymous = {
-       .mech_name = "ANONYMOUS",
+       .name = "ANONYMOUS",
 
        .flags = SASL_MECH_SEC_ANONYMOUS | SASL_MECH_SEC_ALLOW_NULS,
        .passdb_need = SASL_MECH_PASSDB_NEED_NOTHING,
index b841c20ecf6a4b2ba3c4749fef77ae4a8934879b..ee71c273aadfdb7456317e91f5a9360c10c499fa 100644 (file)
@@ -180,7 +180,7 @@ static const struct sasl_server_mech_funcs mech_cram_md5_funcs = {
 };
 
 const struct sasl_server_mech_def mech_cram_md5 = {
-       .mech_name = "CRAM-MD5",
+       .name = "CRAM-MD5",
 
        .flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE,
        .passdb_need = SASL_MECH_PASSDB_NEED_VERIFY_RESPONSE,
index c5e9cadc725a234990ec1debab25785bcbb61acb..ef6b24ec7ac721635a74efef3a0b8496b0fff004 100644 (file)
@@ -611,7 +611,7 @@ static const struct sasl_server_mech_funcs mech_digest_md5_funcs = {
 };
 
 const struct sasl_server_mech_def mech_digest_md5 = {
-       .mech_name = "DIGEST-MD5",
+       .name = "DIGEST-MD5",
 
        .flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
                 SASL_MECH_SEC_MUTUAL_AUTH,
index 2a65b0e1985502cedb3ee96601c3fdd8dc1b2153..2a7ac27154c173ccab908376e32847e5a9852f5f 100644 (file)
@@ -34,7 +34,7 @@ static const struct sasl_server_mech_funcs mech_external_funcs = {
 };
 
 const struct sasl_server_mech_def mech_external = {
-       .mech_name = "EXTERNAL",
+       .name = "EXTERNAL",
 
        .flags = 0,
        .passdb_need = SASL_MECH_PASSDB_NEED_VERIFY_PLAIN,
index dbcb82c8d01fb1a3e9ac1cc19ec453de884a6818..d15cf08456eafe86755878bbf9c6934f827f77d6 100644 (file)
@@ -680,7 +680,7 @@ static const struct sasl_server_mech_funcs mech_gssapi_funcs = {
 };
 
 const struct sasl_server_mech_def mech_gssapi = {
-       .mech_name = "GSSAPI",
+       .name = "GSSAPI",
 
        .flags = SASL_MECH_SEC_ALLOW_NULS,
        .passdb_need = SASL_MECH_PASSDB_NEED_NOTHING,
@@ -692,7 +692,7 @@ const struct sasl_server_mech_def mech_gssapi = {
    internally. Nothing else needs to be done here. Note, however, that this does
    not support SPNEGO when the only available credential is NTLM. */
 const struct sasl_server_mech_def mech_gssapi_spnego = {
-       .mech_name = "GSS-SPNEGO",
+       .name = "GSS-SPNEGO",
 
        .flags = SASL_MECH_SEC_ALLOW_NULS,
        .passdb_need = SASL_MECH_PASSDB_NEED_NOTHING,
@@ -724,7 +724,7 @@ void mech_gssapi_init(void)
        mech_register_module(&mech_gssapi);
 #ifdef HAVE_GSSAPI_SPNEGO
        /* load if we already didn't load it using winbind */
-       if (mech_module_find(mech_gssapi_spnego.mech_name) == NULL)
+       if (mech_module_find(mech_gssapi_spnego.name) == NULL)
                mech_register_module(&mech_gssapi_spnego);
 #endif
 }
@@ -734,7 +734,7 @@ void mech_gssapi_deinit(void)
 #ifdef HAVE_GSSAPI_SPNEGO
        const struct sasl_server_mech_def *mech;
 
-       mech = mech_module_find(mech_gssapi_spnego.mech_name);
+       mech = mech_module_find(mech_gssapi_spnego.name);
        if (mech != NULL && mech == &mech_gssapi_spnego)
                mech_unregister_module(&mech_gssapi_spnego);
 #endif
index bf7892a5b0c964fefa31c5fb78ab7f2ab69637df..58fb246c0f6468b7348f80187f0cd95d05ea1444 100644 (file)
@@ -57,7 +57,7 @@ static const struct sasl_server_mech_funcs mech_login_funcs = {
 };
 
 const struct sasl_server_mech_def mech_login = {
-       .mech_name = "LOGIN",
+       .name = "LOGIN",
 
        .flags = SASL_MECH_SEC_PLAINTEXT,
        .passdb_need = SASL_MECH_PASSDB_NEED_VERIFY_PLAIN,
index e8988b088477941c77e176285338cdbb659e5daa..2213f2ee9ca98b749a596512c04f205f72020412 100644 (file)
@@ -320,7 +320,7 @@ static const struct sasl_server_mech_funcs mech_oauthbearer_funcs = {
 };
 
 const struct sasl_server_mech_def mech_oauthbearer = {
-       .mech_name = "OAUTHBEARER",
+       .name = "OAUTHBEARER",
 
        /* while this does not transfer plaintext password,
           the token is still considered as password */
@@ -337,7 +337,7 @@ static const struct sasl_server_mech_funcs mech_xoauth2_funcs = {
 };
 
 const struct sasl_server_mech_def mech_xoauth2 = {
-       .mech_name = "XOAUTH2",
+       .name = "XOAUTH2",
 
        .flags = SASL_MECH_SEC_PLAINTEXT,
        .passdb_need = 0,
index 6ff2cfadf931a8237703101dc3e1a34208b2859d..182ac212956a44f0b610d69210ce1826b1b1e514 100644 (file)
@@ -319,7 +319,7 @@ static const struct sasl_server_mech_funcs mech_otp_funcs = {
 };
 
 const struct sasl_server_mech_def mech_otp = {
-       .mech_name = "OTP",
+       .name = "OTP",
 
        .flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
                 SASL_MECH_SEC_ALLOW_NULS,
index 86c3ef8154d08e744011be76308f42aa165ffdf8..ecee61e251a7d56f972cb96479f3545b831c1834 100644 (file)
@@ -68,7 +68,7 @@ static const struct sasl_server_mech_funcs mech_plain_funcs = {
 };
 
 const struct sasl_server_mech_def mech_plain = {
-       .mech_name = "PLAIN",
+       .name = "PLAIN",
 
        .flags = SASL_MECH_SEC_PLAINTEXT | SASL_MECH_SEC_ALLOW_NULS,
        .passdb_need = SASL_MECH_PASSDB_NEED_VERIFY_PLAIN,
index 5ce483cffb8be4b865b5560932071a296b0d0995..a94fc0702d6b5f52a3ce504b902169beb23efd67 100644 (file)
@@ -239,7 +239,7 @@ static const struct sasl_server_mech_funcs mech_scram_sha1_funcs = {
 };
 
 const struct sasl_server_mech_def mech_scram_sha1 = {
-       .mech_name = "SCRAM-SHA-1",
+       .name = "SCRAM-SHA-1",
 
        .flags = SASL_MECH_SEC_MUTUAL_AUTH,
        .passdb_need = SASL_MECH_PASSDB_NEED_LOOKUP_CREDENTIALS,
@@ -248,7 +248,7 @@ const struct sasl_server_mech_def mech_scram_sha1 = {
 };
 
 const struct sasl_server_mech_def mech_scram_sha1_plus = {
-       .mech_name = "SCRAM-SHA-1-PLUS",
+       .name = "SCRAM-SHA-1-PLUS",
 
        .flags = SASL_MECH_SEC_MUTUAL_AUTH | SASL_MECH_SEC_CHANNEL_BINDING,
        .passdb_need = SASL_MECH_PASSDB_NEED_LOOKUP_CREDENTIALS,
@@ -264,7 +264,7 @@ static const struct sasl_server_mech_funcs mech_scram_sha256_funcs = {
 };
 
 const struct sasl_server_mech_def mech_scram_sha256 = {
-       .mech_name = "SCRAM-SHA-256",
+       .name = "SCRAM-SHA-256",
 
        .flags = SASL_MECH_SEC_MUTUAL_AUTH,
        .passdb_need = SASL_MECH_PASSDB_NEED_LOOKUP_CREDENTIALS,
@@ -273,7 +273,7 @@ const struct sasl_server_mech_def mech_scram_sha256 = {
 };
 
 const struct sasl_server_mech_def mech_scram_sha256_plus = {
-       .mech_name = "SCRAM-SHA-256-PLUS",
+       .name = "SCRAM-SHA-256-PLUS",
 
        .flags = SASL_MECH_SEC_MUTUAL_AUTH | SASL_MECH_SEC_CHANNEL_BINDING,
        .passdb_need = SASL_MECH_PASSDB_NEED_LOOKUP_CREDENTIALS,
index 2ed40d28c555aabac923b97df7760223834d9acb..509cb887360c8b098c5aaa23b82837fbd85abc62 100644 (file)
@@ -346,7 +346,7 @@ static const struct sasl_server_mech_funcs mech_winbind_ntlm_funcs = {
 };
 
 const struct sasl_server_mech_def mech_winbind_ntlm = {
-       .mech_name = "NTLM",
+       .name = "NTLM",
 
        .flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
                 SASL_MECH_SEC_ALLOW_NULS,
@@ -362,7 +362,7 @@ static const struct sasl_server_mech_funcs mech_winbind_spnego_funcs = {
 };
 
 const struct sasl_server_mech_def mech_winbind_spnego = {
-       .mech_name = "GSS-SPNEGO",
+       .name = "GSS-SPNEGO",
 
        .flags = SASL_MECH_SEC_ALLOW_NULS,
        .passdb_need = SASL_MECH_PASSDB_NEED_NOTHING,
index 275f5e9bc3c573aa605bb4cb26bf16f7f77d834e..35fe5b30bf33f35ac9283d99625bd3ad86103dea 100644 (file)
@@ -23,7 +23,7 @@ struct sasl_server_mech_funcs {
 };
 
 struct sasl_server_mech_def {
-       const char *mech_name;
+       const char *name;
 
        enum sasl_mech_security_flags flags;
        enum sasl_mech_passdb_need passdb_need;
index 1081596a5411e62a7b68e4a99987b0a8696c2e55..f91d4888c9da3038247117afec38e8fcb938cd13 100644 (file)
@@ -50,7 +50,7 @@ void sasl_server_request_create(struct sasl_server_req_ctx *rctx,
 
        req->mech = mreq;
        rctx->mech = mech;
-       rctx->mech_name = mech->mech_name;
+       rctx->mech_name = mech->name;
        rctx->request = req;
 }
 
index 495d11262337f7ad0216432eec83f0ed264ff854..9bab54e470e544470670702147c50d915c081054 100644 (file)
@@ -293,7 +293,7 @@ static void test_mechs(void)
                const struct sasl_server_mech_def *mech = test_case->mech;
                struct auth_request *request;
                const char *testname = t_strdup_printf("auth mech %s %d/%zu",
-                                                      mech->mech_name,
+                                                      mech->name,
                                                       running_test+1,
                                                       N_ELEMENTS(tests));
                test_begin(testname);