director-settings.c revision 3e10cd470988298dc2b37f548ad03da4d7c11ffa
5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen/* Copyright (c) 2009-2015 Dovecot authors, see the included COPYING file */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#include "lib.h"
9a583c7a827f7a4d89ee43774f2d51ea6a214543Timo Sirainen#include "buffer.h"
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen#include "settings-parser.h"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#include "service-settings.h"
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen#include "director-settings.h"
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* <settings checks> */
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainenstatic bool director_settings_verify(void *_set, pool_t pool, const char **error_r);
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic struct file_listener_settings director_unix_listeners_array[] = {
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen { "login/director", 0, "", "" },
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen { "director-admin", 0600, "", "" }
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen};
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic struct file_listener_settings *director_unix_listeners[] = {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen &director_unix_listeners_array[0],
289064eb21595d3e4460439eccdc48232d13f5e1Timo Sirainen &director_unix_listeners_array[1]
289064eb21595d3e4460439eccdc48232d13f5e1Timo Sirainen};
dd0ba1bab2c1b89c7e063fa45d156fa72b8260d5Timo Sirainenstatic buffer_t director_unix_listeners_buf = {
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen director_unix_listeners,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen sizeof(director_unix_listeners), { NULL, }
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen};
d33fc6c584718efd46159e1d8f46488b9dfc66f5Timo Sirainenstatic struct file_listener_settings director_fifo_listeners_array[] = {
d33fc6c584718efd46159e1d8f46488b9dfc66f5Timo Sirainen { "login/proxy-notify", 0, "", "" }
d33fc6c584718efd46159e1d8f46488b9dfc66f5Timo Sirainen};
d33fc6c584718efd46159e1d8f46488b9dfc66f5Timo Sirainenstatic struct file_listener_settings *director_fifo_listeners[] = {
d33fc6c584718efd46159e1d8f46488b9dfc66f5Timo Sirainen &director_fifo_listeners_array[0]
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen};
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainenstatic buffer_t director_fifo_listeners_buf = {
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen director_fifo_listeners,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen sizeof(director_fifo_listeners), { NULL, }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen};
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* </settings checks> */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct service_settings director_service_settings = {
a2ce2eb4c266e2854fd34416ea5cfbe05dfd3971Timo Sirainen .name = "director",
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainen .protocol = "",
a2ce2eb4c266e2854fd34416ea5cfbe05dfd3971Timo Sirainen .type = "",
e9f2d9104d395bcf54be3f8ba8d9f63aecf0bcbeTimo Sirainen .executable = "director",
d33fc6c584718efd46159e1d8f46488b9dfc66f5Timo Sirainen .user = "$default_internal_user",
131b073bdc3650083b00616dc778dd3017c2bbb5Timo Sirainen .group = "",
289064eb21595d3e4460439eccdc48232d13f5e1Timo Sirainen .privileged_group = "",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen .extra_groups = "",
f0ff961282e618945dfe997dc45ff95d656e5790Timo Sirainen .chroot = ".",
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen
df6478c4cf605bd81b3891c148b84c14eb6c4035Timo Sirainen .drop_priv_before_exec = FALSE,
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen .process_min_avail = 0,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen .process_limit = 1,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .client_limit = 0,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .service_count = 0,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .idle_kill = UINT_MAX,
289064eb21595d3e4460439eccdc48232d13f5e1Timo Sirainen .vsz_limit = (uoff_t)-1,
127f99adeb10d9f9e06896f97dc187eac4ca8852Timo Sirainen
e1f05b193ac1edd3267294e9501e8063aa0f791aTimo Sirainen .unix_listeners = { { &director_unix_listeners_buf,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen sizeof(director_unix_listeners[0]) } },
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .fifo_listeners = { { &director_fifo_listeners_buf,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen sizeof(director_fifo_listeners[0]) } },
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .inet_listeners = ARRAY_INIT,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen
61b6d1256936065321153bcd9228b9e45d95c9abTimo Sirainen .process_limit_1 = TRUE
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen};
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen#undef DEF
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen#define DEF(type, name) \
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen { type, #name, offsetof(struct director_settings, name), NULL }
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen
9f19a50d5966643c4d1c5ca06868ac2ad31bc4d5Timo Sirainenstatic const struct setting_define director_setting_defines[] = {
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen DEF(SET_STR, master_user_separator),
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen DEF(SET_STR, director_servers),
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen DEF(SET_STR, director_mail_servers),
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen DEF(SET_STR, director_username_hash),
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen DEF(SET_TIME, director_user_expire),
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen DEF(SET_TIME, director_user_kick_delay),
9f19a50d5966643c4d1c5ca06868ac2ad31bc4d5Timo Sirainen DEF(SET_IN_PORT, director_doveadm_port),
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen DEF(SET_BOOL, director_consistent_hashing),
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen SETTING_DEFINE_LIST_END
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen};
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainenconst struct director_settings director_default_settings = {
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .master_user_separator = "",
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .director_servers = "",
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .director_mail_servers = "",
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .director_username_hash = "%Lu",
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .director_user_expire = 60*15,
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen .director_user_kick_delay = 2,
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen .director_doveadm_port = 0
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen};
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
61b6d1256936065321153bcd9228b9e45d95c9abTimo Sirainenconst struct setting_parser_info director_setting_parser_info = {
61b6d1256936065321153bcd9228b9e45d95c9abTimo Sirainen .module_name = "director",
61b6d1256936065321153bcd9228b9e45d95c9abTimo Sirainen .defines = director_setting_defines,
61b6d1256936065321153bcd9228b9e45d95c9abTimo Sirainen .defaults = &director_default_settings,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .type_offset = (size_t)-1,
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen .struct_size = sizeof(struct director_settings),
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen .parent_offset = (size_t)-1,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen .check_func = director_settings_verify
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen};
ee26329cb5cc679b5645e4933d529f86accb976aTimo Sirainen
992a13add4eea0810e4db0f042a595dddf85536aTimo Sirainen/* <settings checks> */
992a13add4eea0810e4db0f042a595dddf85536aTimo Sirainenstatic bool
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainendirector_settings_verify(void *_set, pool_t pool ATTR_UNUSED, const char **error_r)
992a13add4eea0810e4db0f042a595dddf85536aTimo Sirainen{
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen struct director_settings *set = _set;
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen if (set->director_user_expire < 10) {
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen *error_r = "director_user_expire is too low";
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen return FALSE;
5e40ed3f0a2c2acddc9b8eab59670c7a850114c5Timo Sirainen }
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen return TRUE;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen}
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* </settings checks> */
61b6d1256936065321153bcd9228b9e45d95c9abTimo Sirainen