]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Forward end_client_tls_secured state through proxies
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 4 Nov 2022 21:00:58 +0000 (23:00 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 16 Nov 2022 08:09:54 +0000 (08:09 +0000)
src/lmtp/lmtp-client.c
src/lmtp/lmtp-client.h
src/lmtp/lmtp-local.c
src/lmtp/lmtp-proxy.c
src/lmtp/lmtp-proxy.h

index 95e13a8679e56fe4a382e576ddaf8684ef26a7d4..985f59df501bfe7044d9fde86ca7f589c19fd9d8 100644 (file)
@@ -347,6 +347,12 @@ client_connection_proxy_data_updated(void *context,
 
        client->remote_ip = data->source_ip;
        client->remote_port = data->source_port;
+       if (data->client_transport != NULL) {
+               client->end_client_tls_secured = TRUE;
+               client->end_client_tls_secured =
+                       str_begins_with(data->client_transport,
+                                       CLIENT_TRANSPORT_TLS);
+       }
 
        if (clients_count == 1)
                refresh_proctitle();
index 9442f21b2d28a44178cd2bf17ac163fe419606d0..43e592c7a7475014c1bddea204c50cbc43dd00d9 100644 (file)
@@ -98,6 +98,8 @@ struct client {
 
        bool disconnected:1;
        bool destroyed:1;
+       bool end_client_tls_secured:1;
+       bool end_client_tls_secured_set:1;
 };
 
 struct lmtp_module_register {
index a39b63e82c77533a9aa698df18c86bef3425e832..35f16e3ae7b24c4c1437213ad023d5cbe0d156f1 100644 (file)
@@ -306,6 +306,8 @@ int lmtp_local_rcpt(struct client *client,
        input.remote_port = client->remote_port;
        input.session_id = lrcpt->session_id;
        input.conn_ssl_secured =
+               client->end_client_tls_secured_set ?
+               client->end_client_tls_secured :
                smtp_server_connection_is_ssl_secured(client->conn);
        input.forward_fields = lrcpt->forward_fields;
        input.event_parent = rcpt->event;
index 11e218e8f45ce894b82927c050a6df46bf27403a..76276848dd480a65bcb77afe555f265a1574adcc 100644 (file)
@@ -125,6 +125,12 @@ lmtp_proxy_init(struct client *client,
                                              &lmtp_set.proxy_data);
        lmtp_set.proxy_data.source_ip = client->remote_ip;
        lmtp_set.proxy_data.source_port = client->remote_port;
+       bool end_client_tls_secured =
+               client->end_client_tls_secured_set ?
+               client->end_client_tls_secured :
+               smtp_server_connection_is_ssl_secured(client->conn);
+       lmtp_set.proxy_data.client_transport = end_client_tls_secured ?
+               CLIENT_TRANSPORT_TLS : CLIENT_TRANSPORT_INSECURE;
        /* This initial session_id is used only locally by lib-smtp. Each LMTP
           proxy connection gets a more specific updated session_id. */
        lmtp_set.proxy_data.session = trans->id;
index 5ef71c4c7ddb6006b03709458b6d498b23d660ff..e0e8e9cf60097d97238ab99faa01b30522816d6e 100644 (file)
@@ -10,6 +10,9 @@
 #define LMTP_PROXY_DEFAULT_TTL 5
 #define LMTP_PROXY_DEFAULT_PORT 24
 
+#define CLIENT_TRANSPORT_TLS "TLS"
+#define CLIENT_TRANSPORT_INSECURE "insecure"
+
 struct smtp_server_cmd_ctx;
 struct smtp_server_cmd_rcpt;
 struct lmtp_proxy;