]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Move auth_mech_list_verify_passdb() to auth-sasl
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sun, 29 Oct 2023 17:05:02 +0000 (18:05 +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/auth-sasl.h
src/auth/auth.c
src/auth/auth.h

index 7282ae3dc06dcfd47289db0747ae86672d8313e2..50f047e3b0e69d7fceb20651814f08fce5317027 100644 (file)
@@ -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);
index 246f62fd5f449749693ce48fabd36a4a287332e3..12a49820e49654280b2308fc7e622b5836a88128 100644 (file)
@@ -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);
 
 /*
index 2d7ccf230d0bf60e847b091f623e67d6475b7033..8cf3b6147fe10472fe3b056cd45c11413ef82575 100644 (file)
@@ -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)
index 1697f2e95e689ac87b0102681d3abf9cd00b45c8..94faf67d32a4ba6af9928588f90d9bac15923b11 100644 (file)
@@ -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);