]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: lmtp-proxy - Add ORCPT parameter to RCPT command when recipient path changes.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 8 Oct 2019 20:54:12 +0000 (22:54 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 7 Nov 2019 07:34:34 +0000 (07:34 +0000)
This will happen when passdb changes the username.

src/lmtp/lmtp-proxy.c

index 8d9ee6df52828313649697ca9b939657cdba5133..dd79fa5711924c82536ab2f4d0c79d71b7ad7ef8 100644 (file)
@@ -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);