]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: mech-apop - Create and use definition for mechanism name
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 3 Sep 2025 17:13:48 +0000 (19:13 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 9 Oct 2025 08:41:22 +0000 (08:41 +0000)
src/auth/auth-sasl-mech-apop.c
src/auth/auth-sasl.h
src/lib-auth-client/Makefile.am
src/lib-auth-client/auth-client-interface.h
src/lib-auth-client/auth-sasl-common.h [new file with mode: 0644]
src/pop3-login/client-authenticate.c
src/pop3-login/client.c

index 95b954b71569185f9d870dfaf082b585af2a5b77..62a8a209091081f0a158b81691bf88a6e61c90c9 100644 (file)
@@ -11,6 +11,7 @@
 #include "md5.h"
 #include "buffer.h"
 #include "sasl-server-protected.h"
+#include "auth-sasl.h"
 #include "auth-client-connection.h"
 #include "auth-master-connection.h"
 
@@ -160,7 +161,7 @@ static const struct sasl_server_mech_funcs mech_apop_funcs = {
 };
 
 const struct sasl_server_mech_def mech_apop = {
-       .name = "APOP",
+       .name = AUTH_SASL_MECH_NAME_APOP,
 
        .flags = SASL_MECH_SEC_PRIVATE | SASL_MECH_SEC_DICTIONARY |
                 SASL_MECH_SEC_ACTIVE | SASL_MECH_SEC_ALLOW_NULS,
index 852c54b90b720c219d903503e9d14a6c9c02a463..f99c983199331c7f9c3ab23eba6058d5ac98efd9 100644 (file)
@@ -2,6 +2,7 @@
 #define AUTH_SASL_H
 
 #include "sasl-server.h"
+#include "auth-sasl-common.h"
 
 /* Used only for string sanitization. */
 #define AUTH_SASL_MAX_MECH_NAME_LEN 64
index afb77b8cbe05e701ba6096d69be3425831e07bc6..177b0b623f1bc8e2020f35e446797debf141b82b 100644 (file)
@@ -17,6 +17,7 @@ libauth_client_la_SOURCES = \
        auth-proxy.c
 
 headers = \
+       auth-sasl-common.h \
        auth-client.h \
        auth-client-interface.h \
        auth-client-private.h \
index 1554409c4a7156162942549153f810d9feea35d1..f4dce1db843947c3df798c1585413e27bbcddce0 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef AUTH_CLIENT_INTERFACE_H
 #define AUTH_CLIENT_INTERFACE_H
 
-#include "sasl-common.h"
+#include "auth-sasl-common.h"
 
 /* Major version changes are not backwards compatible,
    minor version numbers can be ignored. */
diff --git a/src/lib-auth-client/auth-sasl-common.h b/src/lib-auth-client/auth-sasl-common.h
new file mode 100644 (file)
index 0000000..3786a10
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef AUTH_SASL_COMMON_H
+#define AUTH_SASL_COMMON_H
+
+#include "sasl-common.h"
+
+#define AUTH_SASL_MECH_NAME_APOP               "APOP"
+
+#endif
index 1198cc63df2de93e1722fee9b35a21cc92fbf767..742405a3d5208abd88c12570a5c02f6bcd3d056d 100644 (file)
@@ -272,6 +272,7 @@ bool cmd_apop(struct pop3_client *pop3_client, const char *args)
                return TRUE;
        }
 
-       (void)client_auth_begin_private(client, "APOP", str_c(base64));
+       (void)client_auth_begin_private(client, AUTH_SASL_MECH_NAME_APOP,
+                                       str_c(base64));
        return TRUE;
 }
index f74c27da30d0bb2565cfbf9ef54869df1e621154..020f398ede8f88232a683629ce60babe931674c4 100644 (file)
@@ -232,7 +232,8 @@ static char *get_apop_challenge(struct pop3_client *client)
        unsigned char buffer_base64[MAX_BASE64_ENCODED_SIZE(sizeof(buffer)) + 1];
        buffer_t buf;
 
-       if (sasl_server_find_available_mech(&client->common, "APOP") == NULL) {
+       if (sasl_server_find_available_mech(
+               &client->common, AUTH_SASL_MECH_NAME_APOP) == NULL) {
                /* disabled, no need to present the challenge */
                return NULL;
        }