SETTING_DEFINE_STRUCT_##type(#name, name, struct auth_settings)
static const struct setting_define auth_setting_defines[] = {
- DEF(STR, mechanisms),
+ DEF(BOOLLIST, mechanisms),
DEF(STR, realms),
DEF(STR, default_domain),
DEF(SIZE, cache_size),
};
static const struct auth_settings auth_default_settings = {
- .mechanisms = "plain",
.realms = "",
.default_domain = "",
.cache_size = 0,
.first_valid_gid = 1,
.last_valid_gid = 0,
};
+static const struct setting_keyvalue auth_default_settings_keyvalue[] = {
+ { "auth_mechanisms", "plain" },
+ { NULL, NULL }
+};
const struct setting_parser_info auth_setting_parser_info = {
.name = "auth",
.defines = auth_setting_defines,
.defaults = &auth_default_settings,
+ .default_settings = auth_default_settings_keyvalue,
.struct_size = sizeof(struct auth_settings),
.pool_offset1 = 1 + offsetof(struct auth_settings, pool),
struct auth_settings {
pool_t pool;
- const char *mechanisms;
+ ARRAY_TYPE(const_string) mechanisms;
const char *realms;
const char *default_domain;
uoff_t cache_size;
{
struct mechanisms_register *reg;
const struct mech_module *mech;
- const char *const *mechanisms;
+ const char *name;
pool_t pool;
pool = pool_alloconly_create("mechanisms register", 1024);
reg->set = set;
reg->handshake = str_new(pool, 512);
- mechanisms = t_strsplit_spaces(set->mechanisms, " ");
- for (; *mechanisms != NULL; mechanisms++) {
- const char *name = t_str_ucase(*mechanisms);
+ if (!array_is_created(&set->mechanisms) ||
+ array_is_empty(&set->mechanisms))
+ i_fatal("No authentication mechanisms configured");
+
+ array_foreach_elem(&set->mechanisms, name) {
+ name = t_str_ucase(name);
if (strcmp(name, "ANONYMOUS") == 0) {
if (*set->anonymous_username == '\0') {
i_fatal("Unknown authentication mechanism '%s'", name);
mech_register_add(reg, mech);
}
-
- if (reg->modules == NULL)
- i_fatal("No authentication mechanisms configured");
return reg;
}
test_auth_set = *(const struct auth_settings *)auth_setting_parser_info.defaults;
test_auth_set.pool = pool_alloconly_create("test settings", 128);
test_auth_set.base_dir = ".";
- test_auth_set.mechanisms = "plain";
+ p_array_init(&test_auth_set.mechanisms, test_auth_set.pool, 1);
+ const char *plain = "plain";
+ array_push_back(&test_auth_set.mechanisms, &plain);
global_auth_settings = &test_auth_set;
memset((&test_auth_set)->username_chars_map, 1,
sizeof((&test_auth_set)->username_chars_map));