dovecot-2.2: lmtp: Added lmtp_hdr_delivery_address=final|origina...

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 24 12:15:38 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/df0eba01d105
changeset: 18476:df0eba01d105
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 24 15:13:59 2015 +0300
description:
lmtp: Added lmtp_hdr_delivery_address=final|original|none setting.
This controls what username is used for logging Delivered-To: header and the
"for user at domain" in Received: header. The default "final" is the regular
username as earlier, "original" logs the RFC822 address received via ORCPT
parameter or fallbacks to username, "none" logs nothing.

diffstat:

 src/lmtp/commands.c      |  18 +++++++++++++++++-
 src/lmtp/lmtp-settings.c |  29 +++++++++++++++++++++++++++++
 src/lmtp/lmtp-settings.h |  11 +++++++++++
 3 files changed, 57 insertions(+), 1 deletions(-)

diffs (126 lines):

diff -r daa426965e5a -r df0eba01d105 src/lmtp/commands.c
--- a/src/lmtp/commands.c	Fri Apr 24 14:47:43 2015 +0300
+++ b/src/lmtp/commands.c	Fri Apr 24 15:13:59 2015 +0300
@@ -1060,13 +1060,29 @@
 static const char *client_get_added_headers(struct client *client)
 {
 	string_t *str = t_str_new(200);
+	void **sets;
+	const struct lmtp_settings *lmtp_set;
 	const char *host, *rcpt_to = NULL;
 
 	if (array_count(&client->state.rcpt_to) == 1) {
 		struct mail_recipient *const *rcptp =
 			array_idx(&client->state.rcpt_to, 0);
 
-		rcpt_to = (*rcptp)->address;
+		sets = mail_storage_service_user_get_set((*rcptp)->service_user);
+		lmtp_set = sets[2];
+
+		switch (lmtp_set->parsed_lmtp_hdr_delivery_address) {
+		case LMTP_HDR_DELIVERY_ADDRESS_NONE:
+			break;
+		case LMTP_HDR_DELIVERY_ADDRESS_FINAL:
+			rcpt_to = (*rcptp)->address;
+			break;
+		case LMTP_HDR_DELIVERY_ADDRESS_ORIGINAL:
+			if (!orcpt_get_valid_rfc822((*rcptp)->params.dsn_orcpt,
+						    &rcpt_to))
+				rcpt_to = (*rcptp)->address;
+			break;
+		}
 	}
 
 	/* don't set Return-Path when proxying so it won't get added twice */
diff -r daa426965e5a -r df0eba01d105 src/lmtp/lmtp-settings.c
--- a/src/lmtp/lmtp-settings.c	Fri Apr 24 14:47:43 2015 +0300
+++ b/src/lmtp/lmtp-settings.c	Fri Apr 24 15:13:59 2015 +0300
@@ -14,6 +14,8 @@
 #include <stddef.h>
 #include <unistd.h>
 
+static bool lmtp_settings_check(void *_set, pool_t pool, const char **error_r);
+
 /* <settings checks> */
 static struct file_listener_settings lmtp_unix_listeners_array[] = {
 	{ "lmtp", 0666, "", "" }
@@ -62,6 +64,7 @@
 	DEF(SET_BOOL, lmtp_rcpt_check_quota),
 	DEF(SET_UINT, lmtp_user_concurrency_limit),
 	DEF(SET_STR, lmtp_address_translate),
+	DEF(SET_ENUM, lmtp_hdr_delivery_address),
 	DEF(SET_STR_VARS, login_greeting),
 	DEF(SET_STR, login_trusted_networks),
 
@@ -74,6 +77,7 @@
 	.lmtp_rcpt_check_quota = FALSE,
 	.lmtp_user_concurrency_limit = 0,
 	.lmtp_address_translate = "",
+	.lmtp_hdr_delivery_address = "final:none:original",
 	.login_greeting = PACKAGE_NAME" ready.",
 	.login_trusted_networks = ""
 };
@@ -93,9 +97,34 @@
 
 	.parent_offset = (size_t)-1,
 
+	.check_func = lmtp_settings_check,
 	.dependencies = lmtp_setting_dependencies
 };
 
+/* <settings checks> */
+static bool lmtp_settings_check(void *_set, pool_t pool ATTR_UNUSED,
+				const char **error_r)
+{
+	struct lmtp_settings *set = _set;
+
+	if (strcmp(set->lmtp_hdr_delivery_address, "none") == 0) {
+		set->parsed_lmtp_hdr_delivery_address =
+			LMTP_HDR_DELIVERY_ADDRESS_NONE;
+	} else if (strcmp(set->lmtp_hdr_delivery_address, "final") == 0) {
+		set->parsed_lmtp_hdr_delivery_address =
+			LMTP_HDR_DELIVERY_ADDRESS_FINAL;
+	} else if (strcmp(set->lmtp_hdr_delivery_address, "original") == 0) {
+		set->parsed_lmtp_hdr_delivery_address =
+			LMTP_HDR_DELIVERY_ADDRESS_ORIGINAL;
+	} else {
+		*error_r = t_strdup_printf("Unknown lmtp_hdr_delivery_address: %s",
+					   set->lmtp_hdr_delivery_address);
+		return FALSE;
+	}
+	return TRUE;
+}
+/* </settings checks> */
+
 void lmtp_settings_dup(const struct setting_parser_context *set_parser,
 		       pool_t pool,
 		       struct lmtp_settings **lmtp_set_r,
diff -r daa426965e5a -r df0eba01d105 src/lmtp/lmtp-settings.h
--- a/src/lmtp/lmtp-settings.h	Fri Apr 24 14:47:43 2015 +0300
+++ b/src/lmtp/lmtp-settings.h	Fri Apr 24 15:13:59 2015 +0300
@@ -4,14 +4,25 @@
 struct lda_settings;
 struct lmtp_settings;
 
+/* <settings checks> */
+enum lmtp_hdr_delivery_address {
+	LMTP_HDR_DELIVERY_ADDRESS_NONE,
+	LMTP_HDR_DELIVERY_ADDRESS_FINAL,
+	LMTP_HDR_DELIVERY_ADDRESS_ORIGINAL
+};
+/* </settings checks> */
+
 struct lmtp_settings {
 	bool lmtp_proxy;
 	bool lmtp_save_to_detail_mailbox;
 	bool lmtp_rcpt_check_quota;
 	unsigned int lmtp_user_concurrency_limit;
 	const char *lmtp_address_translate;
+	const char *lmtp_hdr_delivery_address;
 	const char *login_greeting;
 	const char *login_trusted_networks;
+
+	enum lmtp_hdr_delivery_address parsed_lmtp_hdr_delivery_address;
 };
 
 extern const struct setting_parser_info lmtp_setting_parser_info;


More information about the dovecot-cvs mailing list