bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "lib.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "buffer.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "settings-parser.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "service-settings.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "director-settings.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen/* <settings checks> */
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainenstatic bool director_settings_verify(void *_set, pool_t pool, const char **error_r);
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic struct file_listener_settings director_unix_listeners_array[] = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen { "login/director", 0, "", "" },
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen { "director-admin", 0600, "", "" }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic struct file_listener_settings *director_unix_listeners[] = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen &director_unix_listeners_array[0],
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen &director_unix_listeners_array[1]
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic buffer_t director_unix_listeners_buf = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen director_unix_listeners,
da7f1a07f583df8905684a7b78469960afd7c78dPhil Carmody sizeof(director_unix_listeners), { NULL, }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainenstatic struct file_listener_settings director_fifo_listeners_array[] = {
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen { "login/proxy-notify", 0, "", "" }
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen};
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainenstatic struct file_listener_settings *director_fifo_listeners[] = {
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen &director_fifo_listeners_array[0]
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen};
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainenstatic buffer_t director_fifo_listeners_buf = {
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen director_fifo_listeners,
da7f1a07f583df8905684a7b78469960afd7c78dPhil Carmody sizeof(director_fifo_listeners), { NULL, }
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen/* </settings checks> */
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstruct service_settings director_service_settings = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .name = "director",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .protocol = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .type = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .executable = "director",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .user = "$default_internal_user",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .group = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .privileged_group = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .extra_groups = "",
263fa7b43fb222f9805b80f62090907fe3f9ec13Timo Sirainen .chroot = ".",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .drop_priv_before_exec = FALSE,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .process_min_avail = 0,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .process_limit = 1,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .client_limit = 0,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .service_count = 0,
8ae72ad7d0c69e972cfa65d1e2ce4e3e9a8b765cTimo Sirainen .idle_kill = UINT_MAX,
f7f25f9e1a38678d0e97d2e609beac16285fac6bTimo Sirainen .vsz_limit = (uoff_t)-1,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .unix_listeners = { { &director_unix_listeners_buf,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen sizeof(director_unix_listeners[0]) } },
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen .fifo_listeners = { { &director_fifo_listeners_buf,
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen sizeof(director_fifo_listeners[0]) } },
35fcdde46a71ac151c2518d48c841019f1181bb2Timo Sirainen .inet_listeners = ARRAY_INIT,
35fcdde46a71ac151c2518d48c841019f1181bb2Timo Sirainen
35fcdde46a71ac151c2518d48c841019f1181bb2Timo Sirainen .process_limit_1 = TRUE
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#undef DEF
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#define DEF(type, name) \
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen { type, #name, offsetof(struct director_settings, name), NULL }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic const struct setting_define director_setting_defines[] = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_STR, master_user_separator),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_STR, director_servers),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_STR, director_mail_servers),
5733207dc3ec10e6e5a6e0a8b30fbd1b061062b9Timo Sirainen DEF(SET_STR, director_username_hash),
cf7857bce68a33cdabe88bb15568e21921eb5ac7Aki Tuomi DEF(SET_STR, director_flush_socket),
2adcf55dd8b0380cb2f1d2fd53accf448053d5d3Timo Sirainen DEF(SET_TIME, director_ping_idle_timeout),
2adcf55dd8b0380cb2f1d2fd53accf448053d5d3Timo Sirainen DEF(SET_TIME, director_ping_max_timeout),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_TIME, director_user_expire),
3e10cd470988298dc2b37f548ad03da4d7c11ffaTimo Sirainen DEF(SET_TIME, director_user_kick_delay),
b97e952db93a681968777dfda9728cc92ff0d7c4Timo Sirainen DEF(SET_UINT, director_max_parallel_moves),
b97e952db93a681968777dfda9728cc92ff0d7c4Timo Sirainen DEF(SET_UINT, director_max_parallel_kicks),
311cf367b949f360c9a90822f06f39df31ec69e3Timo Sirainen DEF(SET_SIZE, director_output_buffer_size),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen SETTING_DEFINE_LIST_END
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenconst struct director_settings director_default_settings = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .master_user_separator = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .director_servers = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .director_mail_servers = "",
df27aa70a3f0250767eb8a154981cd7f5dadcc91Timo Sirainen .director_username_hash = "%Lu",
cf7857bce68a33cdabe88bb15568e21921eb5ac7Aki Tuomi .director_flush_socket = "",
2adcf55dd8b0380cb2f1d2fd53accf448053d5d3Timo Sirainen .director_ping_idle_timeout = 30,
2adcf55dd8b0380cb2f1d2fd53accf448053d5d3Timo Sirainen .director_ping_max_timeout = 60,
861f53be0cc2fa5665f3c107a7576e2a53bb2eb0Timo Sirainen .director_user_expire = 60*15,
3e10cd470988298dc2b37f548ad03da4d7c11ffaTimo Sirainen .director_user_kick_delay = 2,
74c369c0587c5f6bb13d730675d8bc455c5c3f8eTimo Sirainen .director_max_parallel_moves = 100,
74c369c0587c5f6bb13d730675d8bc455c5c3f8eTimo Sirainen .director_max_parallel_kicks = 100,
311cf367b949f360c9a90822f06f39df31ec69e3Timo Sirainen .director_output_buffer_size = 10 * 1024 * 1024,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenconst struct setting_parser_info director_setting_parser_info = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .module_name = "director",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .defines = director_setting_defines,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .defaults = &director_default_settings,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .type_offset = (size_t)-1,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .struct_size = sizeof(struct director_settings),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen .parent_offset = (size_t)-1,
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen .check_func = director_settings_verify
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen/* <settings checks> */
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainenstatic bool
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainendirector_settings_verify(void *_set, pool_t pool ATTR_UNUSED, const char **error_r)
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen{
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen struct director_settings *set = _set;
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen if (set->director_user_expire < 10) {
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen *error_r = "director_user_expire is too low";
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen return FALSE;
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen }
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen return TRUE;
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen}
935960e45571872e38f730964f8ca1d116a1b532Timo Sirainen/* </settings checks> */