login-settings.c revision ec892704d6a9625195fbb4087edeb04bc463d4ff
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstatic bool login_settings_check(void *_set, pool_t pool, const char **error_r);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen { type, #name, offsetof(struct login_settings, name), NULL }
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstatic const struct setting_define login_setting_defines[] = {
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenstatic const struct login_settings login_default_settings = {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .login_log_format_elements = "user=<%u> method=%m rip=%r lip=%l mpid=%e %c",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen .ssl_cipher_list = "ALL:!LOW:!SSLv2:!EXP:!aNULL",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenconst struct setting_parser_info login_setting_parser_info = {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenstatic const struct setting_parser_info *default_login_set_roots[] = {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenconst struct setting_parser_info **login_set_roots = default_login_set_roots;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenstatic struct master_service_settings_cache *set_cache;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen/* <settings checks> */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenstatic int ssl_settings_check(void *_set ATTR_UNUSED, const char **error_r)
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen *error_r = t_strdup_printf("SSL support not compiled in but ssl=%s",
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen *error_r = "ssl enabled, but ssl_cert not set";
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen *error_r = "ssl enabled, but ssl_key not set";
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 Sirainenstatic bool login_settings_check(void *_set, pool_t pool, const char **error_r)
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen p_strsplit(pool, set->login_log_format_elements, " ");
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen /* if we require valid cert, make sure we also ask for it */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen /* disabled */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen } else if (strcmp(set->ssl, "required") == 0) {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen *error_r = t_strdup_printf("Unknown ssl setting value: %s",
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* </settings checks> */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstatic const struct var_expand_table *
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenlogin_set_var_expand_table(const struct master_service_settings_input *input)
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen static struct var_expand_table static_tab[] = {
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen tab[1].value = net_ip2addr(&input->remote_ip);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen unsigned int i, count;
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen set_cache = master_service_settings_cache_init(master_service,
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen if (master_service_settings_cache_read(set_cache, &input, NULL,
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen i_fatal("Error reading configuration: %s", error);
a505d1beb29cbffab724b92ad16d0c44ebbaffb9Timo Sirainen cache_sets = settings_parser_get_list(parser) + 1;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen for (count = 0; input.roots[count] != NULL; count++) ;
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 settings_var_expand(&login_setting_parser_info, sets[0], pool,