bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
08d6658a4e2ec8104cd1307f6baa75fdb07a24f8Mark Washenberger#include "auth-common.h"
345648b341f228bd7f0b89f8aa3ecb9c470d817eTimo Sirainen#include "ioloop.h"
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen#include "mech.h"
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen#include "str.h"
6894cb956465bfb921abc7872a48e90c1b632a7eAki Tuomi#include "strfuncs.h"
5a2cb3d097a2d9a9e930af997e7bf3400a8d840dTimo Sirainen#include "passdb.h"
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen#include <ctype.h>
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainenstatic struct mech_module_list *mech_modules;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
16f46efe0e090fe6975acf012a61a160f4787985Andrey Paninvoid mech_register_module(const struct mech_module *module)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen{
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen struct mech_module_list *list;
6894cb956465bfb921abc7872a48e90c1b632a7eAki Tuomi i_assert(strcmp(module->mech_name, t_str_ucase(module->mech_name)) == 0);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen list = i_new(struct mech_module_list, 1);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen list->module = *module;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen list->next = mech_modules;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen mech_modules = list;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen}
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
16f46efe0e090fe6975acf012a61a160f4787985Andrey Paninvoid mech_unregister_module(const struct mech_module *module)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen{
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen struct mech_module_list **pos, *list;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen for (pos = &mech_modules; *pos != NULL; pos = &(*pos)->next) {
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen if (strcmp((*pos)->module.mech_name, module->mech_name) == 0) {
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen list = *pos;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen *pos = (*pos)->next;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen i_free(list);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen break;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen }
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen }
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen}
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
7242e1ce7803b83bc82e239ef111b47c1c72dd4bAndrey Paninconst struct mech_module *mech_module_find(const char *name)
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen{
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen struct mech_module_list *list;
6894cb956465bfb921abc7872a48e90c1b632a7eAki Tuomi name = t_str_ucase(name);
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen for (list = mech_modules; list != NULL; list = list->next) {
6894cb956465bfb921abc7872a48e90c1b632a7eAki Tuomi if (strcmp(list->module.mech_name, name) == 0)
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen return &list->module;
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen }
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen return NULL;
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen}
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainenvoid mech_generic_auth_initial(struct auth_request *request,
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen const unsigned char *data, size_t data_size)
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen{
4051fa1f367553cac34f74c2e332a678390bcee5Timo Sirainen if (data == NULL) {
5965eaa2d972e6264cecaf54091cd43019bc7d1fTimo Sirainen auth_request_handler_reply_continue(request, uchar_empty_ptr, 0);
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen } else {
4051fa1f367553cac34f74c2e332a678390bcee5Timo Sirainen /* initial reply given, even if it was 0 bytes */
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen request->mech->auth_continue(request, data, data_size);
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen }
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen}
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainenvoid mech_generic_auth_free(struct auth_request *request)
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen{
648d24583c1574441c4fa0331a90bd4d6e7996c5Timo Sirainen pool_unref(&request->pool);
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen}
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_plain;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_login;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_apop;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_cram_md5;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_digest_md5;
59beb411159176b39e48a52d60dd3239732e67b4Timo Sirainenextern const struct mech_module mech_external;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_ntlm;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_otp;
15cb9549422ccee416b21d26fec97a556ad0fa36Florian Zeitzextern const struct mech_module mech_scram_sha1;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_skey;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_rpa;
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_anonymous;
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen#ifdef HAVE_GSSAPI
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenextern const struct mech_module mech_gssapi;
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen#endif
704fbadd78375da18dcaf2c5d93ac8cfe2c61358Timo Sirainen#ifdef HAVE_GSSAPI_SPNEGO
704fbadd78375da18dcaf2c5d93ac8cfe2c61358Timo Sirainenextern const struct mech_module mech_gssapi_spnego;
704fbadd78375da18dcaf2c5d93ac8cfe2c61358Timo Sirainen#endif
2c38504860da8a8de915f8e0f5f39d7e7bd00cf8Timo Sirainenextern const struct mech_module mech_winbind_ntlm;
2c38504860da8a8de915f8e0f5f39d7e7bd00cf8Timo Sirainenextern const struct mech_module mech_winbind_spnego;
d1c565179ff8b17fe9ff21a3f1cb2f9c4d4f5836Aki Tuomiextern const struct mech_module mech_oauthbearer;
d1c565179ff8b17fe9ff21a3f1cb2f9c4d4f5836Aki Tuomiextern const struct mech_module mech_xoauth2;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainenstatic void mech_register_add(struct mechanisms_register *reg,
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen const struct mech_module *mech)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen{
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen struct mech_module_list *list;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen list = p_new(reg->pool, struct mech_module_list, 1);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen list->module = *mech;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_printfa(reg->handshake, "MECH\t%s", mech->mech_name);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if ((mech->flags & MECH_SEC_PRIVATE) != 0)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_append(reg->handshake, "\tprivate");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if ((mech->flags & MECH_SEC_ANONYMOUS) != 0)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_append(reg->handshake, "\tanonymous");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if ((mech->flags & MECH_SEC_PLAINTEXT) != 0)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_append(reg->handshake, "\tplaintext");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if ((mech->flags & MECH_SEC_DICTIONARY) != 0)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_append(reg->handshake, "\tdictionary");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if ((mech->flags & MECH_SEC_ACTIVE) != 0)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_append(reg->handshake, "\tactive");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if ((mech->flags & MECH_SEC_FORWARD_SECRECY) != 0)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_append(reg->handshake, "\tforward-secrecy");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if ((mech->flags & MECH_SEC_MUTUAL_AUTH) != 0)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_append(reg->handshake, "\tmutual-auth");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen str_append_c(reg->handshake, '\n');
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen list->next = reg->modules;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen reg->modules = list;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen}
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainenstatic const char *mech_get_plugin_name(const char *name)
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen{
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen string_t *str = t_str_new(32);
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen str_append(str, "mech_");
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen for (; *name != '\0'; name++) {
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen if (*name == '-')
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen str_append_c(str, '_');
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen else
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen str_append_c(str, i_tolower(*name));
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen }
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen return str_c(str);
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen}
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainenstruct mechanisms_register *
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainenmech_register_init(const struct auth_settings *set)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen{
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen struct mechanisms_register *reg;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen const struct mech_module *mech;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen const char *const *mechanisms;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen pool_t pool;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen pool = pool_alloconly_create("mechanisms register", 1024);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen reg = p_new(pool, struct mechanisms_register, 1);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen reg->pool = pool;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen reg->set = set;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen reg->handshake = str_new(pool, 512);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen mechanisms = t_strsplit_spaces(set->mechanisms, " ");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen for (; *mechanisms != NULL; mechanisms++) {
6894cb956465bfb921abc7872a48e90c1b632a7eAki Tuomi const char *name = t_str_ucase(*mechanisms);
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen
6894cb956465bfb921abc7872a48e90c1b632a7eAki Tuomi if (strcmp(name, "ANONYMOUS") == 0) {
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if (*set->anonymous_username == '\0') {
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen i_fatal("ANONYMOUS listed in mechanisms, "
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen "but anonymous_username not set");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen }
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen }
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen mech = mech_module_find(name);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if (mech == NULL) {
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen /* maybe it's a plugin. try to load it. */
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen auth_module_load(mech_get_plugin_name(name));
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen mech = mech_module_find(name);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen }
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen if (mech == NULL)
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen i_fatal("Unknown authentication mechanism '%s'", name);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen mech_register_add(reg, mech);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen }
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if (reg->modules == NULL)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen i_fatal("No authentication mechanisms configured");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen return reg;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen}
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainenvoid mech_register_deinit(struct mechanisms_register **_reg)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen{
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen struct mechanisms_register *reg = *_reg;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen *_reg = NULL;
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen pool_unref(&reg->pool);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen}
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Boschconst struct mech_module *
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Boschmech_register_find(const struct mechanisms_register *reg, const char *name)
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch{
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch const struct mech_module_list *list;
6894cb956465bfb921abc7872a48e90c1b632a7eAki Tuomi name = t_str_ucase(name);
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch for (list = reg->modules; list != NULL; list = list->next) {
6894cb956465bfb921abc7872a48e90c1b632a7eAki Tuomi if (strcmp(list->module.mech_name, name) == 0)
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch return &list->module;
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch }
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch return NULL;
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch}
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenvoid mech_init(const struct auth_settings *set)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen{
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen mech_register_module(&mech_plain);
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen mech_register_module(&mech_login);
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen mech_register_module(&mech_apop);
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen mech_register_module(&mech_cram_md5);
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen mech_register_module(&mech_digest_md5);
59beb411159176b39e48a52d60dd3239732e67b4Timo Sirainen mech_register_module(&mech_external);
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen if (set->use_winbind) {
2c38504860da8a8de915f8e0f5f39d7e7bd00cf8Timo Sirainen mech_register_module(&mech_winbind_ntlm);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen mech_register_module(&mech_winbind_spnego);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen } else {
2c38504860da8a8de915f8e0f5f39d7e7bd00cf8Timo Sirainen mech_register_module(&mech_ntlm);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen#if defined(HAVE_GSSAPI_SPNEGO) && defined(BUILTIN_GSSAPI)
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen mech_register_module(&mech_gssapi_spnego);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen#endif
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen }
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen mech_register_module(&mech_otp);
15cb9549422ccee416b21d26fec97a556ad0fa36Florian Zeitz mech_register_module(&mech_scram_sha1);
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen mech_register_module(&mech_skey);
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen mech_register_module(&mech_rpa);
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen mech_register_module(&mech_anonymous);
f97cf1c086715db87094bc3d0a4fefdd80bd869cTimo Sirainen#ifdef BUILTIN_GSSAPI
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen mech_register_module(&mech_gssapi);
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen#endif
d1c565179ff8b17fe9ff21a3f1cb2f9c4d4f5836Aki Tuomi mech_register_module(&mech_oauthbearer);
d1c565179ff8b17fe9ff21a3f1cb2f9c4d4f5836Aki Tuomi mech_register_module(&mech_xoauth2);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen}
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenvoid mech_deinit(const struct auth_settings *set)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen{
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen mech_unregister_module(&mech_plain);
33c6d5807b449463e9b81db5ec99fe027cc1b984Timo Sirainen mech_unregister_module(&mech_login);
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen mech_unregister_module(&mech_apop);
94a78eb438622fa53abef1e1726714dacad4b61cTimo Sirainen mech_unregister_module(&mech_cram_md5);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen mech_unregister_module(&mech_digest_md5);
59beb411159176b39e48a52d60dd3239732e67b4Timo Sirainen mech_unregister_module(&mech_external);
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen if (set->use_winbind) {
2c38504860da8a8de915f8e0f5f39d7e7bd00cf8Timo Sirainen mech_unregister_module(&mech_winbind_ntlm);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen mech_unregister_module(&mech_winbind_spnego);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen } else {
2c38504860da8a8de915f8e0f5f39d7e7bd00cf8Timo Sirainen mech_unregister_module(&mech_ntlm);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen#if defined(HAVE_GSSAPI_SPNEGO) && defined(BUILTIN_GSSAPI)
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen mech_unregister_module(&mech_gssapi_spnego);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen#endif
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen }
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen mech_unregister_module(&mech_otp);
81419a8dd69d8cef0e93d1e04bda77d135202452Timo Sirainen mech_unregister_module(&mech_scram_sha1);
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen mech_unregister_module(&mech_skey);
a4ac325c2802693c6b761e5a8fda961e5d7490eaTimo Sirainen mech_unregister_module(&mech_rpa);
b7c2065b3f10f9ae27787a9db5aaefbfc70d4502Timo Sirainen mech_unregister_module(&mech_anonymous);
f97cf1c086715db87094bc3d0a4fefdd80bd869cTimo Sirainen#ifdef BUILTIN_GSSAPI
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen mech_unregister_module(&mech_gssapi);
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen#endif
d1c565179ff8b17fe9ff21a3f1cb2f9c4d4f5836Aki Tuomi mech_unregister_module(&mech_oauthbearer);
d1c565179ff8b17fe9ff21a3f1cb2f9c4d4f5836Aki Tuomi mech_unregister_module(&mech_xoauth2);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen}