bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
08d6658a4e2ec8104cd1307f6baa75fdb07a24f8Mark Washenberger#include "auth-common.h"
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen#include "array.h"
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen#include "ipwd.h"
eff552f5fdc275c940c4c709eeeddb833bc51b40Timo Sirainen#include "auth-worker-server.h"
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen#include "userdb.h"
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainenstatic ARRAY(struct userdb_module_interface *) userdb_interfaces;
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainenstatic ARRAY(struct userdb_module *) userdb_modules;
b42f37ae6f65ed986315b6885568d32115e589b1Timo Sirainen
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainenstatic const struct userdb_module_interface userdb_iface_deinit = {
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainen .name = "deinit"
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainen};
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainen
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenstatic struct userdb_module_interface *userdb_interface_find(const char *name)
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen{
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen struct userdb_module_interface *const *ifaces;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen array_foreach(&userdb_interfaces, ifaces) {
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen struct userdb_module_interface *iface = *ifaces;
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen if (strcmp(iface->name, name) == 0)
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen return iface;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen }
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen return NULL;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen}
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenvoid userdb_register_module(struct userdb_module_interface *iface)
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen{
5c99eaa4e3e07ee065580d163240b4ce95b66befTimo Sirainen struct userdb_module_interface *old_iface;
5c99eaa4e3e07ee065580d163240b4ce95b66befTimo Sirainen
5c99eaa4e3e07ee065580d163240b4ce95b66befTimo Sirainen old_iface = userdb_interface_find(iface->name);
5c99eaa4e3e07ee065580d163240b4ce95b66befTimo Sirainen if (old_iface != NULL && old_iface->lookup == NULL) {
5c99eaa4e3e07ee065580d163240b4ce95b66befTimo Sirainen /* replacing a "support not compiled in" userdb */
5c99eaa4e3e07ee065580d163240b4ce95b66befTimo Sirainen userdb_unregister_module(old_iface);
5c99eaa4e3e07ee065580d163240b4ce95b66befTimo Sirainen } else if (old_iface != NULL) {
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen i_panic("userdb_register_module(%s): Already registered",
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen iface->name);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen }
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen array_append(&userdb_interfaces, &iface, 1);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen}
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenvoid userdb_unregister_module(struct userdb_module_interface *iface)
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen{
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen struct userdb_module_interface *const *ifaces;
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen unsigned int idx;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen array_foreach(&userdb_interfaces, ifaces) {
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen if (*ifaces == iface) {
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen idx = array_foreach_idx(&userdb_interfaces, ifaces);
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen array_delete(&userdb_interfaces, idx, 1);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen return;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen }
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen }
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen i_panic("userdb_unregister_module(%s): Not registered", iface->name);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen}
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainenuid_t userdb_parse_uid(struct auth_request *request, const char *str)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen{
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen struct passwd pw;
2521482f3f897c83f7d5a2f9e17fe99fa4ba2cbeTimo Sirainen uid_t uid;
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen
137ea7ca34005345aa2304a940149b7f3774d727Timo Sirainen if (str == NULL)
137ea7ca34005345aa2304a940149b7f3774d727Timo Sirainen return (uid_t)-1;
137ea7ca34005345aa2304a940149b7f3774d727Timo Sirainen
9261dbf0675204898c6557591c7aa376e23a52b2Timo Sirainen if (str_to_uid(str, &uid) == 0)
9261dbf0675204898c6557591c7aa376e23a52b2Timo Sirainen return uid;
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen switch (i_getpwnam(str, &pw)) {
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen case -1:
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen i_error("getpwnam() failed: %m");
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen return (uid_t)-1;
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen case 0:
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen if (request != NULL) {
6135260095e1704ed6edff9d00bdfc043c11429cTimo Sirainen auth_request_log_error(request, AUTH_SUBSYS_DB,
73e19ec2d5069ea125dcd1ede5d8a70f701fd9a8Timo Sirainen "Invalid UID value '%s'", str);
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen }
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen return (uid_t)-1;
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen default:
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen return pw.pw_uid;
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen }
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen}
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainengid_t userdb_parse_gid(struct auth_request *request, const char *str)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen{
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen struct group gr;
2521482f3f897c83f7d5a2f9e17fe99fa4ba2cbeTimo Sirainen gid_t gid;
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen
137ea7ca34005345aa2304a940149b7f3774d727Timo Sirainen if (str == NULL)
ccfc6441cadb577084daeb1f0aa3dd7bdfa2a220Timo Sirainen return (gid_t)-1;
137ea7ca34005345aa2304a940149b7f3774d727Timo Sirainen
9261dbf0675204898c6557591c7aa376e23a52b2Timo Sirainen if (str_to_gid(str, &gid) == 0)
9261dbf0675204898c6557591c7aa376e23a52b2Timo Sirainen return gid;
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen switch (i_getgrnam(str, &gr)) {
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen case -1:
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen i_error("getgrnam() failed: %m");
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen return (gid_t)-1;
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen case 0:
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen if (request != NULL) {
6135260095e1704ed6edff9d00bdfc043c11429cTimo Sirainen auth_request_log_error(request, AUTH_SUBSYS_DB,
73e19ec2d5069ea125dcd1ede5d8a70f701fd9a8Timo Sirainen "Invalid GID value '%s'", str);
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen }
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen return (gid_t)-1;
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen default:
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen return gr.gr_gid;
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen }
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen}
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainenstatic struct userdb_module *
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainenuserdb_find(const char *driver, const char *args, unsigned int *idx_r)
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen{
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen struct userdb_module *const *userdbs;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen unsigned int i, count;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen userdbs = array_get(&userdb_modules, &count);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen for (i = 0; i < count; i++) {
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen if (strcmp(userdbs[i]->iface->name, driver) == 0 &&
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen strcmp(userdbs[i]->args, args) == 0) {
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen *idx_r = i;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen return userdbs[i];
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen }
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen }
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen return NULL;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen}
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainenstruct userdb_module *
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainenuserdb_preinit(pool_t pool, const struct auth_userdb_settings *set)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen{
3cf67672fdc87583cb23ce088c95bb5dee60e74dTimo Sirainen static unsigned int auth_userdb_id = 0;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen struct userdb_module_interface *iface;
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainen struct userdb_module *userdb;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen unsigned int idx;
965ed6ea3fc8f7637bd0d159d2fdb283a191ce34Timo Sirainen
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen iface = userdb_interface_find(set->driver);
8ff9812659728d4166df8e003a1dd3524ae8514eTimo Sirainen if (iface == NULL || iface->lookup == NULL) {
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen /* maybe it's a plugin. try to load it. */
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen auth_module_load(t_strconcat("authdb_", set->driver, NULL));
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen iface = userdb_interface_find(set->driver);
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen }
d5abbb932a0a598f002da39a8b3326643b1b5efcTimo Sirainen if (iface == NULL)
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen i_fatal("Unknown userdb driver '%s'", set->driver);
d5abbb932a0a598f002da39a8b3326643b1b5efcTimo Sirainen if (iface->lookup == NULL) {
d5abbb932a0a598f002da39a8b3326643b1b5efcTimo Sirainen i_fatal("Support not compiled in for userdb driver '%s'",
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen set->driver);
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen }
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen if (iface->preinit == NULL && iface->init == NULL &&
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen *set->args != '\0') {
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen i_fatal("userdb %s: No args are supported: %s",
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen set->driver, set->args);
747e77e3ab073a8e9e69c7a3e71b4593c5655d03Timo Sirainen }
dd93aba1901a457346990f49c54a738947dc7128Timo Sirainen
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen userdb = userdb_find(set->driver, set->args, &idx);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen if (userdb != NULL)
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen return userdb;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainen if (iface->preinit == NULL)
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainen userdb = p_new(pool, struct userdb_module, 1);
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainen else
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen userdb = iface->preinit(pool, set->args);
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainen userdb->id = ++auth_userdb_id;
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainen userdb->iface = iface;
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen userdb->args = p_strdup(pool, set->args);
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen array_append(&userdb_modules, &userdb, 1);
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainen return userdb;
08aea01ef9a9d20703e0fcf8618e6195c0037a44Timo Sirainen}
08aea01ef9a9d20703e0fcf8618e6195c0037a44Timo Sirainen
f3d506e525a720f214020ca0f989a1966b30edaeTimo Sirainenvoid userdb_init(struct userdb_module *userdb)
08aea01ef9a9d20703e0fcf8618e6195c0037a44Timo Sirainen{
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen if (userdb->iface->init != NULL && userdb->init_refcount == 0)
f3d506e525a720f214020ca0f989a1966b30edaeTimo Sirainen userdb->iface->init(userdb);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen userdb->init_refcount++;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen}
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen
849969f639a00eab26791db3cb1b66430420c0cdTimo Sirainenvoid userdb_deinit(struct userdb_module *userdb)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen{
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen unsigned int idx;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen i_assert(userdb->init_refcount > 0);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen if (--userdb->init_refcount > 0)
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen return;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen if (userdb_find(userdb->iface->name, userdb->args, &idx) == NULL)
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen i_unreached();
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen array_delete(&userdb_modules, idx, 1);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
849969f639a00eab26791db3cb1b66430420c0cdTimo Sirainen if (userdb->iface->deinit != NULL)
849969f639a00eab26791db3cb1b66430420c0cdTimo Sirainen userdb->iface->deinit(userdb);
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainen
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainen /* make sure userdb isn't accessed again */
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainen userdb->iface = &userdb_iface_deinit;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen}
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen
9625595c47c665f5aee57ebfcb1fcbe9ad1bf3a0Martti Rannanjärvivoid userdbs_generate_md5(unsigned char md5[STATIC_ARRAY MD5_RESULTLEN])
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen{
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen struct md5_context ctx;
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen struct userdb_module *const *userdbs;
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen unsigned int i, count;
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen md5_init(&ctx);
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen userdbs = array_get(&userdb_modules, &count);
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen for (i = 0; i < count; i++) {
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen md5_update(&ctx, &userdbs[i]->id, sizeof(userdbs[i]->id));
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen md5_update(&ctx, userdbs[i]->iface->name,
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen strlen(userdbs[i]->iface->name));
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen md5_update(&ctx, userdbs[i]->args, strlen(userdbs[i]->args));
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen }
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen md5_final(&ctx, md5);
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen}
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenextern struct userdb_module_interface userdb_prefetch;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenextern struct userdb_module_interface userdb_static;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenextern struct userdb_module_interface userdb_passwd;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenextern struct userdb_module_interface userdb_passwd_file;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenextern struct userdb_module_interface userdb_vpopmail;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenextern struct userdb_module_interface userdb_ldap;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenextern struct userdb_module_interface userdb_sql;
51ead2f4c04ee85615d23c453924633b9ed8a4c2Timo Sirainenextern struct userdb_module_interface userdb_checkpassword;
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenextern struct userdb_module_interface userdb_dict;
9698cd24356147d8a5471260062ea7e10e692fdfAki Tuomi#ifdef HAVE_LUA
9698cd24356147d8a5471260062ea7e10e692fdfAki Tuomiextern struct userdb_module_interface userdb_lua;
9698cd24356147d8a5471260062ea7e10e692fdfAki Tuomi#endif
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenvoid userdbs_init(void)
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen{
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen i_array_init(&userdb_interfaces, 16);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen i_array_init(&userdb_modules, 16);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen userdb_register_module(&userdb_passwd);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen userdb_register_module(&userdb_passwd_file);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen userdb_register_module(&userdb_prefetch);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen userdb_register_module(&userdb_static);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen userdb_register_module(&userdb_vpopmail);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen userdb_register_module(&userdb_ldap);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen userdb_register_module(&userdb_sql);
51ead2f4c04ee85615d23c453924633b9ed8a4c2Timo Sirainen userdb_register_module(&userdb_checkpassword);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen userdb_register_module(&userdb_dict);
9698cd24356147d8a5471260062ea7e10e692fdfAki Tuomi#ifdef HAVE_LUA
9698cd24356147d8a5471260062ea7e10e692fdfAki Tuomi userdb_register_module(&userdb_lua);
9698cd24356147d8a5471260062ea7e10e692fdfAki Tuomi#endif
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen}
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenvoid userdbs_deinit(void)
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen{
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen array_free(&userdb_modules);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen array_free(&userdb_interfaces);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen}