From: Stephan Bosch Date: Thu, 5 Oct 2023 16:56:09 +0000 (+0200) Subject: auth: mech-dovecot-token - Create and use definition for mechanism name X-Git-Tag: 2.4.2~201 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e60e938ff69f18aeafaa0f66261f9cb2eacd6eb5;p=thirdparty%2Fdovecot%2Fcore.git auth: mech-dovecot-token - Create and use definition for mechanism name --- diff --git a/src/auth/auth-client-connection.c b/src/auth/auth-client-connection.c index cbc4339274..e4c03a4662 100644 --- a/src/auth/auth-client-connection.c +++ b/src/auth/auth-client-connection.c @@ -10,7 +10,6 @@ #include "str-sanitize.h" #include "randgen.h" #include "master-service.h" -#include "sasl-server-protected.h" // FIXME: remove #include "auth-sasl.h" #include "auth-request-handler.h" #include "auth-client-interface.h" @@ -193,8 +192,8 @@ static void auth_client_finish_handshake(struct auth_client_connection *conn) return; if (conn->token_auth) { - mechanisms = t_strconcat("MECH\t", - mech_dovecot_token.name, "\tprivate\n", NULL); + mechanisms = "MECH\t" + AUTH_SASL_MECH_NAME_DOVECOT_TOKEN "\tprivate\n"; } else { mechanisms = auth_sasl_mechs_get_handshake(); if (conn->conn.minor_version >= AUTH_CLIENT_MINOR_VERSION_CHANNEL_BINDING) diff --git a/src/auth/auth-sasl-mech-dovecot-token.c b/src/auth/auth-sasl-mech-dovecot-token.c index 365f7be308..d9baf47718 100644 --- a/src/auth/auth-sasl-mech-dovecot-token.c +++ b/src/auth/auth-sasl-mech-dovecot-token.c @@ -6,6 +6,7 @@ #include "auth-common.h" #include "safe-memset.h" #include "sasl-server-protected.h" +#include "auth-sasl.h" #include "auth-token.h" static void @@ -74,7 +75,7 @@ static const struct sasl_server_mech_funcs mech_dovecot_token_funcs = { }; const struct sasl_server_mech_def mech_dovecot_token = { - .name = "DOVECOT-TOKEN", + .name = AUTH_SASL_MECH_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/test-mech.c b/src/auth/test-mech.c index 39648deea5..ca3f563a72 100644 --- a/src/auth/test-mech.c +++ b/src/auth/test-mech.c @@ -108,7 +108,7 @@ static void test_mech_prepare_request(struct auth_request **request_r, struct auth *auth = auth_default_protocol(); const struct sasl_server_mech *mech; - if (strcmp(mech_name, "DOVECOT-TOKEN") == 0) + if (strcmp(mech_name, AUTH_SASL_MECH_NAME_DOVECOT_TOKEN) == 0) mech = auth->sasl_mech_dovecot_token; else mech = sasl_server_mech_find(auth->sasl_inst, mech_name); diff --git a/src/imap-urlauth-login/imap-urlauth-login.c b/src/imap-urlauth-login/imap-urlauth-login.c index 23a76f6c81..31648034cb 100644 --- a/src/imap-urlauth-login/imap-urlauth-login.c +++ b/src/imap-urlauth-login/imap-urlauth-login.c @@ -108,8 +108,8 @@ static void imap_urlauth_client_handle_input(struct client *client) base64_encode(str_data(auth_data), str_len(auth_data), init_resp); - (void)client_auth_begin_private(client, "DOVECOT-TOKEN", - str_c(init_resp)); + (void)client_auth_begin_private(client, + AUTH_SASL_MECH_NAME_DOVECOT_TOKEN, str_c(init_resp)); } T_END; } diff --git a/src/lib-auth-client/auth-sasl-common.h b/src/lib-auth-client/auth-sasl-common.h index 3786a10a57..565d2bfc33 100644 --- a/src/lib-auth-client/auth-sasl-common.h +++ b/src/lib-auth-client/auth-sasl-common.h @@ -4,5 +4,6 @@ #include "sasl-common.h" #define AUTH_SASL_MECH_NAME_APOP "APOP" +#define AUTH_SASL_MECH_NAME_DOVECOT_TOKEN "DOVECOT-TOKEN" #endif