From: Stephan Bosch Date: Wed, 3 Sep 2025 17:13:48 +0000 (+0200) Subject: auth: mech-apop - Create and use definition for mechanism name X-Git-Tag: 2.4.2~202 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c772e22ef0ee646dfdf0efb9aec7ee6c5c12f736;p=thirdparty%2Fdovecot%2Fcore.git auth: mech-apop - Create and use definition for mechanism name --- diff --git a/src/auth/auth-sasl-mech-apop.c b/src/auth/auth-sasl-mech-apop.c index 95b954b715..62a8a20909 100644 --- a/src/auth/auth-sasl-mech-apop.c +++ b/src/auth/auth-sasl-mech-apop.c @@ -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, diff --git a/src/auth/auth-sasl.h b/src/auth/auth-sasl.h index 852c54b90b..f99c983199 100644 --- a/src/auth/auth-sasl.h +++ b/src/auth/auth-sasl.h @@ -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 diff --git a/src/lib-auth-client/Makefile.am b/src/lib-auth-client/Makefile.am index afb77b8cbe..177b0b623f 100644 --- a/src/lib-auth-client/Makefile.am +++ b/src/lib-auth-client/Makefile.am @@ -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 \ diff --git a/src/lib-auth-client/auth-client-interface.h b/src/lib-auth-client/auth-client-interface.h index 1554409c4a..f4dce1db84 100644 --- a/src/lib-auth-client/auth-client-interface.h +++ b/src/lib-auth-client/auth-client-interface.h @@ -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 index 0000000000..3786a10a57 --- /dev/null +++ b/src/lib-auth-client/auth-sasl-common.h @@ -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 diff --git a/src/pop3-login/client-authenticate.c b/src/pop3-login/client-authenticate.c index 1198cc63df..742405a3d5 100644 --- a/src/pop3-login/client-authenticate.c +++ b/src/pop3-login/client-authenticate.c @@ -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; } diff --git a/src/pop3-login/client.c b/src/pop3-login/client.c index f74c27da30..020f398ede 100644 --- a/src/pop3-login/client.c +++ b/src/pop3-login/client.c @@ -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; }