lmtp-settings.c revision da7f1a07f583df8905684a7b78469960afd7c78d
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen/* Copyright (c) 2009-2014 Dovecot authors, see the included COPYING file */
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "lib.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "buffer.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "var-expand.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "settings-parser.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "service-settings.h"
fe8af34153615d9007f2238fca87df11ff32d614Timo Sirainen#include "master-service.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "master-service-settings.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "lda-settings.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "lmtp-settings.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include "mail-storage-settings.h"
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include <stddef.h>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#include <unistd.h>
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen/* <settings checks> */
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic struct file_listener_settings lmtp_unix_listeners_array[] = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen { "lmtp", 0666, "", "" }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic struct file_listener_settings *lmtp_unix_listeners[] = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen &lmtp_unix_listeners_array[0]
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic buffer_t lmtp_unix_listeners_buf = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen lmtp_unix_listeners, sizeof(lmtp_unix_listeners), { NULL, }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen/* </settings checks> */
b4ddb5b3c3722620a8fef387dd8c47bb411a5643Timo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstruct service_settings lmtp_service_settings = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .name = "lmtp",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .protocol = "lmtp",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .type = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .executable = "lmtp",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .user = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .group = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .privileged_group = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .extra_groups = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .chroot = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .drop_priv_before_exec = FALSE,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .process_min_avail = 0,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .process_limit = 0,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .client_limit = 1,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .service_count = 0,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .idle_kill = 0,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .vsz_limit = (uoff_t)-1,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .unix_listeners = { { &lmtp_unix_listeners_buf,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen sizeof(lmtp_unix_listeners[0]) } },
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .fifo_listeners = ARRAY_INIT,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .inet_listeners = ARRAY_INIT
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#undef DEF
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#define DEF(type, name) \
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen { type, #name, offsetof(struct lmtp_settings, name), NULL }
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic const struct setting_define lmtp_setting_defines[] = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_BOOL, lmtp_proxy),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_BOOL, lmtp_save_to_detail_mailbox),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_BOOL, lmtp_rcpt_check_quota),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_STR, lmtp_address_translate),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_STR_VARS, login_greeting),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEF(SET_STR, login_trusted_networks),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen SETTING_DEFINE_LIST_END
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic const struct lmtp_settings lmtp_default_settings = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .lmtp_proxy = FALSE,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .lmtp_save_to_detail_mailbox = FALSE,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .lmtp_rcpt_check_quota = FALSE,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .lmtp_address_translate = "",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .login_greeting = PACKAGE_NAME" ready.",
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen .login_trusted_networks = ""
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic const struct setting_parser_info *lmtp_setting_dependencies[] = {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen &lda_setting_parser_info,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen NULL
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen};
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainenconst struct setting_parser_info lmtp_setting_parser_info = {
300e4e43ed1ca46d0614459161ca2fb460ef661aTimo Sirainen .module_name = "lmtp",
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .defines = lmtp_setting_defines,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .defaults = &lmtp_default_settings,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .type_offset = (size_t)-1,
156fc0eeccbe855ccc487c673528d21aa440191eTimo Sirainen .struct_size = sizeof(struct lmtp_settings),
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .parent_offset = (size_t)-1,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen .dependencies = lmtp_setting_dependencies
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen};
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenvoid lmtp_settings_dup(const struct setting_parser_context *set_parser,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen pool_t pool,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen struct lmtp_settings **lmtp_set_r,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen struct lda_settings **lda_set_r)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen{
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen void **sets;
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
b4ddb5b3c3722620a8fef387dd8c47bb411a5643Timo Sirainen sets = master_service_settings_parser_get_others(master_service,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen set_parser);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen *lda_set_r = settings_dup(&lda_setting_parser_info, sets[1], pool);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen *lmtp_set_r = settings_dup(&lmtp_setting_parser_info, sets[2], pool);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen}
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen