From: Stephan Bosch Date: Tue, 8 Oct 2019 20:54:12 +0000 (+0200) Subject: lmtp: lmtp-proxy - Add ORCPT parameter to RCPT command when recipient path changes. X-Git-Tag: 2.3.9~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=729c0ba2e774c35e4a886e22cd5d17e2e647176a;p=thirdparty%2Fdovecot%2Fcore.git lmtp: lmtp-proxy - Add ORCPT parameter to RCPT command when recipient path changes. This will happen when passdb changes the username. --- diff --git a/src/lmtp/lmtp-proxy.c b/src/lmtp/lmtp-proxy.c index 8d9ee6df52..dd79fa5711 100644 --- a/src/lmtp/lmtp-proxy.c +++ b/src/lmtp/lmtp-proxy.c @@ -481,6 +481,7 @@ int lmtp_proxy_rcpt(struct client *client, struct smtp_proxy_data proxy_data; struct smtp_address *user; struct smtp_client_transaction_rcpt *relay_rcpt; + struct smtp_params_rcpt *rcpt_params = &rcpt->params; pool_t auth_pool; int ret; @@ -578,6 +579,17 @@ int lmtp_proxy_rcpt(struct client *client, if (client->proxy == NULL) client->proxy = lmtp_proxy_init(client, trans); + /* Add an ORCPT parameter when passdb changed the username (and + therefore the RCPT address changed) and there is no ORCPT parameter + yet. */ + if (!smtp_params_rcpt_has_orcpt(rcpt_params) && + !smtp_address_equals(address, rcpt->path)) { + pool_t pool = pool_datastack_create(); + rcpt_params = p_new(pool, struct smtp_params_rcpt, 1); + smtp_params_rcpt_copy(pool, rcpt_params, &rcpt->params); + smtp_params_rcpt_set_orcpt(rcpt_params, pool, rcpt->path); + } + conn = lmtp_proxy_get_connection(client->proxy, &set); pool_unref(&auth_pool); @@ -594,7 +606,7 @@ int lmtp_proxy_rcpt(struct client *client, lmtp_proxy_rcpt_approved, lprcpt); relay_rcpt = smtp_client_transaction_add_pool_rcpt( - conn->lmtp_trans, rcpt->pool, address, &rcpt->params, + conn->lmtp_trans, rcpt->pool, address, rcpt_params, lmtp_proxy_rcpt_cb, lprcpt); smtp_client_transaction_rcpt_set_data_callback( relay_rcpt, lmtp_proxy_data_cb, lprcpt);