From: Stephan Bosch Date: Mon, 6 Mar 2023 22:32:58 +0000 (+0100) Subject: auth: sasl-server - Rename struct mech_module to struct struct sasl_server_mech_def X-Git-Tag: 2.4.2~256 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d63ac78bd30c6298e536d3195c225d306e2adf5;p=thirdparty%2Fdovecot%2Fcore.git auth: sasl-server - Rename struct mech_module to struct struct sasl_server_mech_def --- diff --git a/src/auth/auth-request-handler.c b/src/auth/auth-request-handler.c index 241a5eef65..da7a67ad78 100644 --- a/src/auth/auth-request-handler.c +++ b/src/auth/auth-request-handler.c @@ -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; diff --git a/src/auth/auth-request.c b/src/auth/auth-request.c index 68926c6285..416dfa1602 100644 --- a/src/auth/auth-request.c +++ b/src/auth/auth-request.c @@ -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; diff --git a/src/auth/auth-request.h b/src/auth/auth-request.h index f3ce45309c..9bc5b9d0bd 100644 --- a/src/auth/auth-request.h +++ b/src/auth/auth-request.h @@ -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); diff --git a/src/auth/auth-sasl-mech-apop.c b/src/auth/auth-sasl-mech-apop.c index 78c512285b..c00d3777a8 100644 --- a/src/auth/auth-sasl-mech-apop.c +++ b/src/auth/auth-sasl-mech-apop.c @@ -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 | diff --git a/src/auth/auth-sasl-mech-dovecot-token.c b/src/auth/auth-sasl-mech-dovecot-token.c index e64514b3f9..2eae84fe31 100644 --- a/src/auth/auth-sasl-mech-dovecot-token.c +++ b/src/auth/auth-sasl-mech-dovecot-token.c @@ -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, diff --git a/src/auth/auth.c b/src/auth/auth.c index 24b7a488e8..27b3307a3e 100644 --- a/src/auth/auth.c +++ b/src/auth/auth.c @@ -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: diff --git a/src/auth/mech.c b/src/auth/mech.c index f7195180b6..5bc37cf81c 100644 --- a/src/auth/mech.c +++ b/src/auth/mech.c @@ -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(®->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; diff --git a/src/auth/sasl-server-mech-anonymous.c b/src/auth/sasl-server-mech-anonymous.c index cc66f869b8..50d674633d 100644 --- a/src/auth/sasl-server-mech-anonymous.c +++ b/src/auth/sasl-server-mech-anonymous.c @@ -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, diff --git a/src/auth/sasl-server-mech-cram-md5.c b/src/auth/sasl-server-mech-cram-md5.c index 593bcaff5b..8367436193 100644 --- a/src/auth/sasl-server-mech-cram-md5.c +++ b/src/auth/sasl-server-mech-cram-md5.c @@ -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, diff --git a/src/auth/sasl-server-mech-digest-md5.c b/src/auth/sasl-server-mech-digest-md5.c index dd41de4c8a..815311a3eb 100644 --- a/src/auth/sasl-server-mech-digest-md5.c +++ b/src/auth/sasl-server-mech-digest-md5.c @@ -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 | diff --git a/src/auth/sasl-server-mech-external.c b/src/auth/sasl-server-mech-external.c index 9f8c4081ec..4b1ba21c3e 100644 --- a/src/auth/sasl-server-mech-external.c +++ b/src/auth/sasl-server-mech-external.c @@ -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, diff --git a/src/auth/sasl-server-mech-gssapi.c b/src/auth/sasl-server-mech-gssapi.c index fa27a16263..913f97fffe 100644 --- a/src/auth/sasl-server-mech-gssapi.c +++ b/src/auth/sasl-server-mech-gssapi.c @@ -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) diff --git a/src/auth/sasl-server-mech-login.c b/src/auth/sasl-server-mech-login.c index bf52b9151d..13bdfb579e 100644 --- a/src/auth/sasl-server-mech-login.c +++ b/src/auth/sasl-server-mech-login.c @@ -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, diff --git a/src/auth/sasl-server-mech-oauth2.c b/src/auth/sasl-server-mech-oauth2.c index d4a9186433..f8548abf81 100644 --- a/src/auth/sasl-server-mech-oauth2.c +++ b/src/auth/sasl-server-mech-oauth2.c @@ -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, diff --git a/src/auth/sasl-server-mech-otp.c b/src/auth/sasl-server-mech-otp.c index a1eca5716d..26f900a52b 100644 --- a/src/auth/sasl-server-mech-otp.c +++ b/src/auth/sasl-server-mech-otp.c @@ -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 | diff --git a/src/auth/sasl-server-mech-plain.c b/src/auth/sasl-server-mech-plain.c index 78a410100d..3ce208f585 100644 --- a/src/auth/sasl-server-mech-plain.c +++ b/src/auth/sasl-server-mech-plain.c @@ -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, diff --git a/src/auth/sasl-server-mech-scram.c b/src/auth/sasl-server-mech-scram.c index 8fbce99afa..c7c51a8305 100644 --- a/src/auth/sasl-server-mech-scram.c +++ b/src/auth/sasl-server-mech-scram.c @@ -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, diff --git a/src/auth/sasl-server-mech-winbind.c b/src/auth/sasl-server-mech-winbind.c index c366ae8c5d..eb111d39fd 100644 --- a/src/auth/sasl-server-mech-winbind.c +++ b/src/auth/sasl-server-mech-winbind.c @@ -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, diff --git a/src/auth/sasl-server-protected.h b/src/auth/sasl-server-protected.h index b44c844c3d..27d176f647 100644 --- a/src/auth/sasl-server-protected.h +++ b/src/auth/sasl-server-protected.h @@ -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); diff --git a/src/auth/test-auth-request-fields.c b/src/auth/test-auth-request-fields.c index ffe8963b5d..7fccb15692 100644 --- a/src/auth/test-auth-request-fields.c +++ b/src/auth/test-auth-request-fields.c @@ -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); diff --git a/src/auth/test-mech.c b/src/auth/test-mech.c index 4ada604119..351d43c249 100644 --- a/src/auth/test-mech.c +++ b/src/auth/test-mech.c @@ -17,21 +17,21 @@ #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,