]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: sasl-server - Rename struct mech_module to struct struct sasl_server_mech_def
authorStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 6 Mar 2023 22:32:58 +0000 (23:32 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 9 Oct 2025 08:41:22 +0000 (08:41 +0000)
21 files changed:
src/auth/auth-request-handler.c
src/auth/auth-request.c
src/auth/auth-request.h
src/auth/auth-sasl-mech-apop.c
src/auth/auth-sasl-mech-dovecot-token.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/test-auth-request-fields.c
src/auth/test-mech.c

index 241a5eef658ef2a389f3047e8e5bc4626a105593..da7a67ad786790b518233a5a0a1a7cef6bf9f3b8 100644 (file)
@@ -569,7 +569,7 @@ auth_penalty_callback(unsigned int penalty, struct auth_request *request)
 int auth_request_handler_auth_begin(struct auth_request_handler *handler,
                                    const char *const *args)
 {
-       const struct mech_module *mech;
+       const struct sasl_server_mech_def *mech;
        struct auth_request *request;
        const char *name, *arg, *initial_resp;
        void *initial_resp_data;
index 68926c6285da13827415ee5e0173ba1c08b0fba9..416dfa1602d8b49b80e7ceb85c63b59cd3e34340 100644 (file)
@@ -150,7 +150,8 @@ auth_request_post_alloc_init(struct auth_request *request,
 }
 
 struct auth_request *
-auth_request_new(const struct mech_module *mech, struct event *parent_event)
+auth_request_new(const struct sasl_server_mech_def *mech,
+                struct event *parent_event)
 {
        struct auth_request *request;
 
@@ -553,7 +554,7 @@ auth_request_save_cache(struct auth_request *request,
 
 static bool
 auth_request_mechanism_accepted(const char *const *mechs,
-                               const struct mech_module *mech)
+                               const struct sasl_server_mech_def *mech)
 {
        /* no filter specified, anything goes */
        if (mechs == NULL) return TRUE;
index f3ce45309cd74b55ab60a9d4d405e05a0b3bad98..9bc5b9d0bd6f53fef4845efb6aa6d8b4bd818430 100644 (file)
@@ -135,7 +135,7 @@ struct auth_request {
           proxy DNS lookups) */
        enum passdb_result passdb_result;
 
-       const struct mech_module *mech;
+       const struct sasl_server_mech_def *mech;
        /* Protocol-specific settings */
        const struct auth_settings *protocol_set;
        /* Currently active settings. May be the same as protocol_set, but
@@ -253,7 +253,8 @@ typedef void auth_request_proxy_cb_t(bool success, struct auth_request *);
 extern unsigned int auth_request_state_count[AUTH_REQUEST_STATE_MAX];
 
 struct auth_request *
-auth_request_new(const struct mech_module *mech, struct event *parent_event);
+auth_request_new(const struct sasl_server_mech_def *mech,
+                struct event *parent_event);
 struct auth_request *auth_request_new_dummy(struct event *parent_event);
 void auth_request_init(struct auth_request *request);
 struct auth *auth_request_get_auth(struct auth_request *request);
index 78c512285b4c590ca185e591af6aab3317f7ddb8..c00d3777a8b8a669098f9c47dfa998cb38a9cf3a 100644 (file)
@@ -157,7 +157,7 @@ static struct auth_request *mech_apop_auth_new(void)
        return &request->auth_request;
 }
 
-const struct mech_module mech_apop = {
+const struct sasl_server_mech_def mech_apop = {
        .mech_name = "APOP",
 
        .flags = SASL_MECH_SEC_PRIVATE | SASL_MECH_SEC_DICTIONARY |
index e64514b3f97ba589fc99b8758fd1e35309b055f4..2eae84fe31c52f731b528f69f5b8bba9e92396de 100644 (file)
@@ -79,7 +79,7 @@ static struct auth_request *mech_dovecot_token_auth_new(void)
        return request;
 }
 
-const struct mech_module mech_dovecot_token = {
+const struct sasl_server_mech_def mech_dovecot_token = {
        .mech_name = "DOVECOT-TOKEN",
 
        .flags = SASL_MECH_SEC_PRIVATE | SASL_MECH_SEC_ALLOW_NULS,
index 24b7a488e8cf9fb33700237f445c908a40362dd0..27b3307a3e46083476ec51c8a5640f126fb778ff 100644 (file)
@@ -241,7 +241,8 @@ static bool auth_passdb_list_have_set_credentials(const struct auth *auth)
 }
 
 static bool
-auth_mech_verify_passdb(const struct auth *auth, const struct mech_module *mech)
+auth_mech_verify_passdb(const struct auth *auth,
+                       const struct sasl_server_mech_def *mech)
 {
        switch (mech->passdb_need) {
        case SASL_MECH_PASSDB_NEED_NOTHING:
index f7195180b6fd95f24bdfdd42e19c81207a45e5f7..5bc37cf81cd9f319dda1afbbed193d1b070a9ca5 100644 (file)
@@ -12,7 +12,7 @@
 
 static struct mech_module_list *mech_modules;
 
-void mech_register_module(const struct mech_module *module)
+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);
@@ -24,7 +24,7 @@ void mech_register_module(const struct mech_module *module)
        mech_modules = list;
 }
 
-void mech_unregister_module(const struct mech_module *module)
+void mech_unregister_module(const struct sasl_server_mech_def *module)
 {
        struct mech_module_list **pos, *list;
 
@@ -38,7 +38,7 @@ void mech_unregister_module(const struct mech_module *module)
        }
 }
 
-const struct mech_module *mech_module_find(const char *name)
+const struct sasl_server_mech_def *mech_module_find(const char *name)
 {
        struct mech_module_list *list;
        name = t_str_ucase(name);
@@ -50,31 +50,31 @@ const struct mech_module *mech_module_find(const char *name)
        return NULL;
 }
 
-extern const struct mech_module mech_plain;
-extern const struct mech_module mech_login;
-extern const struct mech_module mech_apop;
-extern const struct mech_module mech_cram_md5;
-extern const struct mech_module mech_digest_md5;
-extern const struct mech_module mech_external;
-extern const struct mech_module mech_otp;
-extern const struct mech_module mech_scram_sha1;
-extern const struct mech_module mech_scram_sha1_plus;
-extern const struct mech_module mech_scram_sha256;
-extern const struct mech_module mech_scram_sha256_plus;
-extern const struct mech_module mech_anonymous;
+extern const struct sasl_server_mech_def mech_plain;
+extern const struct sasl_server_mech_def mech_login;
+extern const struct sasl_server_mech_def mech_apop;
+extern const struct sasl_server_mech_def mech_cram_md5;
+extern const struct sasl_server_mech_def mech_digest_md5;
+extern const struct sasl_server_mech_def mech_external;
+extern const struct sasl_server_mech_def mech_otp;
+extern const struct sasl_server_mech_def mech_scram_sha1;
+extern const struct sasl_server_mech_def mech_scram_sha1_plus;
+extern const struct sasl_server_mech_def mech_scram_sha256;
+extern const struct sasl_server_mech_def mech_scram_sha256_plus;
+extern const struct sasl_server_mech_def mech_anonymous;
 #ifdef HAVE_GSSAPI
-extern const struct mech_module mech_gssapi;
+extern const struct sasl_server_mech_def mech_gssapi;
 #endif
 #ifdef HAVE_GSSAPI_SPNEGO
-extern const struct mech_module mech_gssapi_spnego;
+extern const struct sasl_server_mech_def mech_gssapi_spnego;
 #endif
-extern const struct mech_module mech_winbind_ntlm;
-extern const struct mech_module mech_winbind_spnego;
-extern const struct mech_module mech_oauthbearer;
-extern const struct mech_module mech_xoauth2;
+extern const struct sasl_server_mech_def mech_winbind_ntlm;
+extern const struct sasl_server_mech_def mech_winbind_spnego;
+extern const struct sasl_server_mech_def mech_oauthbearer;
+extern const struct sasl_server_mech_def mech_xoauth2;
 
 static void mech_register_add(struct mechanisms_register *reg,
-                             const struct mech_module *mech)
+                             const struct sasl_server_mech_def *mech)
 {
        struct mech_module_list *list;
        string_t *handshake;
@@ -128,7 +128,7 @@ struct mechanisms_register *
 mech_register_init(const struct auth_settings *set)
 {
        struct mechanisms_register *reg;
-       const struct mech_module *mech;
+       const struct sasl_server_mech_def *mech;
        const char *name;
        pool_t pool;
 
@@ -173,7 +173,7 @@ void mech_register_deinit(struct mechanisms_register **_reg)
        pool_unref(&reg->pool);
 }
 
-const struct mech_module *
+const struct sasl_server_mech_def *
 mech_register_find(const struct mechanisms_register *reg, const char *name)
 {
        const struct mech_module_list *list;
index cc66f869b865dd1f52332ced00bdfbff1301ee08..50d674633dec5ee11621cb79664c7f4dddae7b44 100644 (file)
@@ -32,7 +32,7 @@ static struct auth_request *mech_anonymous_auth_new(void)
        return request;
 }
 
-const struct mech_module mech_anonymous = {
+const struct sasl_server_mech_def mech_anonymous = {
        .mech_name = "ANONYMOUS",
 
        .flags = SASL_MECH_SEC_ANONYMOUS | SASL_MECH_SEC_ALLOW_NULS,
index 593bcaff5b64862e2c91c9b443b76b6b0ddda23d..836743619378efb155971c3d44221affd6c0569a 100644 (file)
@@ -176,7 +176,7 @@ static struct auth_request *mech_cram_md5_auth_new(void)
        return &request->auth_request;
 }
 
-const struct mech_module mech_cram_md5 = {
+const struct sasl_server_mech_def mech_cram_md5 = {
        .mech_name = "CRAM-MD5",
 
        .flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE,
index dd41de4c8a3d7895de22fc3adbd7a5d662cff617..815311a3ebae1fa6945cf84b12ca1ecc13aec754 100644 (file)
@@ -608,7 +608,7 @@ static struct auth_request *mech_digest_md5_auth_new(void)
        return &request->auth_request;
 }
 
-const struct mech_module mech_digest_md5 = {
+const struct sasl_server_mech_def mech_digest_md5 = {
        .mech_name = "DIGEST-MD5",
 
        .flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
index 9f8c4081ec6672e877d22b45c97f317c4653a50e..4b1ba21c3ea4904188b67fe9e27a5fe03a6be170 100644 (file)
@@ -39,7 +39,7 @@ static struct auth_request *mech_external_auth_new(void)
        return request;
 }
 
-const struct mech_module mech_external = {
+const struct sasl_server_mech_def mech_external = {
        .mech_name = "EXTERNAL",
 
        .flags = 0,
index fa27a162635a3b590ffdcff9ba128b6efbf52415..913f97fffe8d4f6cf2528397985fc8e1e37110df 100644 (file)
@@ -689,7 +689,7 @@ mech_gssapi_auth_free(struct auth_request *auth_request)
        pool_unref(&auth_request->pool);
 }
 
-const struct mech_module mech_gssapi = {
+const struct sasl_server_mech_def mech_gssapi = {
        .mech_name = "GSSAPI",
 
        .flags = SASL_MECH_SEC_ALLOW_NULS,
@@ -704,7 +704,7 @@ const struct mech_module mech_gssapi = {
 /* MIT Kerberos v1.5+ and Heimdal v0.7+ support SPNEGO for Kerberos tickets
    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 mech_module mech_gssapi_spnego = {
+const struct sasl_server_mech_def mech_gssapi_spnego = {
        .mech_name = "GSS-SPNEGO",
 
        .flags = SASL_MECH_SEC_ALLOW_NULS,
@@ -748,7 +748,7 @@ void mech_gssapi_init(void)
 void mech_gssapi_deinit(void)
 {
 #ifdef HAVE_GSSAPI_SPNEGO
-       const struct mech_module *mech;
+       const struct sasl_server_mech_def *mech;
 
        mech = mech_module_find(mech_gssapi_spnego.mech_name);
        if (mech != NULL && mech->auth_new == mech_gssapi_auth_new)
index bf52b9151d542191b8de63e0978e379839eda129..13bdfb579e15c35d756de9ce2417c1f2c0c76def 100644 (file)
@@ -62,7 +62,7 @@ static struct auth_request *mech_login_auth_new(void)
        return request;
 }
 
-const struct mech_module mech_login = {
+const struct sasl_server_mech_def mech_login = {
        .mech_name = "LOGIN",
 
        .flags = SASL_MECH_SEC_PLAINTEXT,
index d4a9186433e9b5ef694f5f6f5546b8a56800c6b1..f8548abf81093ba4263fbd5f8bece71172e66b1c 100644 (file)
@@ -24,8 +24,8 @@ struct oauth2_auth_request {
        bool verifying_token:1;
 };
 
-const struct mech_module mech_oauthbearer;
-const struct mech_module mech_xoauth2;
+const struct sasl_server_mech_def mech_oauthbearer;
+const struct sasl_server_mech_def mech_xoauth2;
 
 static struct db_oauth2 *db_oauth2 = NULL;
 
@@ -309,7 +309,7 @@ static struct auth_request *mech_oauth2_auth_new(void)
        return &request->request;
 }
 
-const struct mech_module mech_oauthbearer = {
+const struct sasl_server_mech_def mech_oauthbearer = {
        .mech_name = "OAUTHBEARER",
 
        /* while this does not transfer plaintext password,
@@ -323,7 +323,7 @@ const struct mech_module mech_oauthbearer = {
        .auth_free = sasl_server_mech_generic_auth_free,
 };
 
-const struct mech_module mech_xoauth2 = {
+const struct sasl_server_mech_def mech_xoauth2 = {
        .mech_name = "XOAUTH2",
 
        .flags = SASL_MECH_SEC_PLAINTEXT,
index a1eca5716dd78f7fa863277eb9724149804e51b0..26f900a52b5d3704a8cfd8c58164fce4c2336409 100644 (file)
@@ -317,7 +317,7 @@ static void mech_otp_auth_free(struct auth_request *auth_request)
  * Mechanism
  */
 
-const struct mech_module mech_otp = {
+const struct sasl_server_mech_def mech_otp = {
        .mech_name = "OTP",
 
        .flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
index 78a410100d6e4dd25e0a6cd4ee69309be1e537fb..3ce208f585302b9157221e41139caaef44073cac 100644 (file)
@@ -73,7 +73,7 @@ static struct auth_request *mech_plain_auth_new(void)
        return request;
 }
 
-const struct mech_module mech_plain = {
+const struct sasl_server_mech_def mech_plain = {
        .mech_name = "PLAIN",
 
        .flags = SASL_MECH_SEC_PLAINTEXT | SASL_MECH_SEC_ALLOW_NULS,
index 8fbce99afa930c3329c0c1ea8a05a4aa16ea965f..c7c51a83051b09d4f558c7a639c41e6f601d2e4b 100644 (file)
@@ -235,7 +235,7 @@ static void mech_scram_auth_free(struct auth_request *auth_request)
        pool_unref(&auth_request->pool);
 }
 
-const struct mech_module mech_scram_sha1 = {
+const struct sasl_server_mech_def mech_scram_sha1 = {
        .mech_name = "SCRAM-SHA-1",
 
        .flags = SASL_MECH_SEC_MUTUAL_AUTH,
@@ -247,7 +247,7 @@ const struct mech_module mech_scram_sha1 = {
        .auth_free = mech_scram_auth_free,
 };
 
-const struct mech_module mech_scram_sha1_plus = {
+const struct sasl_server_mech_def mech_scram_sha1_plus = {
        .mech_name = "SCRAM-SHA-1-PLUS",
 
        .flags = SASL_MECH_SEC_MUTUAL_AUTH | SASL_MECH_SEC_CHANNEL_BINDING,
@@ -259,7 +259,7 @@ const struct mech_module mech_scram_sha1_plus = {
        .auth_free = mech_scram_auth_free,
 };
 
-const struct mech_module mech_scram_sha256 = {
+const struct sasl_server_mech_def mech_scram_sha256 = {
        .mech_name = "SCRAM-SHA-256",
 
        .flags = SASL_MECH_SEC_MUTUAL_AUTH,
@@ -271,7 +271,7 @@ const struct mech_module mech_scram_sha256 = {
        .auth_free = mech_scram_auth_free,
 };
 
-const struct mech_module mech_scram_sha256_plus = {
+const struct sasl_server_mech_def mech_scram_sha256_plus = {
        .mech_name = "SCRAM-SHA-256-PLUS",
 
        .flags = SASL_MECH_SEC_MUTUAL_AUTH | SASL_MECH_SEC_CHANNEL_BINDING,
index c366ae8c5d37e71681911b5bcc9dbe0207619a0c..eb111d39fdf8f835640679675a868ba89dd68170 100644 (file)
@@ -339,7 +339,7 @@ static struct auth_request *mech_winbind_spnego_auth_new(void)
        return do_auth_new(&winbind_spnego_context);
 }
 
-const struct mech_module mech_winbind_ntlm = {
+const struct sasl_server_mech_def mech_winbind_ntlm = {
        .mech_name = "NTLM",
 
        .flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
@@ -352,7 +352,7 @@ const struct mech_module mech_winbind_ntlm = {
        .auth_free = sasl_server_mech_generic_auth_free,
 };
 
-const struct mech_module mech_winbind_spnego = {
+const struct sasl_server_mech_def mech_winbind_spnego = {
        .mech_name = "GSS-SPNEGO",
 
        .flags = SASL_MECH_SEC_ALLOW_NULS,
index b44c844c3d1b149c5ed4ccea785f897e7a5e6a0a..27d176f647d892347eb0e09ba47ce2a2ac18bc4e 100644 (file)
@@ -8,7 +8,7 @@
 
 struct auth_request;
 
-struct mech_module {
+struct sasl_server_mech_def {
        const char *mech_name;
 
        enum sasl_mech_security_flags flags;
@@ -25,7 +25,7 @@ struct mech_module {
 struct mech_module_list {
        struct mech_module_list *next;
 
-       const struct mech_module *module;
+       const struct sasl_server_mech_def *module;
 };
 
 struct mechanisms_register {
@@ -41,11 +41,11 @@ struct mechanisms_register {
  * Mechanism
  */
 
-extern const struct mech_module mech_dovecot_token;
+extern const struct sasl_server_mech_def mech_dovecot_token;
 
-void mech_register_module(const struct mech_module *module);
-void mech_unregister_module(const struct mech_module *module);
-const struct mech_module *mech_module_find(const char *name);
+void mech_register_module(const struct sasl_server_mech_def *module);
+void mech_unregister_module(const struct sasl_server_mech_def *module);
+const struct sasl_server_mech_def *mech_module_find(const char *name);
 
 void sasl_server_mech_generic_auth_initial(struct auth_request *request,
                                           const unsigned char *data,
@@ -55,7 +55,7 @@ void sasl_server_mech_generic_auth_free(struct auth_request *request);
 struct mechanisms_register *
 mech_register_init(const struct auth_settings *set);
 void mech_register_deinit(struct mechanisms_register **reg);
-const struct mech_module *
+const struct sasl_server_mech_def *
 mech_register_find(const struct mechanisms_register *reg, const char *name);
 
 void mech_init(const struct auth_settings *set);
index ffe8963b5d4f08c28823d5453720906d75089532..7fccb15692a7978b54d3df93ea02ff423554a7c4 100644 (file)
@@ -45,7 +45,7 @@ static const struct test_auth_request_field auth_request_field_names[] = {
 };
 
 static struct auth_request *
-test_auth_request_init(const struct mech_module *mech)
+test_auth_request_init(const struct sasl_server_mech_def *mech)
 {
        struct auth_request *request;
        pool_t pool = pool_alloconly_create("test auth request", 1024);
index 4ada6041198d9965a5fadbda77e09a0c5205b89e..351d43c249b2cb19e68e81e6751f3dedc5cb7db6 100644 (file)
 
 #define UCHAR_LEN(str) (const unsigned char *)(str), sizeof(str)-1
 
-extern const struct mech_module mech_anonymous;
-extern const struct mech_module mech_apop;
-extern const struct mech_module mech_cram_md5;
-extern const struct mech_module mech_digest_md5;
-extern const struct mech_module mech_external;
-extern const struct mech_module mech_login;
-extern const struct mech_module mech_oauthbearer;
-extern const struct mech_module mech_otp;
-extern const struct mech_module mech_plain;
-extern const struct mech_module mech_scram_sha1;
-extern const struct mech_module mech_scram_sha256;
-extern const struct mech_module mech_xoauth2;
+extern const struct sasl_server_mech_def mech_anonymous;
+extern const struct sasl_server_mech_def mech_apop;
+extern const struct sasl_server_mech_def mech_cram_md5;
+extern const struct sasl_server_mech_def mech_digest_md5;
+extern const struct sasl_server_mech_def mech_external;
+extern const struct sasl_server_mech_def mech_login;
+extern const struct sasl_server_mech_def mech_oauthbearer;
+extern const struct sasl_server_mech_def mech_otp;
+extern const struct sasl_server_mech_def mech_plain;
+extern const struct sasl_server_mech_def mech_scram_sha1;
+extern const struct sasl_server_mech_def mech_scram_sha256;
+extern const struct sasl_server_mech_def mech_xoauth2;
 
 struct test_case {
-       const struct mech_module *mech;
+       const struct sasl_server_mech_def *mech;
        const unsigned char *in;
        size_t len;
        const char *username;
@@ -83,7 +83,7 @@ auth_client_request_mock_callback(
 }
 
 static void test_mech_prepare_request(struct auth_request **request_r,
-                                     const struct mech_module *mech,
+                                     const struct sasl_server_mech_def *mech,
                                      struct auth_request_handler *handler,
                                      unsigned int running_test,
                                      const struct test_case *test_case)
@@ -284,7 +284,7 @@ static void test_mechs(void)
        for (unsigned int running_test = 0; running_test < N_ELEMENTS(tests);
             running_test++) T_BEGIN {
                struct test_case *test_case = &tests[running_test];
-               const struct mech_module *mech = test_case->mech;
+               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,