login-settings.c revision 1358e2c58ce29231485a5cfa454756d429ad3d2c
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
636f017be100bce67d66fd3ae1544a47681efd33Timo Sirainenstatic bool login_settings_check(void *_set, pool_t pool, const char **error_r);
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen { type, #name, offsetof(struct login_settings, name), NULL }
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainenstatic struct setting_define login_setting_defines[] = {
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenstatic struct login_settings login_default_settings = {
fde0b1793a2842da00eaa105d5e13fec465f0443Timo Sirainen MEMBER(login_log_format_elements) "user=<%u> method=%m rip=%r lip=%l %c",
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen MEMBER(ssl_cert_file) SSLDIR"/certs/dovecot.pem",
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen MEMBER(ssl_key_file) SSLDIR"/private/dovecot.pem",
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen MEMBER(ssl_parameters_file) "ssl-parameters.dat",
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenstruct setting_parser_info login_setting_parser_info = {
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen MEMBER(struct_size) sizeof(struct login_settings),
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen/* <settings checks> */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenstatic int ssl_settings_check(void *_set ATTR_UNUSED, const char **error_r)
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen *error_r = t_strdup_printf("SSL support not compiled in but ssl=%s",
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen if (set->ssl_verify_client_cert && *set->ssl_ca_file == '\0') {
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen *error_r = "ssl_verify_client_cert set, but ssl_ca_file not";
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen *error_r = t_strdup_printf("ssl_cert_file: access(%s) failed: %m",
8039af9679af6fb56116b353fe44f7dd4c08f031Timo Sirainen *error_r = t_strdup_printf("ssl_key_file: access(%s) failed: %m",
2cfe9983ce7a6280636ee12beccc2e865111967bTimo Sirainen if (*set->ssl_ca_file != '\0' && access(set->ssl_ca_file, R_OK) < 0) {
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen *error_r = t_strdup_printf("ssl_ca_file: access(%s) failed: %m",
d10a370b2614712d9cb6a1dd8625f62a071b6377Timo Sirainenstatic bool login_settings_check(void *_set, pool_t pool ATTR_UNUSED,
88ea893b45d3ed8d68000921db9156c03cbe1b00Timo Sirainen const char **error_r)
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen t_strsplit(set->login_log_format_elements, " ");
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen if (set->ssl_require_client_cert || set->ssl_username_from_cert) {
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen /* if we require valid cert, make sure we also ask for it */
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen *error_r = "login_max_connections must be at least 1";
efe78d3ba24fc866af1c79b9223dc0809ba26cadStephan Bosch /* disabled */
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen } else if (strcmp(set->ssl, "required") == 0) {
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen *error_r = t_strdup_printf("Unknown ssl setting value: %s",
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen/* </settings checks> */
923eb3dde28e4d8841c14fd6b4a69635b7070c3eTimo Sirainenstruct login_settings *login_settings_read(struct master_service *service)
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen static const struct setting_parser_info *set_roots[] = {
923eb3dde28e4d8841c14fd6b4a69635b7070c3eTimo Sirainen if (master_service_settings_read(service, &input, &error) < 0)
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen i_fatal("Error reading configuration: %s", error);