login-settings.c revision ec892704d6a9625195fbb4087edeb04bc463d4ff
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include "login-common.h"
6dc4af35c045e10609b13fe80f9cf33f3a06c3ceTimo Sirainen#include "hostpid.h"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include "var-expand.h"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include "settings-parser.h"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include "master-service.h"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include "master-service-settings.h"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include "master-service-settings-cache.h"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include "login-settings.h"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include <stddef.h>
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include <unistd.h>
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstatic bool login_settings_check(void *_set, pool_t pool, const char **error_r);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#undef DEF
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#define DEF(type, name) \
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen { type, #name, offsetof(struct login_settings, name), NULL }
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstatic const struct setting_define login_setting_defines[] = {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen DEF(SET_STR, login_trusted_networks),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_STR_VARS, login_greeting),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_STR, login_log_format_elements),
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen DEF(SET_STR, login_log_format),
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen DEF(SET_STR, login_access_sockets),
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen DEF(SET_ENUM, ssl),
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen DEF(SET_STR, ssl_ca),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_STR, ssl_cert),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_STR, ssl_key),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_STR, ssl_key_password),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_STR, ssl_cipher_list),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_STR, ssl_protocols),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_STR, ssl_cert_username_field),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_BOOL, ssl_verify_client_cert),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_BOOL, auth_ssl_require_client_cert),
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen DEF(SET_BOOL, auth_ssl_username_from_cert),
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen DEF(SET_BOOL, verbose_ssl),
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen DEF(SET_BOOL, disable_plaintext_auth),
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen DEF(SET_BOOL, verbose_auth),
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen DEF(SET_BOOL, auth_debug),
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen DEF(SET_BOOL, verbose_proctitle),
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen DEF(SET_UINT, mail_max_userip_connections),
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen SETTING_DEFINE_LIST_END
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen};
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenstatic const struct login_settings login_default_settings = {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .login_trusted_networks = "",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .login_greeting = PACKAGE_NAME" ready.",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .login_log_format_elements = "user=<%u> method=%m rip=%r lip=%l mpid=%e %c",
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen .login_log_format = "%$: %s",
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen .login_access_sockets = "",
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .ssl = "yes:no:required",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .ssl_ca = "",
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen .ssl_cert = "",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .ssl_key = "",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .ssl_key_password = "",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .ssl_cipher_list = "ALL:!LOW:!SSLv2:!EXP:!aNULL",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .ssl_protocols = "!SSLv2",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .ssl_cert_username_field = "commonName",
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen .ssl_verify_client_cert = FALSE,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .auth_ssl_require_client_cert = FALSE,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .auth_ssl_username_from_cert = FALSE,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .verbose_ssl = FALSE,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .disable_plaintext_auth = TRUE,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .verbose_auth = FALSE,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen .auth_debug = FALSE,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .verbose_proctitle = FALSE,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .mail_max_userip_connections = 10
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen};
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenconst struct setting_parser_info login_setting_parser_info = {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen .module_name = "login",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .defines = login_setting_defines,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .defaults = &login_default_settings,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen .type_offset = (size_t)-1,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen .struct_size = sizeof(struct login_settings),
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen .parent_offset = (size_t)-1,
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .check_func = login_settings_check
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen};
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenstatic const struct setting_parser_info *default_login_set_roots[] = {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen &login_setting_parser_info,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen NULL
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen};
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenconst struct setting_parser_info **login_set_roots = default_login_set_roots;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenstatic struct master_service_settings_cache *set_cache;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen/* <settings checks> */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenstatic int ssl_settings_check(void *_set ATTR_UNUSED, const char **error_r)
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen{
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen struct login_settings *set = _set;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen#ifndef HAVE_SSL
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen *error_r = t_strdup_printf("SSL support not compiled in but ssl=%s",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen set->ssl);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen return FALSE;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen#else
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen if (*set->ssl_cert == '\0') {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen *error_r = "ssl enabled, but ssl_cert not set";
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen return FALSE;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen }
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen if (*set->ssl_key == '\0') {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen *error_r = "ssl enabled, but ssl_key not set";
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen return FALSE;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen }
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen if (set->ssl_verify_client_cert && *set->ssl_ca == '\0') {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen *error_r = "ssl_verify_client_cert set, but ssl_ca not";
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen return FALSE;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen }
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen return TRUE;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen#endif
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen}
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenstatic bool login_settings_check(void *_set, pool_t pool, const char **error_r)
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen{
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen struct login_settings *set = _set;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen set->log_format_elements_split =
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen p_strsplit(pool, set->login_log_format_elements, " ");
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen if (set->auth_ssl_require_client_cert ||
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen set->auth_ssl_username_from_cert) {
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen /* if we require valid cert, make sure we also ask for it */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen set->ssl_verify_client_cert = TRUE;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen }
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen if (strcmp(set->ssl, "no") == 0) {
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen /* disabled */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen } else if (strcmp(set->ssl, "yes") == 0) {
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen if (!ssl_settings_check(set, error_r))
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen return FALSE;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen } else if (strcmp(set->ssl, "required") == 0) {
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen if (!ssl_settings_check(set, error_r))
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen return FALSE;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen set->disable_plaintext_auth = TRUE;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen } else {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen *error_r = t_strdup_printf("Unknown ssl setting value: %s",
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen set->ssl);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen return FALSE;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen }
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen return TRUE;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen}
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* </settings checks> */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstatic const struct var_expand_table *
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenlogin_set_var_expand_table(const struct master_service_settings_input *input)
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen{
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen static struct var_expand_table static_tab[] = {
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen { 'l', NULL, "lip" },
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen { 'r', NULL, "rip" },
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen { 'p', NULL, "pid" },
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen { 's', NULL, "service" },
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen { '\0', NULL, NULL }
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen };
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen struct var_expand_table *tab;
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen tab = t_malloc(sizeof(static_tab));
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen memcpy(tab, static_tab, sizeof(static_tab));
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen tab[0].value = net_ip2addr(&input->local_ip);
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen tab[1].value = net_ip2addr(&input->remote_ip);
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen tab[2].value = my_pid;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen tab[3].value = input->service;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen return tab;
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen}
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenstruct login_settings *
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenlogin_settings_read(pool_t pool,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const struct ip_addr *local_ip,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const struct ip_addr *remote_ip,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char *local_name,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen void ***other_settings_r)
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen{
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen struct master_service_settings_input input;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char *error;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const struct setting_parser_context *parser;
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen void *const *cache_sets;
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen void **sets;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen unsigned int i, count;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen memset(&input, 0, sizeof(input));
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen input.roots = login_set_roots;
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen input.module = login_binary->process_name;
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen input.service = login_binary->protocol;
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen input.local_name = local_name;
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen if (local_ip != NULL)
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen input.local_ip = *local_ip;
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen if (remote_ip != NULL)
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen input.remote_ip = *remote_ip;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen if (set_cache == NULL) {
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen set_cache = master_service_settings_cache_init(master_service,
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen input.module,
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen input.service);
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen }
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen if (master_service_settings_cache_read(set_cache, &input, NULL,
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen &parser, &error) < 0)
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen i_fatal("Error reading configuration: %s", error);
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen cache_sets = settings_parser_get_list(parser) + 1;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen for (count = 0; input.roots[count] != NULL; count++) ;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen i_assert(cache_sets[count] == NULL);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen sets = p_new(pool, void *, count + 1);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen for (i = 0; i < count; i++) {
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen sets[i] = settings_dup(input.roots[i], cache_sets[i], pool);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen if (!settings_check(input.roots[i], pool, sets[i], &error)) {
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char *name = input.roots[i]->module_name;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen i_fatal("settings_check(%s) failed: %s",
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen name != NULL ? name : "unknown", error);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen }
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen }
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen settings_var_expand(&login_setting_parser_info, sets[0], pool,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen login_set_var_expand_table(&input));
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen
13c6532dc104d23061e6901783ceb1ff8872c206Timo Sirainen *other_settings_r = sets + 1;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen return sets[0];
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen}
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainenvoid login_settings_deinit(void)
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen{
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen if (set_cache != NULL)
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen master_service_settings_cache_deinit(&set_cache);
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen}
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen