callback(result, credentials, size, auth_request);
}
-static struct passdb_module *
-passdb_find(const char *driver, const char *args, unsigned int *idx_r)
-{
- struct passdb_module *const *passdbs;
- unsigned int i, count;
-
- passdbs = array_get(&passdb_modules, &count);
- for (i = 0; i < count; i++) {
- if (strcmp(passdbs[i]->iface.name, driver) == 0 &&
- strcmp(passdbs[i]->args, args) == 0) {
- *idx_r = i;
- return passdbs[i];
- }
- }
- return NULL;
-}
-
struct passdb_module *
passdb_preinit(pool_t pool, const struct auth_passdb_settings *set)
{
static unsigned int auth_passdb_id = 0;
struct passdb_module_interface *iface;
struct passdb_module *passdb;
- unsigned int idx;
iface = passdb_interface_find(set->driver);
if (iface == NULL || iface->verify_plain == NULL) {
set->driver, set->args);
}
- passdb = passdb_find(set->driver, set->args, &idx);
- if (passdb != NULL)
- return passdb;
-
if (iface->preinit_legacy == NULL)
passdb = p_new(pool, struct passdb_module, 1);
else
passdb->id = ++auth_passdb_id;
passdb->iface = *iface;
passdb->args = p_strdup(pool, set->args);
- /* NOTE: if anything else than driver & args are added here,
- passdb_find() also needs to be updated. */
array_push_back(&passdb_modules, &passdb);
return passdb;
}
void passdb_deinit(struct passdb_module *passdb)
{
- unsigned int idx;
-
i_assert(passdb->init_refcount > 0);
if (--passdb->init_refcount > 0)
return;
- if (passdb_find(passdb->iface.name, passdb->args, &idx) == NULL)
- i_unreached();
- array_delete(&passdb_modules, idx, 1);
+ struct passdb_module *const *passdbs;
+ unsigned int i, count;
+
+ passdbs = array_get(&passdb_modules, &count);
+ for (i = 0; i < count; i++) {
+ if (passdbs[i] == passdb) {
+ array_delete(&passdb_modules, i, 1);
+ break;
+ }
+ }
+ i_assert(i < count);
if (passdb->iface.deinit != NULL)
passdb->iface.deinit(passdb);
/* number of time init() has been called */
int init_refcount;
- /* WARNING: avoid adding anything here that isn't based on args.
- if you do, you need to change passdb.c:passdb_find() also to avoid
- accidentally merging wrong passdbs. */
-
struct passdb_module_interface iface;
};
}
}
-static struct userdb_module *
-userdb_find(const char *driver, const char *args, unsigned int *idx_r)
-{
- struct userdb_module *const *userdbs;
- unsigned int i, count;
-
- userdbs = array_get(&userdb_modules, &count);
- for (i = 0; i < count; i++) {
- if (strcmp(userdbs[i]->iface->name, driver) == 0 &&
- strcmp(userdbs[i]->args, args) == 0) {
- *idx_r = i;
- return userdbs[i];
- }
- }
- return NULL;
-}
-
struct userdb_module *
userdb_preinit(pool_t pool, const struct auth_userdb_settings *set)
{
static unsigned int auth_userdb_id = 0;
struct userdb_module_interface *iface;
struct userdb_module *userdb;
- unsigned int idx;
iface = userdb_interface_find(set->driver);
if (iface == NULL || iface->lookup == NULL) {
set->driver, set->args);
}
- userdb = userdb_find(set->driver, set->args, &idx);
- if (userdb != NULL)
- return userdb;
-
if (iface->preinit_legacy == NULL)
userdb = p_new(pool, struct userdb_module, 1);
else
userdb->id = ++auth_userdb_id;
userdb->iface = iface;
userdb->args = p_strdup(pool, set->args);
- /* NOTE: if anything else than driver & args are added here,
- userdb_find() also needs to be updated. */
array_push_back(&userdb_modules, &userdb);
return userdb;
}
void userdb_deinit(struct userdb_module *userdb)
{
- unsigned int idx;
-
i_assert(userdb->init_refcount > 0);
if (--userdb->init_refcount > 0)
return;
- if (userdb_find(userdb->iface->name, userdb->args, &idx) == NULL)
- i_unreached();
- array_delete(&userdb_modules, idx, 1);
+ struct userdb_module *const *userdbs;
+ unsigned int i, count;
+
+ userdbs = array_get(&userdb_modules, &count);
+ for (i = 0; i < count; i++) {
+ if (userdbs[i] == userdb) {
+ array_delete(&userdb_modules, i, 1);
+ break;
+ }
+ }
+ i_assert(i < count);
if (userdb->iface->deinit != NULL)
userdb->iface->deinit(userdb);
/* number of time init() has been called */
int init_refcount;
- /* WARNING: avoid adding anything here that isn't based on args.
- if you do, you need to change userdb.c:userdb_find() also to avoid
- accidentally merging wrong userdbs. */
-
const struct userdb_module_interface *iface;
};