From: Stephan Bosch Date: Sun, 29 Oct 2023 23:48:09 +0000 (+0100) Subject: mech: Move mech_register_add() to auth-sasl X-Git-Tag: 2.4.2~208 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f7387611f375238d07ef3955f768fb10cbfd384c;p=thirdparty%2Fdovecot%2Fcore.git mech: Move mech_register_add() to auth-sasl --- diff --git a/src/auth/auth-sasl.c b/src/auth/auth-sasl.c index 4ac24d62b9..f26b630eec 100644 --- a/src/auth/auth-sasl.c +++ b/src/auth/auth-sasl.c @@ -1,6 +1,7 @@ /* Copyright (c) 2023 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "str.h" #include "settings-parser.h" #include "sasl-server-private.h" // FIXME: remove #include "auth.h" @@ -450,6 +451,45 @@ void auth_sasl_instance_deinit(struct auth *auth) * Global */ +void mech_register_add(struct mechanisms_register *reg, + const struct sasl_server_mech_def *mech); +void mech_register_add(struct mechanisms_register *reg, + const struct sasl_server_mech_def *mech) +{ + struct mech_module_list *list; + string_t *handshake; + + list = p_new(reg->pool, struct mech_module_list, 1); + list->module = mech; + + if ((mech->flags & SASL_MECH_SEC_CHANNEL_BINDING) != 0) + handshake = reg->handshake_cbind; + else + handshake = reg->handshake; + + 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) + str_append(handshake, "\tanonymous"); + if ((mech->flags & SASL_MECH_SEC_PLAINTEXT) != 0) + str_append(handshake, "\tplaintext"); + if ((mech->flags & SASL_MECH_SEC_DICTIONARY) != 0) + str_append(handshake, "\tdictionary"); + if ((mech->flags & SASL_MECH_SEC_ACTIVE) != 0) + str_append(handshake, "\tactive"); + if ((mech->flags & SASL_MECH_SEC_FORWARD_SECRECY) != 0) + str_append(handshake, "\tforward-secrecy"); + if ((mech->flags & SASL_MECH_SEC_MUTUAL_AUTH) != 0) + str_append(handshake, "\tmutual-auth"); + if ((mech->flags & SASL_MECH_SEC_CHANNEL_BINDING) != 0) + str_append(handshake, "\tchannel-binding"); + str_append_c(handshake, '\n'); + + list->next = reg->modules; + reg->modules = list; +} + void auth_sasl_preinit(void) { auth_sasl_oauth2_initialize(); diff --git a/src/auth/mech.c b/src/auth/mech.c index a40dff8b73..95be325270 100644 --- a/src/auth/mech.c +++ b/src/auth/mech.c @@ -75,42 +75,6 @@ extern const struct sasl_server_mech_def mech_xoauth2; void mech_register_add(struct mechanisms_register *reg, const struct sasl_server_mech_def *mech); -void mech_register_add(struct mechanisms_register *reg, - const struct sasl_server_mech_def *mech) -{ - struct mech_module_list *list; - string_t *handshake; - - list = p_new(reg->pool, struct mech_module_list, 1); - list->module = mech; - - if ((mech->flags & SASL_MECH_SEC_CHANNEL_BINDING) != 0) - handshake = reg->handshake_cbind; - else - handshake = reg->handshake; - - 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) - str_append(handshake, "\tanonymous"); - if ((mech->flags & SASL_MECH_SEC_PLAINTEXT) != 0) - str_append(handshake, "\tplaintext"); - if ((mech->flags & SASL_MECH_SEC_DICTIONARY) != 0) - str_append(handshake, "\tdictionary"); - if ((mech->flags & SASL_MECH_SEC_ACTIVE) != 0) - str_append(handshake, "\tactive"); - if ((mech->flags & SASL_MECH_SEC_FORWARD_SECRECY) != 0) - str_append(handshake, "\tforward-secrecy"); - if ((mech->flags & SASL_MECH_SEC_MUTUAL_AUTH) != 0) - str_append(handshake, "\tmutual-auth"); - if ((mech->flags & SASL_MECH_SEC_CHANNEL_BINDING) != 0) - str_append(handshake, "\tchannel-binding"); - str_append_c(handshake, '\n'); - - list->next = reg->modules; - reg->modules = list; -} const char *mech_get_plugin_name(const char *name); const char *mech_get_plugin_name(const char *name)