const char *reason)
{
struct mail_user *user = ctx->rcpt_user;
- const struct mail_storage_settings *mail_set =
- mail_user_set_get_storage_set(user);
struct ssl_iostream_settings ssl_set;
struct mail *mail = ctx->src_mail;
struct istream *input;
return 0;
}
- if (!mail_storage_get_postmaster_address(mail_set, &postmaster_addr,
- &error)) {
+ if (!mail_user_set_get_postmaster_address(user->set, &postmaster_addr,
+ &error)) {
i_error("msgid=%s: Invalid postmaster_address - can't send rejection: %s",
orig_msgid == NULL ? "" : str_sanitize(orig_msgid, 80), error);
return -1;
output = smtp_submit_send(smtp_submit);
msgid = mail_deliver_get_new_message_id(ctx);
- boundary = t_strdup_printf("%s/%s", my_pid, mail_set->hostname);
+ boundary = t_strdup_printf("%s/%s", my_pid, user->set->hostname);
str = t_str_new(512);
str_printfa(str, "Message-ID: %s\r\n", msgid);
str_printfa(str, "--%s\r\n"
"Content-Type: message/delivery-status\r\n\r\n",
boundary);
- str_printfa(str, "Reporting-MTA: dns; %s\r\n", mail_set->hostname);
+ str_printfa(str, "Reporting-MTA: dns; %s\r\n", user->set->hostname);
if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0)
str_printfa(str, "Original-Recipient: rfc822; %s\r\n", hdr);
str_printfa(str, "Final-Recipient: rfc822; %s\r\n",
"Content-Type: message/disposition-notification\r\n\r\n",
boundary);
str_printfa(str, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n",
- mail_set->hostname);
+ user->set->hostname);
if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0)
str_printfa(str, "Original-Recipient: rfc822; %s\r\n", hdr);
str_printfa(str, "Final-Recipient: rfc822; %s\r\n",
#include <stddef.h>
static bool mail_storage_settings_check(void *_set, pool_t pool, const char **error_r);
-static bool mail_storage_settings_expand_check(void *_set, pool_t pool ATTR_UNUSED, const char **error_r);
static bool namespace_settings_check(void *_set, pool_t pool, const char **error_r);
static bool mailbox_settings_check(void *_set, pool_t pool, const char **error_r);
static bool mail_user_settings_check(void *_set, pool_t pool, const char **error_r);
+static bool mail_user_settings_expand_check(void *_set, pool_t pool ATTR_UNUSED, const char **error_r);
#undef DEF
#define DEF(type, name) \
DEF(SET_ENUM, lock_method),
DEF(SET_STR, pop3_uidl_format),
- DEF(SET_STR_VARS, postmaster_address),
DEF(SET_STR, hostname),
DEF(SET_STR, recipient_delimiter),
.lock_method = "fcntl:flock:dotlock",
.pop3_uidl_format = "%08Xu%08Xv",
- .postmaster_address = "postmaster@%d",
.hostname = "",
.recipient_delimiter = "+",
.parent = &mail_user_setting_parser_info,
.check_func = mail_storage_settings_check,
-#ifndef CONFIG_BINARY
- .expand_check_func = mail_storage_settings_expand_check,
-#endif
};
#undef DEF
DEF(SET_STR, mail_log_prefix),
+ DEF(SET_STR, hostname),
+ DEF(SET_STR_VARS, postmaster_address),
+
DEFLIST_UNIQUE(namespaces, "namespace", &mail_namespace_setting_parser_info),
{ SET_STRLIST, "plugin", offsetof(struct mail_user_settings, plugin_envs), NULL },
.mail_log_prefix = "%s(%u)<%{pid}><%{session}>: ",
+ .hostname = "",
+ .postmaster_address = "postmaster@%d",
+
.namespaces = ARRAY_INIT,
.plugin_envs = ARRAY_INIT
};
.parent_offset = (size_t)-1,
- .check_func = mail_user_settings_check
+ .check_func = mail_user_settings_check,
+#ifndef CONFIG_BINARY
+ .expand_check_func = mail_user_settings_expand_check,
+#endif
};
const void *
#ifndef CONFIG_BINARY
if (*set->hostname == '\0')
set->hostname = p_strdup(pool, my_hostdomain());
- if (set->postmaster_address[0] == SETTING_STRVAR_UNEXPANDED[0] &&
- set->postmaster_address[1] == '\0') {
- /* check for valid looking fqdn in hostname */
- if (strchr(set->hostname, '.') == NULL) {
- *error_r = "postmaster_address setting not given";
- return FALSE;
- }
- set->postmaster_address =
- p_strconcat(pool, SETTING_STRVAR_UNEXPANDED,
- "postmaster@", set->hostname, NULL);
- }
#endif
/* parse mail_attachment_indicator_options */
return TRUE;
}
-#ifndef CONFIG_BINARY
-static bool parse_postmaster_address(const char *address, pool_t pool,
- struct mail_storage_settings *set,
- const char **error_r) ATTR_NULL(3)
-{
- struct message_address *addr;
- struct smtp_address *smtp_addr;
-
- addr = message_address_parse(pool,
- (const unsigned char *)address,
- strlen(address), 2, 0);
- if (addr == NULL || addr->domain == NULL || addr->invalid_syntax ||
- smtp_address_create_from_msg(pool, addr, &smtp_addr) < 0) {
- *error_r = t_strdup_printf(
- "invalid address `%s' specified for the "
- "postmaster_address setting", address);
- return FALSE;
- }
- if (addr->next != NULL) {
- *error_r = "more than one address specified for the "
- "postmaster_address setting";
- return FALSE;
- }
- if (addr->name == NULL || *addr->name == '\0')
- addr->name = "Postmaster";
- if (set != NULL) {
- set->_parsed_postmaster_address = addr;
- set->_parsed_postmaster_address_smtp = smtp_addr;
- }
- return TRUE;
-}
-
-static bool mail_storage_settings_expand_check(void *_set,
- pool_t pool, const char **error_r ATTR_UNUSED)
-{
- struct mail_storage_settings *set = _set;
- const char *error;
-
- /* Parse if possible. Perform error handling later. */
- (void)parse_postmaster_address(set->postmaster_address, pool,
- set, &error);
- return TRUE;
-}
-#endif
-
static bool namespace_settings_check(void *_set, pool_t pool ATTR_UNUSED,
const char **error_r)
{
#ifndef CONFIG_BINARY
fix_base_path(set, pool, &set->auth_socket_path);
+
+ if (*set->hostname == '\0')
+ set->hostname = p_strdup(pool, my_hostdomain());
+ if (set->postmaster_address[0] == SETTING_STRVAR_UNEXPANDED[0] &&
+ set->postmaster_address[1] == '\0') {
+ /* check for valid looking fqdn in hostname */
+ if (strchr(set->hostname, '.') == NULL) {
+ *error_r = "postmaster_address setting not given";
+ return FALSE;
+ }
+ set->postmaster_address =
+ p_strconcat(pool, SETTING_STRVAR_UNEXPANDED,
+ "postmaster@", set->hostname, NULL);
+ }
#else
if (*set->mail_plugins != '\0' &&
access(set->mail_plugin_dir, R_OK | X_OK) < 0) {
#endif
return TRUE;
}
+
+#ifndef CONFIG_BINARY
+static bool parse_postmaster_address(const char *address, pool_t pool,
+ struct mail_user_settings *set,
+ const char **error_r) ATTR_NULL(3)
+{
+ struct message_address *addr;
+ struct smtp_address *smtp_addr;
+
+ addr = message_address_parse(pool,
+ (const unsigned char *)address,
+ strlen(address), 2, 0);
+ if (addr == NULL || addr->domain == NULL || addr->invalid_syntax ||
+ smtp_address_create_from_msg(pool, addr, &smtp_addr) < 0) {
+ *error_r = t_strdup_printf(
+ "invalid address `%s' specified for the "
+ "postmaster_address setting", address);
+ return FALSE;
+ }
+ if (addr->next != NULL) {
+ *error_r = "more than one address specified for the "
+ "postmaster_address setting";
+ return FALSE;
+ }
+ if (addr->name == NULL || *addr->name == '\0')
+ addr->name = "Postmaster";
+ if (set != NULL) {
+ set->_parsed_postmaster_address = addr;
+ set->_parsed_postmaster_address_smtp = smtp_addr;
+ }
+ return TRUE;
+}
+
+static bool
+mail_user_settings_expand_check(void *_set, pool_t pool,
+ const char **error_r ATTR_UNUSED)
+{
+ struct mail_user_settings *set = _set;
+ const char *error;
+
+ /* Parse if possible. Perform error handling later. */
+ (void)parse_postmaster_address(set->postmaster_address, pool,
+ set, &error);
+ return TRUE;
+}
+#endif
+
/* </settings checks> */
static void
-get_postmaster_address_error(const struct mail_storage_settings *set,
+get_postmaster_address_error(const struct mail_user_settings *set,
const char **error_r)
{
if (parse_postmaster_address(set->postmaster_address,
set->postmaster_address);
}
-bool mail_storage_get_postmaster_address(const struct mail_storage_settings *set,
- const struct message_address **address_r,
- const char **error_r)
+bool mail_user_set_get_postmaster_address(const struct mail_user_settings *set,
+ const struct message_address **address_r,
+ const char **error_r)
{
*address_r = set->_parsed_postmaster_address;
if (*address_r != NULL)
return FALSE;
}
-bool mail_storage_get_postmaster_smtp(const struct mail_storage_settings *set,
- const struct smtp_address **address_r,
- const char **error_r)
+bool mail_user_set_get_postmaster_smtp(const struct mail_user_settings *set,
+ const struct smtp_address **address_r,
+ const char **error_r)
{
*address_r = set->_parsed_postmaster_address_smtp;
if (*address_r != NULL)
const char *lock_method;
const char *pop3_uidl_format;
- const char *postmaster_address;
-
const char *hostname;
const char *recipient_delimiter;
enum file_lock_method parsed_lock_method;
enum fsync_mode parsed_fsync_mode;
- /* May be NULL - use mail_storage_get_postmaster_address() instead of
- directly accessing this. */
- const struct message_address *_parsed_postmaster_address;
- const struct smtp_address *_parsed_postmaster_address_smtp;
const char *const *parsed_mail_attachment_content_type_filter;
bool parsed_mail_attachment_exclude_inlined;
const char *mail_log_prefix;
+ const char *hostname;
+ const char *postmaster_address;
+
ARRAY(struct mail_namespace_settings *) namespaces;
ARRAY(const char *) plugin_envs;
+
+ /* May be NULL - use mail_storage_get_postmaster_address() instead of
+ directly accessing this. */
+ const struct message_address *_parsed_postmaster_address;
+ const struct smtp_address *_parsed_postmaster_address_smtp;
};
extern const struct setting_parser_info mail_user_setting_parser_info;
const struct dynamic_settings_parser *
mail_storage_get_dynamic_parsers(pool_t pool);
-bool mail_storage_get_postmaster_address(const struct mail_storage_settings *set,
- const struct message_address **address_r,
- const char **error_r);
-bool mail_storage_get_postmaster_smtp(const struct mail_storage_settings *set,
- const struct smtp_address **address_r,
- const char **error_r);
+bool mail_user_set_get_postmaster_address(const struct mail_user_settings *set,
+ const struct message_address **address_r,
+ const char **error_r);
+bool mail_user_set_get_postmaster_smtp(const struct mail_user_settings *set,
+ const struct smtp_address **address_r,
+ const char **error_r);
#endif