lda-settings.c revision 7744586e3e0fd60158abfbb03a233d3bd8d6c48b
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen#include "lib.h"
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen#include "settings-parser.h"
b039dabf4c53f72454e795930e7643b6e0e625f9Timo Sirainen#include "mail-storage-settings.h"
2f30b72d49fbff0c4096125c139e4bdfef45669cTimo Sirainen#include "lda-settings.h"
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen
91b203fd2132510a47a4b34252c0ae0efd688a19Timo Sirainen#include <stddef.h>
b13f738e8eb3f24dc2abf2c804f954b4d864ac6fTimo Sirainen
61b0637759146621cbb7edcbd0b03a71cfd66dfeTimo Sirainenstatic bool lda_settings_check(void *_set, pool_t pool, const char **error_r);
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen#undef DEF
b039dabf4c53f72454e795930e7643b6e0e625f9Timo Sirainen#undef DEFLIST
b039dabf4c53f72454e795930e7643b6e0e625f9Timo Sirainen#define DEF(type, name) \
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen { type, #name, offsetof(struct lda_settings, name), NULL }
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen#define DEFLIST(field, name, defines) \
c040ee67d0ac0fb7375bb543965bf67dcae6affaTimo Sirainen { SET_DEFLIST, name, offsetof(struct lda_settings, field), defines }
b039dabf4c53f72454e795930e7643b6e0e625f9Timo Sirainen
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainenstatic const struct setting_define lda_setting_defines[] = {
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen DEF(SET_STR, postmaster_address),
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen DEF(SET_STR, hostname),
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen DEF(SET_STR, sendmail_path),
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen DEF(SET_STR, rejection_subject),
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen DEF(SET_STR, rejection_reason),
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen DEF(SET_STR, deliver_log_format),
4c1deab456fe8877bf025d11843167ac1f36327aTimo Sirainen DEF(SET_BOOL, quota_full_tempfail),
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen DEF(SET_BOOL, lda_mailbox_autocreate),
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen DEF(SET_BOOL, lda_mailbox_autosubscribe),
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen SETTING_DEFINE_LIST_END
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen};
c040ee67d0ac0fb7375bb543965bf67dcae6affaTimo Sirainen
c040ee67d0ac0fb7375bb543965bf67dcae6affaTimo Sirainenstatic const struct lda_settings lda_default_settings = {
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(postmaster_address) "",
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(hostname) "",
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(sendmail_path) "/usr/lib/sendmail",
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(rejection_subject) "Rejected: %s",
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(rejection_reason)
b039dabf4c53f72454e795930e7643b6e0e625f9Timo Sirainen "Your message to <%t> was automatically rejected:%n%r",
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(deliver_log_format) "msgid=%m: %$",
648d24583c1574441c4fa0331a90bd4d6e7996c5Timo Sirainen MEMBER(quota_full_tempfail) FALSE,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(lda_mailbox_autocreate) FALSE,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(lda_mailbox_autosubscribe) FALSE
c0a87e5f3316a57e6f915882fa1951d0fbb74a61Timo Sirainen};
c0a87e5f3316a57e6f915882fa1951d0fbb74a61Timo Sirainen
c0a87e5f3316a57e6f915882fa1951d0fbb74a61Timo Sirainenstatic const struct setting_parser_info *lda_setting_dependencies[] = {
c0a87e5f3316a57e6f915882fa1951d0fbb74a61Timo Sirainen &mail_user_setting_parser_info,
c0a87e5f3316a57e6f915882fa1951d0fbb74a61Timo Sirainen NULL
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen};
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainenconst struct setting_parser_info lda_setting_parser_info = {
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen MEMBER(module_name) "lda",
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen MEMBER(defines) lda_setting_defines,
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen MEMBER(defaults) &lda_default_settings,
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen MEMBER(type_offset) (size_t)-1,
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen MEMBER(struct_size) sizeof(struct lda_settings),
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen MEMBER(parent_offset) (size_t)-1,
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen MEMBER(parent) NULL,
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen
12b4dbf933ee54f7b96968ba150095baa985fdafTimo Sirainen#ifdef CONFIG_BINARY
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen MEMBER(check_func) NULL,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen#else
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen MEMBER(check_func) lda_settings_check,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen#endif
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen MEMBER(dependencies) lda_setting_dependencies
e9df0f285429d2b896ecdb4cd873d25e5e895620Timo Sirainen};
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainenstatic bool lda_settings_check(void *_set, pool_t pool ATTR_UNUSED,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen const char **error_r)
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen{
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen struct lda_settings *set = _set;
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen
e9df0f285429d2b896ecdb4cd873d25e5e895620Timo Sirainen if (*set->postmaster_address == '\0') {
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen *error_r = "postmaster_address setting not given";
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen return FALSE;
ad396be1d926e49cd31b0732824362647ecd5fc2Timo Sirainen }
ad396be1d926e49cd31b0732824362647ecd5fc2Timo Sirainen return TRUE;
ad396be1d926e49cd31b0732824362647ecd5fc2Timo Sirainen}
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen