void auth_policy_init(void)
{
const struct master_service_ssl_settings *master_ssl_set =
- master_service_settings_get_root_set(master_service,
+ master_service_settings_get_or_fatal(NULL,
&master_service_ssl_setting_parser_info);
struct ssl_iostream_settings ssl_set;
i_zero(&ssl_set);
http_client_set.ssl = &ssl_set;
http_client_set.event_parent = auth_event;
http_client = http_client_init(&http_client_set);
+ master_service_settings_free(master_ssl_set);
/* prepare template */
.defaults = &auth_default_settings,
.struct_size = sizeof(struct auth_settings),
+ .pool_offset1 = 1 + offsetof(struct auth_settings, pool),
.check_func = auth_settings_check
};
const struct auth_settings *global_auth_settings;
const struct auth_settings *
-auth_settings_read(const char *service, pool_t pool,
+auth_settings_read(const char *service,
struct master_service_settings_output *output_r)
{
static const struct setting_parser_info *set_roots[] = {
NULL
};
struct master_service_settings_input input;
- struct setting_parser_context *set_parser;
const char *error;
i_zero(&input);
input.roots = set_roots;
input.service = service;
+ input.disable_check_settings = TRUE;
if (master_service_settings_read(master_service, &input,
output_r, &error) < 0)
i_fatal("%s", error);
- pool_ref(pool);
- set_parser = settings_parser_dup(master_service->set_parser, pool);
- if (!settings_parser_check(set_parser, pool, &error))
- i_unreached();
-
- struct auth_settings *set =
- settings_parser_get_root_set(set_parser, &auth_setting_parser_info);
- settings_parser_unref(&set_parser);
+ struct event *event = event_create(NULL);
+ event_add_str(event, "protocol", service);
+ const struct auth_settings *set =
+ master_service_settings_get_or_fatal(event,
+ &auth_setting_parser_info);
+ event_unref(&event);
return set;
}
};
struct auth_settings {
+ pool_t pool;
const char *mechanisms;
const char *realms;
const char *default_domain;
extern const struct auth_settings *global_auth_settings;
const struct auth_settings *
-auth_settings_read(const char *service, pool_t pool,
+auth_settings_read(const char *service,
struct master_service_settings_output *output_r)
ATTR_NULL(1);
}
static struct auth * ATTR_NULL(2)
-auth_preinit(const struct auth_settings *set, const char *service, pool_t pool,
+auth_preinit(const struct auth_settings *set, const char *service,
const struct mechanisms_register *reg)
{
struct auth_passdb_settings *const *passdbs;
struct auth *auth;
unsigned int i, count, db_count, passdb_count, last_passdb = 0;
+ pool_t pool = pool_alloconly_create("auth", 128);
auth = p_new(pool, struct auth, 1);
auth->pool = pool;
auth->service = p_strdup(pool, service);
return a[0];
}
-void auths_preinit(const struct auth_settings *set, pool_t pool,
+void auths_preinit(const struct auth_settings *set,
const struct mechanisms_register *reg,
const char *const *services)
{
event_add_category(auth_event, &event_category_auth);
i_array_init(&auths, 8);
- auth = auth_preinit(set, NULL, pool, reg);
+ auth = auth_preinit(set, NULL, reg);
array_push_back(&auths, &auth);
for (i = 0; services[i] != NULL; i++) {
}
not_service = services[i];
}
- service_set = auth_settings_read(services[i], pool,
- &set_output);
- auth = auth_preinit(service_set, services[i], pool, reg);
+ service_set = auth_settings_read(services[i], &set_output);
+ auth = auth_preinit(service_set, services[i], reg);
array_push_back(&auths, &auth);
}
void auths_free(void)
{
- struct auth **auth;
- unsigned int i, count;
+ struct auth *auth;
- /* deinit in reverse order, because modules have been allocated by
- the first auth pool that used them */
- auth = array_get_modifiable(&auths, &count);
- for (i = count; i > 0; i--)
- pool_unref(&auth[i-1]->pool);
+ array_foreach_elem(&auths, auth) {
+ master_service_settings_free(auth->set);
+ pool_unref(&auth->pool);
+ }
array_free(&auths);
}
struct auth *auth_find_service(const char *name);
struct auth *auth_default_service(void);
-void auths_preinit(const struct auth_settings *set, pool_t pool,
+void auths_preinit(const struct auth_settings *set,
const struct mechanisms_register *reg,
const char *const *services);
void auths_init(void);
time_t process_start_time;
struct auth_penalty *auth_penalty;
-static pool_t auth_set_pool;
static struct module *modules = NULL;
static struct mechanisms_register *mech_reg;
static ARRAY(struct auth_socket_listener) listeners;
static const char *const *read_global_settings(void)
{
struct master_service_settings_output set_output;
- const char **services;
- unsigned int i, count;
-
- auth_set_pool = pool_alloconly_create("auth settings", 8192);
- global_auth_settings =
- auth_settings_read(NULL, auth_set_pool, &set_output);
-
- /* strdup() the service names, because they're allocated from
- set parser pool, and we'll later clear it. */
- count = str_array_length(set_output.specific_services);
- services = p_new(auth_set_pool, const char *, count + 1);
- for (i = 0; i < count; i++) {
- services[i] = p_strdup(auth_set_pool,
- set_output.specific_services[i]);
- }
- return services;
+
+ global_auth_settings = auth_settings_read(NULL, &set_output);
+ if (set_output.specific_services == NULL)
+ return t_new(const char *, 1);
+ return set_output.specific_services;
}
static enum auth_socket_type auth_socket_type_get(const char *typename)
mech_init(global_auth_settings);
mech_reg = mech_register_init(global_auth_settings);
dict_drivers_register_builtin();
- auths_preinit(global_auth_settings, auth_set_pool,
- mech_reg, services);
+ auths_preinit(global_auth_settings, mech_reg, services);
listeners_init();
if (!worker)
array_foreach_modifiable(&listeners, l)
i_free(l->path);
array_free(&listeners);
- pool_unref(&auth_set_pool);
}
static void worker_connected(struct master_service_connection *conn)
password_schemes_init();
password_schemes_allow_weak(TRUE);
- auths_preinit(&set, pool_datastack_create(), mech_reg, services);
+ auths_preinit(&set, mech_reg, services);
auths_init();
auth_token_init();
}