From: Stephan Bosch Date: Sun, 26 Mar 2023 17:33:40 +0000 (+0200) Subject: auth: sasl-server - Rename mech_name field to name in struct sasl_server_mech_def X-Git-Tag: 2.4.2~223 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd2fcdedf73860df194dbca316ca75ebcbfcce5e;p=thirdparty%2Fdovecot%2Fcore.git auth: sasl-server - Rename mech_name field to name in struct sasl_server_mech_def --- diff --git a/src/auth/auth-client-connection.c b/src/auth/auth-client-connection.c index 48a1a6dfde..28de892951 100644 --- a/src/auth/auth-client-connection.c +++ b/src/auth/auth-client-connection.c @@ -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) { diff --git a/src/auth/auth-request-fields.c b/src/auth/auth-request-fields.c index e332e0349d..c86b3f7c87 100644 --- a/src/auth/auth-request-fields.c +++ b/src/auth/auth-request-fields.c @@ -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); } } diff --git a/src/auth/auth-request-handler.c b/src/auth/auth-request-handler.c index 90c3a56d12..0a2f5c1e0b 100644 --- a/src/auth/auth-request-handler.c +++ b/src/auth/auth-request-handler.c @@ -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 diff --git a/src/auth/auth-request.c b/src/auth/auth-request.c index 3bc0f555e9..d955868b03 100644 --- a/src/auth/auth-request.c +++ b/src/auth/auth-request.c @@ -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); } /** diff --git a/src/auth/auth-sasl-mech-apop.c b/src/auth/auth-sasl-mech-apop.c index ae200ce745..95b954b715 100644 --- a/src/auth/auth-sasl-mech-apop.c +++ b/src/auth/auth-sasl-mech-apop.c @@ -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, diff --git a/src/auth/auth-sasl-mech-dovecot-token.c b/src/auth/auth-sasl-mech-dovecot-token.c index e1b2453d72..365f7be308 100644 --- a/src/auth/auth-sasl-mech-dovecot-token.c +++ b/src/auth/auth-sasl-mech-dovecot-token.c @@ -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, diff --git a/src/auth/auth-sasl-mech-oauth2.c b/src/auth/auth-sasl-mech-oauth2.c index 8c2d5a30ed..e9b81055f8 100644 --- a/src/auth/auth-sasl-mech-oauth2.c +++ b/src/auth/auth-sasl-mech-oauth2.c @@ -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); diff --git a/src/auth/auth.c b/src/auth/auth.c index 813183f08f..b18e7709a4 100644 --- a/src/auth/auth.c +++ b/src/auth/auth.c @@ -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); } } diff --git a/src/auth/mech.c b/src/auth/mech.c index 8668c818de..4bbc17e60f 100644 --- a/src/auth/mech.c +++ b/src/auth/mech.c @@ -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; diff --git a/src/auth/sasl-server-mech-anonymous.c b/src/auth/sasl-server-mech-anonymous.c index d0dd09c3ad..60a1825d1e 100644 --- a/src/auth/sasl-server-mech-anonymous.c +++ b/src/auth/sasl-server-mech-anonymous.c @@ -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, diff --git a/src/auth/sasl-server-mech-cram-md5.c b/src/auth/sasl-server-mech-cram-md5.c index b841c20ecf..ee71c273aa 100644 --- a/src/auth/sasl-server-mech-cram-md5.c +++ b/src/auth/sasl-server-mech-cram-md5.c @@ -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, diff --git a/src/auth/sasl-server-mech-digest-md5.c b/src/auth/sasl-server-mech-digest-md5.c index c5e9cadc72..ef6b24ec7a 100644 --- a/src/auth/sasl-server-mech-digest-md5.c +++ b/src/auth/sasl-server-mech-digest-md5.c @@ -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, diff --git a/src/auth/sasl-server-mech-external.c b/src/auth/sasl-server-mech-external.c index 2a65b0e198..2a7ac27154 100644 --- a/src/auth/sasl-server-mech-external.c +++ b/src/auth/sasl-server-mech-external.c @@ -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, diff --git a/src/auth/sasl-server-mech-gssapi.c b/src/auth/sasl-server-mech-gssapi.c index dbcb82c8d0..d15cf08456 100644 --- a/src/auth/sasl-server-mech-gssapi.c +++ b/src/auth/sasl-server-mech-gssapi.c @@ -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 diff --git a/src/auth/sasl-server-mech-login.c b/src/auth/sasl-server-mech-login.c index bf7892a5b0..58fb246c0f 100644 --- a/src/auth/sasl-server-mech-login.c +++ b/src/auth/sasl-server-mech-login.c @@ -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, diff --git a/src/auth/sasl-server-mech-oauth2.c b/src/auth/sasl-server-mech-oauth2.c index e8988b0884..2213f2ee9c 100644 --- a/src/auth/sasl-server-mech-oauth2.c +++ b/src/auth/sasl-server-mech-oauth2.c @@ -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, diff --git a/src/auth/sasl-server-mech-otp.c b/src/auth/sasl-server-mech-otp.c index 6ff2cfadf9..182ac21295 100644 --- a/src/auth/sasl-server-mech-otp.c +++ b/src/auth/sasl-server-mech-otp.c @@ -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, diff --git a/src/auth/sasl-server-mech-plain.c b/src/auth/sasl-server-mech-plain.c index 86c3ef8154..ecee61e251 100644 --- a/src/auth/sasl-server-mech-plain.c +++ b/src/auth/sasl-server-mech-plain.c @@ -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, diff --git a/src/auth/sasl-server-mech-scram.c b/src/auth/sasl-server-mech-scram.c index 5ce483cffb..a94fc0702d 100644 --- a/src/auth/sasl-server-mech-scram.c +++ b/src/auth/sasl-server-mech-scram.c @@ -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, diff --git a/src/auth/sasl-server-mech-winbind.c b/src/auth/sasl-server-mech-winbind.c index 2ed40d28c5..509cb88736 100644 --- a/src/auth/sasl-server-mech-winbind.c +++ b/src/auth/sasl-server-mech-winbind.c @@ -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, diff --git a/src/auth/sasl-server-protected.h b/src/auth/sasl-server-protected.h index 275f5e9bc3..35fe5b30bf 100644 --- a/src/auth/sasl-server-protected.h +++ b/src/auth/sasl-server-protected.h @@ -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; diff --git a/src/auth/sasl-server-request.c b/src/auth/sasl-server-request.c index 1081596a54..f91d4888c9 100644 --- a/src/auth/sasl-server-request.c +++ b/src/auth/sasl-server-request.c @@ -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; } diff --git a/src/auth/test-mech.c b/src/auth/test-mech.c index 495d112623..9bab54e470 100644 --- a/src/auth/test-mech.c +++ b/src/auth/test-mech.c @@ -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);