]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mech: Move mech_register_add() to auth-sasl
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sun, 29 Oct 2023 23:48:09 +0000 (00:48 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 9 Oct 2025 08:41:22 +0000 (08:41 +0000)
src/auth/auth-sasl.c
src/auth/mech.c

index 4ac24d62b92dfb147c92ff5b0a3d71271342fd90..f26b630eece23e88d30961bb86c618aa7a048f2b 100644 (file)
@@ -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();
index a40dff8b738a753d3883f1317271c18a52c0d251..95be325270e88d1575c78061a25d3fbad57aa1fc 100644 (file)
@@ -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)