userdb.c revision be5c76fabc7439fd33bc799bc3ab3f570799977b
89a126810703c666309310d0f3189e9834d70b5bTimo Sirainen/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainenstatic ARRAY_DEFINE(userdb_interfaces, struct userdb_module_interface *);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenstatic ARRAY_DEFINE(userdb_modules, struct userdb_module *);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenstatic struct userdb_module_interface *userdb_interface_find(const char *name)
9511a40d933181045343110c8101b75887062aaeTimo Sirainen struct userdb_module_interface *const *ifaces;
1de2b5a16a455e018d8cbf72ee114d4b5d557a48Timo Sirainen struct userdb_module_interface *iface = *ifaces;
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenvoid userdb_register_module(struct userdb_module_interface *iface)
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen old_iface = userdb_interface_find(iface->name);
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen if (old_iface != NULL && old_iface->lookup == NULL) {
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen /* replacing a "support not compiled in" userdb */
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen i_panic("userdb_register_module(%s): Already registered",
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenvoid userdb_unregister_module(struct userdb_module_interface *iface)
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen struct userdb_module_interface *const *ifaces;
1de2b5a16a455e018d8cbf72ee114d4b5d557a48Timo Sirainen unsigned int idx;
601f5f14c6cde28f0e0c6ca7c5d735315d3d48dfTimo Sirainen idx = array_foreach_idx(&userdb_interfaces, ifaces);
1de2b5a16a455e018d8cbf72ee114d4b5d557a48Timo Sirainen i_panic("userdb_unregister_module(%s): Not registered", iface->name);
1de2b5a16a455e018d8cbf72ee114d4b5d557a48Timo Sirainenuid_t userdb_parse_uid(struct auth_request *request, const char *str)
1117aa7adc2909c750031fd7551a58a486d100d8Timo Sirainen if (*p == '\0')
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainengid_t userdb_parse_gid(struct auth_request *request, const char *str)
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen if (*p == '\0')
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenuserdb_find(const char *driver, const char *args, unsigned int *idx_r)
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen unsigned int i, count;
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen for (i = 0; i < count; i++) {
597dba3488c648ffb375ee4a552bd52ac4346979Timo Sirainen if (strcmp(userdbs[i]->iface->name, driver) == 0 &&
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenuserdb_preinit(pool_t pool, const char *driver, const char *args)
411d6baa37f31d90730e90c4a28c43e1974bbe58Timo Sirainen static unsigned int auth_userdb_id = 0;
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen unsigned int idx;
driver);
return userdb;
return userdb;
unsigned int idx;
i_unreached();
unsigned int i, count;
for (i = 0; i < count; i++) {
void userdbs_init(void)
void userdbs_deinit(void)