]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
submission: Separately pass XCLIENT HELO value from pre-login to post-login service.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 18 Jun 2021 17:31:54 +0000 (19:31 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 23 Jul 2021 06:47:02 +0000 (06:47 +0000)
src/submission-login/client-authenticate.c
src/submission/main.c
src/submission/submission-client.c
src/submission/submission-client.h

index 1e55918b120782bcf4b1e37feb21a4db8e88e158..cff7c5ba06ac697db58096a82bcb49c654b17f23 100644 (file)
@@ -268,6 +268,7 @@ int cmd_auth(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
        struct submission_client *subm_client = conn_ctx;
        struct client *client = &subm_client->common;
        struct smtp_server_helo_data *helo;
+       struct smtp_proxy_data proxy;
 
        i_assert(subm_client->pending_auth == NULL);
 
@@ -281,6 +282,13 @@ int cmd_auth(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
        }
        buffer_append_c(buf, '\0');
 
+       /* pass proxied ehlo parameter to post-login service upon successful
+          login */
+       smtp_server_connection_get_proxy_data(subm_client->conn, &proxy);
+       if (proxy.helo != NULL)
+               buffer_append(buf, proxy.helo, strlen(proxy.helo));
+       buffer_append_c(buf, '\0');
+
        i_free(client->master_data_prefix);
        client->master_data_prefix_len = buf->used;
        client->master_data_prefix = buffer_free_without_data(&buf);
index 89f1bf0427976c8d5672a649a95d95a5e38ce022..d64325dfb2cf9e84684cb5d4d499f90231da4bb2 100644 (file)
@@ -148,6 +148,7 @@ client_create_from_input(const struct mail_storage_service_input *input,
        struct submission_settings *set;
        const char *errstr;
        const char *helo = NULL;
+       struct smtp_proxy_data proxy_data;
        const unsigned char *data;
        size_t data_len;
 
@@ -188,11 +189,14 @@ client_create_from_input(const struct mail_storage_service_input *input,
        /* parse input data */
        data = NULL;
        data_len = 0;
+       i_zero(&proxy_data);
        if (input_buf != NULL && input_buf->used > 0) {
                data = input_buf->data;
                data_len = input_buf->used;
 
-               if (extract_input_data_field(&data, &data_len, &helo)) {
+               if (extract_input_data_field(&data, &data_len, &helo) &&
+                   extract_input_data_field(&data, &data_len,
+                                            &proxy_data.helo)) {
                        /* nothing to do */
                }
 
@@ -202,7 +206,7 @@ client_create_from_input(const struct mail_storage_service_input *input,
        }
 
        (void)client_create(fd_in, fd_out, mail_user,
-                           user, set, helo, data, data_len);
+                           user, set, helo, &proxy_data, data, data_len);
        return 0;
 }
 
index cd93dee22cef314af6ebf2d54ccdab641a8f12f4..6627e117a0b76686f3bc673180308bb18e013762 100644 (file)
@@ -178,6 +178,7 @@ struct client *
 client_create(int fd_in, int fd_out, struct mail_user *user,
              struct mail_storage_service_user *service_user,
              const struct submission_settings *set, const char *helo,
+             const struct smtp_proxy_data *proxy_data,
              const unsigned char *pdata, unsigned int pdata_len)
 {
        enum submission_client_workarounds workarounds =
@@ -229,6 +230,7 @@ client_create(int fd_in, int fd_out, struct mail_user *user,
        client->conn = smtp_server_connection_create(smtp_server,
                fd_in, fd_out, user->conn.remote_ip, user->conn.remote_port,
                FALSE, &smtp_set, &smtp_callbacks, client);
+       smtp_server_connection_set_proxy_data(client->conn, proxy_data);
        smtp_server_connection_login(client->conn, client->user->username, helo,
                                     pdata, pdata_len, user->conn.ssl_secured);
 
index 102aa10eab451f13189cc70117f0ce7881b9fc45..76776ed732a6b67d89d2e224711e98228400e575 100644 (file)
@@ -136,6 +136,7 @@ struct client *
 client_create(int fd_in, int fd_out, struct mail_user *user,
              struct mail_storage_service_user *service_user,
              const struct submission_settings *set, const char *helo,
+             const struct smtp_proxy_data *proxy_data,
              const unsigned char *pdata, unsigned int pdata_len);
 void client_destroy(struct client **client, const char *prefix,
                    const char *reason) ATTR_NULL(2, 3);