From: Stephan Bosch Date: Sun, 29 Oct 2023 17:05:02 +0000 (+0100) Subject: auth: Move auth_mech_list_verify_passdb() to auth-sasl X-Git-Tag: 2.4.2~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0c666d8b796881f2f02ad1264ace2f2a9eb8799;p=thirdparty%2Fdovecot%2Fcore.git auth: Move auth_mech_list_verify_passdb() to auth-sasl --- diff --git a/src/auth/auth-sasl.c b/src/auth/auth-sasl.c index 7282ae3dc0..50f047e3b0 100644 --- a/src/auth/auth-sasl.c +++ b/src/auth/auth-sasl.c @@ -394,6 +394,52 @@ void auth_sasl_instance_init(struct auth *auth, sasl_server_instance_create(auth_sasl_server, &sasl_set); } +static bool +auth_mech_verify_passdb(const struct auth *auth, + const struct sasl_server_mech_def *mech) +{ + switch (mech->passdb_need) { + case SASL_MECH_PASSDB_NEED_NOTHING: + break; + case SASL_MECH_PASSDB_NEED_VERIFY_PLAIN: + if (!auth_passdb_list_have_verify_plain(auth)) + return FALSE; + break; + case SASL_MECH_PASSDB_NEED_VERIFY_RESPONSE: + case SASL_MECH_PASSDB_NEED_LOOKUP_CREDENTIALS: + if (!auth_passdb_list_have_lookup_credentials(auth)) + return FALSE; + break; + case SASL_MECH_PASSDB_NEED_SET_CREDENTIALS: + if (!auth_passdb_list_have_lookup_credentials(auth)) + return FALSE; + if (!auth_passdb_list_have_set_credentials(auth)) + return FALSE; + break; + } + return TRUE; +} + +void auth_mech_list_verify_passdb(const struct auth *auth) +{ + const struct mech_module_list *list; + + for (list = auth->reg->modules; list != NULL; list = list->next) { + if (!auth_mech_verify_passdb(auth, list->module)) + break; + } + + if (list != NULL) { + if (auth->passdbs == NULL) { + i_fatal("No passdbs specified in configuration file. " + "%s mechanism needs one", + list->module->name); + } + i_fatal("%s mechanism can't be supported with given passdbs", + list->module->name); + } +} + void auth_sasl_instance_deinit(struct auth *auth) { sasl_server_instance_unref(&auth->sasl_inst); diff --git a/src/auth/auth-sasl.h b/src/auth/auth-sasl.h index 246f62fd5f..12a49820e4 100644 --- a/src/auth/auth-sasl.h +++ b/src/auth/auth-sasl.h @@ -42,6 +42,7 @@ auth_sasl_mech_module_find(const char *name); void auth_sasl_instance_init(struct auth *auth, const struct auth_settings *set); +void auth_mech_list_verify_passdb(const struct auth *auth); void auth_sasl_instance_deinit(struct auth *auth); /* diff --git a/src/auth/auth.c b/src/auth/auth.c index 2d7ccf230d..8cf3b6147f 100644 --- a/src/auth/auth.c +++ b/src/auth/auth.c @@ -241,52 +241,6 @@ bool auth_passdb_list_have_set_credentials(const struct auth *auth) return FALSE; } -static bool -auth_mech_verify_passdb(const struct auth *auth, - const struct sasl_server_mech_def *mech) -{ - switch (mech->passdb_need) { - case SASL_MECH_PASSDB_NEED_NOTHING: - break; - case SASL_MECH_PASSDB_NEED_VERIFY_PLAIN: - if (!auth_passdb_list_have_verify_plain(auth)) - return FALSE; - break; - case SASL_MECH_PASSDB_NEED_VERIFY_RESPONSE: - case SASL_MECH_PASSDB_NEED_LOOKUP_CREDENTIALS: - if (!auth_passdb_list_have_lookup_credentials(auth)) - return FALSE; - break; - case SASL_MECH_PASSDB_NEED_SET_CREDENTIALS: - if (!auth_passdb_list_have_lookup_credentials(auth)) - return FALSE; - if (!auth_passdb_list_have_set_credentials(auth)) - return FALSE; - break; - } - return TRUE; -} - -void auth_mech_list_verify_passdb(const struct auth *auth) -{ - const struct mech_module_list *list; - - for (list = auth->reg->modules; list != NULL; list = list->next) { - if (!auth_mech_verify_passdb(auth, list->module)) - break; - } - - if (list != NULL) { - if (auth->passdbs == NULL) { - i_fatal("No passdbs specified in configuration file. " - "%s mechanism needs one", - list->module->name); - } - i_fatal("%s mechanism can't be supported with given passdbs", - list->module->name); - } -} - static struct auth * ATTR_NULL(2) auth_preinit(const struct auth_settings *set, const char *protocol, const struct mechanisms_register *reg) diff --git a/src/auth/auth.h b/src/auth/auth.h index 1697f2e95e..94faf67d32 100644 --- a/src/auth/auth.h +++ b/src/auth/auth.h @@ -94,8 +94,6 @@ bool auth_passdb_list_have_verify_plain(const struct auth *auth); bool auth_passdb_list_have_lookup_credentials(const struct auth *auth); bool auth_passdb_list_have_set_credentials(const struct auth *auth); -void auth_mech_list_verify_passdb(const struct auth *auth); - struct auth *auth_find_protocol(const char *name); struct auth *auth_default_protocol(void);